From: Yu Watanabe Date: Tue, 15 Jul 2025 23:49:52 +0000 (+0900) Subject: test-bpf-token: use test macros and functions X-Git-Tag: v258-rc1~30^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1eed4e592d93a12199184050e96261261fe3d63;p=thirdparty%2Fsystemd.git test-bpf-token: use test macros and functions No functional change, just refactoring. --- diff --git a/src/test/test-bpf-token.c b/src/test/test-bpf-token.c index 23dd1430821..3d6127182ec 100644 --- a/src/test/test-bpf-token.c +++ b/src/test/test-bpf-token.c @@ -4,25 +4,22 @@ #include #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);