]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: skip various tests if namespacing is not available 10505/head
authorLennart Poettering <lennart@poettering.net>
Wed, 24 Oct 2018 14:53:14 +0000 (16:53 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 Oct 2018 17:40:24 +0000 (19:40 +0200)
Apparently on Debian LXC/AppArmor doesn't allow namespacing to container
payloads. Deal with it.

Fixes: #9700
src/test/test-execute.c
src/test/test-namespace.c
src/test/test-process-util.c
src/test/test-seccomp.c

index b5bb535adc010ee6b4974f5f28530018771aa261..e6715f9574994818e03cf87a8ee93a34afa2a48a 100644 (file)
@@ -28,7 +28,7 @@
 #include "util.h"
 #include "virt.h"
 
-static bool can_unshare = true;
+static bool can_unshare;
 
 typedef void (*test_function_t)(Manager *m);
 
@@ -760,6 +760,8 @@ int main(int argc, char *argv[]) {
         (void) unsetenv("LOGNAME");
         (void) unsetenv("SHELL");
 
+        can_unshare = have_namespaces();
+
         /* It is needed otherwise cgroup creation fails */
         if (getuid() != 0)
                 return log_tests_skipped("not root");
index ab8f05076df7b4e069cb159435c52844731aea2c..cc2efecfd2ec9d319146f99730d1511c80bf1fcc 100644 (file)
@@ -111,6 +111,11 @@ int main(int argc, char *argv[]) {
 
         test_setup_logging(LOG_INFO);
 
+        if (!have_namespaces()) {
+                log_tests_skipped("Don't have namespace support");
+                return EXIT_TEST_SKIP;
+        }
+
         assert_se(sd_id128_get_boot(&bid) >= 0);
         sd_id128_to_string(bid, boot_id);
 
index 921c304deced330a506268e228452536371f7396..ae0f1a564d72747fbe343a3de6df3093a3687add 100644 (file)
@@ -186,6 +186,11 @@ static void test_get_process_cmdline_harder(void) {
                 return;
         }
 
+        if (!have_namespaces()) {
+                log_notice("Testing without namespaces, skipping %s", __func__);
+                return;
+        }
+
 #if HAVE_VALGRIND_VALGRIND_H
         /* valgrind patches open(/proc//cmdline)
          * so, test_get_process_cmdline_harder fails always
index 00cd216a4bdd5e96b21c67366caca348d45edf76..fbfeedd536490dc84849472feaaf0858e31e7f13 100644 (file)
@@ -178,6 +178,11 @@ static void test_restrict_namespace(void) {
         unsigned long ul;
         pid_t pid;
 
+        if (!have_namespaces()) {
+                log_notice("Testing without namespaces, skipping %s", __func__);
+                return;
+        }
+
         log_info("/* %s */", __func__);
 
         assert_se(namespace_flags_to_string(0, &s) == 0 && streq(s, ""));