]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: use log_tests_skipped() and friend more 29778/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 31 Oct 2023 05:53:10 +0000 (14:53 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 31 Oct 2023 05:54:27 +0000 (14:54 +0900)
src/test/test-compress.c
src/test/test-dev-setup.c
src/test/test-firewall-util.c
src/test/test-loopback.c
src/test/test-recurse-dir.c

index 18f8ce3b351e139618ceba79f7600052eaf97ab0..2f20d0011671f86d70afbddf0942056e89f58908 100644 (file)
@@ -368,7 +368,6 @@ int main(int argc, char *argv[]) {
 
         return 0;
 #else
-        log_info("/* XZ, LZ4 and ZSTD tests skipped */");
-        return EXIT_TEST_SKIP;
+        return log_tests_skipped("no compression algorithm supported");
 #endif
 }
index ea9df56aebc0bddfdbdbc719f88b7c3274284c39..c9022ab97353228559b13126c005f9ce615ecdf1 100644 (file)
@@ -6,6 +6,7 @@
 #include "mkdir.h"
 #include "path-util.h"
 #include "rm-rf.h"
+#include "tests.h"
 #include "tmpfile-util.h"
 
 int main(int argc, char *argv[]) {
@@ -14,7 +15,7 @@ int main(int argc, char *argv[]) {
         struct stat st;
 
         if (have_effective_cap(CAP_DAC_OVERRIDE) <= 0)
-                return EXIT_TEST_SKIP;
+                return log_tests_skipped("missing capability (CAP_DAC_OVERRIDE)");
 
         assert_se(mkdtemp_malloc("/tmp/test-dev-setupXXXXXX", &p) >= 0);
 
index 3ca3108e365b8b9e0241aa1dc3c32eee6b6287ba..3f47a30aefbc493b88e36922e28535e7dfb38d39 100644 (file)
@@ -107,7 +107,7 @@ int main(int argc, char *argv[]) {
         assert_se(ctx);
 
         if (ctx->backend == FW_BACKEND_NONE)
-                return EXIT_TEST_SKIP;
+                return log_tests_skipped("no firewall backend supported");
 
         if (test_v4(ctx) && ctx->backend == FW_BACKEND_NFTABLES)
                 test_v6(ctx);
index 1a423e556e873e302f29499a60f3f4a85063f28e..48869ae337def2fe0d0ebc2be139a2cf08384fb6 100644 (file)
@@ -13,10 +13,8 @@ TEST_RET(loopback_setup) {
         int r;
 
         if (unshare(CLONE_NEWUSER | CLONE_NEWNET) < 0) {
-                if (ERRNO_IS_PRIVILEGE(errno) || ERRNO_IS_NOT_SUPPORTED(errno)) {
-                        log_notice("Skipping test, lacking privileges or namespaces not supported");
-                        return EXIT_TEST_SKIP;
-                }
+                if (ERRNO_IS_PRIVILEGE(errno) || ERRNO_IS_NOT_SUPPORTED(errno))
+                        return log_tests_skipped("lacking privileges or namespaces not supported");
                 return log_error_errno(errno, "Failed to create user+network namespace: %m");
         }
 
index 9362d6729aaaaae7e04269901df98232970850b9..8684d064ec391833ee2aed2f87a5697e204879e0 100644 (file)
@@ -132,19 +132,15 @@ int main(int argc, char *argv[]) {
                 p = "/usr/share/man"; /* something hopefully reasonably stable while we run (and limited in size) */
 
         fd = open(p, O_DIRECTORY|O_CLOEXEC);
-        if (fd < 0 && errno == ENOENT) {
-                log_warning_errno(errno, "Couldn't open directory %s, ignoring: %m", p);
-                return EXIT_TEST_SKIP;
-        }
+        if (fd < 0 && errno == ENOENT)
+                return log_tests_skipped_errno(errno, "Couldn't open directory %s", p);
         assert_se(fd >= 0);
 
         /* If the test directory is on an overlayfs then files and their directory may return different
          * st_dev in stat results, which confuses nftw into thinking they're on different filesystems and
          * won't return the result when the FTW_MOUNT flag is set. */
-        if (fd_is_fs_type(fd, OVERLAYFS_SUPER_MAGIC)) {
-                log_tests_skipped("nftw mountpoint detection produces false-positives on overlayfs");
-                return EXIT_TEST_SKIP;
-        }
+        if (fd_is_fs_type(fd, OVERLAYFS_SUPER_MAGIC))
+                return log_tests_skipped("nftw mountpoint detection produces false-positives on overlayfs");
 
         /* Enumerate the specified dirs in full, once via nftw(), and once via recurse_dir(), and ensure the
          * results are identical. nftw() sometimes skips symlinks (see