]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-execute: add test for PrivateNetwork
authorRonny Chevalier <chevalier.ronny@gmail.com>
Fri, 30 Oct 2015 12:51:51 +0000 (13:51 +0100)
committerRonny Chevalier <chevalier.ronny@gmail.com>
Sat, 31 Oct 2015 14:07:19 +0000 (15:07 +0100)
Makefile.am
src/test/test-execute.c
test/exec-privatenetwork-yes.service [new file with mode: 0644]

index 00b9e86346f9664c9210209d038749ccabea13d8..cd5ea6f32c19e3a387c66bbd96f50f11d71c3905 100644 (file)
@@ -1566,6 +1566,7 @@ EXTRA_DIST += \
        test/exec-workingdirectory.service \
        test/exec-umask-0177.service \
        test/exec-umask-default.service \
+       test/exec-privatenetwork-yes.service \
        test/bus-policy/hello.conf \
        test/bus-policy/methods.conf \
        test/bus-policy/ownerships.conf \
index afbaa12e94d7cd3474c53a3c1bb30b0fdec57cbb..fb0cb3fdc4149a7e85e96d7f4b786093c53edead 100644 (file)
@@ -178,6 +178,18 @@ static void test_exec_capabilityboundingset(Manager *m) {
         test(m, "exec-capabilityboundingset-invert.service", 0, CLD_EXITED);
 }
 
+static void test_exec_privatenetwork(Manager *m) {
+        int r;
+
+        r = find_binary("ip", NULL);
+        if (r < 0) {
+                log_error_errno(r, "Skipping test_exec_privatenetwork, could not find ip binary: %m");
+                return;
+        }
+
+        test(m, "exec-privatenetwork-yes.service", 0, CLD_EXITED);
+}
+
 int main(int argc, char *argv[]) {
         test_function_t tests[] = {
                 test_exec_workingdirectory,
@@ -185,6 +197,7 @@ int main(int argc, char *argv[]) {
                 test_exec_ignoresigpipe,
                 test_exec_privatetmp,
                 test_exec_privatedevices,
+                test_exec_privatenetwork,
                 test_exec_systemcallfilter,
                 test_exec_systemcallerrornumber,
                 test_exec_user,
diff --git a/test/exec-privatenetwork-yes.service b/test/exec-privatenetwork-yes.service
new file mode 100644 (file)
index 0000000..494712e
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=Test for PrivateNetwork
+
+[Service]
+ExecStart=/bin/sh -c 'i=$(ip link | grep ": " | grep -v lo); echo $i; exit $(test -z $i)'
+PrivateNetwork=yes