]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #5319 from keszybz/test-execute
authorLennart Poettering <lennart@poettering.net>
Mon, 13 Feb 2017 14:29:40 +0000 (15:29 +0100)
committerGitHub <noreply@github.com>
Mon, 13 Feb 2017 14:29:40 +0000 (15:29 +0100)
test-execute without capsh

1  2 
README
src/test/test-execute.c

diff --combined README
index 4b369fbc869f2562919ec78c4540b32028e70980,d3838e0cc5f5c795e30d433e3da9e44d39df6c87..dc88d5b2610907fa198692bd4226e0850fb79d53
--- 1/README
--- 2/README
+++ b/README
@@@ -180,6 -180,7 +180,7 @@@ REQUIREMENTS
          - python3-pyparsing
          - python3-evdev      (used by hwdb parsing tests)
          - strace             (used by test/test-functions)
+         - capsh              (optional, used by test-execute)
  
  USERS AND GROUPS:
          Default udev rules use the following standard system group
@@@ -275,6 -276,11 +276,6 @@@ WARNINGS
          false positives will be triggered by code which violates
          some rules but is actually safe.
  
 -        Currently, systemd-timesyncd defaults to use the Google NTP
 -        servers if not specified otherwise at configure time. You
 -        really should not ship an OS or device with this default
 -        setting. See DISTRO_PORTING for details.
 -
  ENGINEERING AND CONSULTING SERVICES:
          Kinvolk (https://kinvolk.io) offers professional engineering
          and consulting services for systemd. Please contact Chris Kühl
diff --combined src/test/test-execute.c
index 1e479b98432b798b0e885729c6f4c625e4e6061a,4e0d052d4fde4b00a808817f8cb87097e2595ad6..3a3ab3eb94975764eae6244bd50e2b9773d7f603
@@@ -145,11 -145,11 +145,11 @@@ static void test_exec_privatetmp(Manage
  
  static void test_exec_privatedevices(Manager *m) {
          if (detect_container() > 0) {
-                 log_notice("testing in container, skipping private device tests");
+                 log_notice("testing in container, skipping %s", __func__);
                  return;
          }
          if (!is_inaccessible_available()) {
-                 log_notice("testing without inaccessible, skipping private device tests");
+                 log_notice("testing without inaccessible, skipping %s", __func__);
                  return;
          }
  
  }
  
  static void test_exec_privatedevices_capabilities(Manager *m) {
+         int r;
          if (detect_container() > 0) {
-                 log_notice("testing in container, skipping private device tests");
+                 log_notice("testing in container, skipping %s", __func__);
                  return;
          }
          if (!is_inaccessible_available()) {
-                 log_notice("testing without inaccessible, skipping private device tests");
+                 log_notice("testing without inaccessible, skipping %s", __func__);
+                 return;
+         }
+         /* We use capsh to test if the capabilities are
+          * properly set, so be sure that it exists */
+         r = find_binary("capsh", NULL);
+         if (r < 0) {
+                 log_error_errno(r, "Skipping %s, could not find capsh binary: %m", __func__);
                  return;
          }
  
  }
  
  static void test_exec_protectkernelmodules(Manager *m) {
+         int r;
          if (detect_container() > 0) {
-                 log_notice("testing in container, skipping protectkernelmodules tests");
+                 log_notice("testing in container, skipping %s", __func__);
                  return;
          }
          if (!is_inaccessible_available()) {
-                 log_notice("testing without inaccessible, skipping protectkernelmodules tests");
+                 log_notice("testing without inaccessible, skipping %s", __func__);
                  return;
          }
  
+         r = find_binary("capsh", NULL);
+         if (r < 0) {
+                 log_error_errno(r, "Skipping %s, could not find capsh binary: %m", __func__);
+                 return;
+         }
          test(m, "exec-protectkernelmodules-no-capabilities.service", 0, CLD_EXITED);
          test(m, "exec-protectkernelmodules-yes-capabilities.service", 0, CLD_EXITED);
          test(m, "exec-protectkernelmodules-yes-mount-propagation.service", 0, CLD_EXITED);
@@@ -253,7 -272,7 +272,7 @@@ static void test_exec_systemcall_system
          else if (getpwnam("nfsnobody"))
                  test(m, "exec-systemcallfilter-system-user-nfsnobody.service", 0, CLD_EXITED);
          else
-                 log_error_errno(errno, "Skipping test_exec_systemcall_system_mode_with_user, could not find nobody/nfsnobody user: %m");
+                 log_error_errno(errno, "Skipping %s, could not find nobody/nfsnobody user: %m", __func__);
  #endif
  }
  
@@@ -263,7 -282,7 +282,7 @@@ static void test_exec_user(Manager *m) 
          else if (getpwnam("nfsnobody"))
                  test(m, "exec-user-nfsnobody.service", 0, CLD_EXITED);
          else
-                 log_error_errno(errno, "Skipping test_exec_user, could not find nobody/nfsnobody user: %m");
+                 log_error_errno(errno, "Skipping %s, could not find nobody/nfsnobody user: %m", __func__);
  }
  
  static void test_exec_group(Manager *m) {
          else if (getgrnam("nfsnobody"))
                  test(m, "exec-group-nfsnobody.service", 0, CLD_EXITED);
          else
-                 log_error_errno(errno, "Skipping test_exec_group, could not find nobody/nfsnobody group: %m");
+                 log_error_errno(errno, "Skipping %s, could not find nobody/nfsnobody group: %m", __func__);
  }
  
  static void test_exec_supplementary_groups(Manager *m) {
@@@ -353,17 -372,15 +372,15 @@@ static void test_exec_runtimedirectory(
          else if (getgrnam("nfsnobody"))
                  test(m, "exec-runtimedirectory-owner-nfsnobody.service", 0, CLD_EXITED);
          else
-                 log_error_errno(errno, "Skipping test_exec_runtimedirectory-owner, could not find nobody/nfsnobody group: %m");
+                 log_error_errno(errno, "Skipping %s, could not find nobody/nfsnobody group: %m", __func__);
  }
  
  static void test_exec_capabilityboundingset(Manager *m) {
          int r;
  
-         /* We use capsh to test if the capabilities are
-          * properly set, so be sure that it exists */
          r = find_binary("capsh", NULL);
          if (r < 0) {
-                 log_error_errno(r, "Skipping test_exec_capabilityboundingset, could not find capsh binary: %m");
+                 log_error_errno(r, "Skipping %s, could not find capsh binary: %m", __func__);
                  return;
          }
  
@@@ -389,9 -406,9 +406,9 @@@ static void test_exec_capabilityambient
                          test(m, "exec-capabilityambientset-nfsnobody.service", 0, CLD_EXITED);
                          test(m, "exec-capabilityambientset-merge-nfsnobody.service", 0, CLD_EXITED);
                  } else
-                         log_error_errno(errno, "Skipping test_exec_capabilityambientset, could not find nobody/nfsnobody user: %m");
+                         log_error_errno(errno, "Skipping %s, could not find nobody/nfsnobody user: %m", __func__);
          } else
-                 log_error_errno(errno, "Skipping test_exec_capabilityambientset, the kernel does not support ambient capabilities: %m");
+                 log_error_errno(errno, "Skipping %s, the kernel does not support ambient capabilities: %m", __func__);
  }
  
  static void test_exec_privatenetwork(Manager *m) {
  
          r = find_binary("ip", NULL);
          if (r < 0) {
-                 log_error_errno(r, "Skipping test_exec_privatenetwork, could not find ip binary: %m");
+                 log_error_errno(r, "Skipping %s, could not find ip binary: %m", __func__);
                  return;
          }
  
@@@ -422,10 -439,6 +439,10 @@@ static void test_exec_spec_interpolatio
          test(m, "exec-spec-interpolation.service", 0, CLD_EXITED);
  }
  
 +static void test_exec_read_only_path_suceed(Manager *m) {
 +        test(m, "exec-read-only-path-succeed.service", 0, CLD_EXITED);
 +}
 +
  static int run_tests(UnitFileScope scope, const test_function_t *tests) {
          const test_function_t *test = NULL;
          Manager *m = NULL;
@@@ -479,7 -492,6 +496,7 @@@ int main(int argc, char *argv[]) 
                  test_exec_oomscoreadjust,
                  test_exec_ioschedulingclass,
                  test_exec_spec_interpolation,
 +                test_exec_read_only_path_suceed,
                  NULL,
          };
          static const test_function_t system_tests[] = {