#include <fcntl.h>
#include "fd-util.h"
-#include "main-func.h"
#include "tests.h"
-static int run(int argc, char *argv[]) {
+static int intro(void) {
#if __LIBBPF_CURRENT_VERSION_GEQ(1, 5)
- _cleanup_close_ int bpffs_fd = -EBADF, token_fd = -EBADF;
-
- bpffs_fd = open("/sys/fs/bpf", O_RDONLY);
+ _cleanup_close_ int bpffs_fd = open("/sys/fs/bpf", O_RDONLY);
if (bpffs_fd < 0)
- return -errno;
+ return log_error_errno(errno, "Failed to open '/sys/fs/bpf': %m");
- token_fd = bpf_token_create(bpffs_fd, /* opts = */ NULL);
+ _cleanup_close_ int token_fd = bpf_token_create(bpffs_fd, /* opts = */ NULL);
if (token_fd < 0)
- return -errno;
+ return log_error_errno(errno, "Failed to create bpf token: %m");
- return 0;
+ return EXIT_SUCCESS;
#else
- exit(77);
+ return log_tests_skipped("libbpf is older than v1.5");
#endif
}
-DEFINE_MAIN_FUNCTION(run);
+DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);