Add int. test for failing to load service
authorDavin McCall <davmac@davmac.org>
Thu, 26 Dec 2019 05:03:29 +0000 (05:03 +0000)
committerDavin McCall <davmac@davmac.org>
Thu, 26 Dec 2019 05:03:29 +0000 (05:03 +0000)
.gitignore
src/igr-tests/igr-runner.cc
src/igr-tests/no-command-error/dinit-run.expected [new file with mode: 0644]
src/igr-tests/no-command-error/run-test.sh [new file with mode: 0755]
src/igr-tests/no-command-error/sd/no-command [new file with mode: 0644]

index 7b8e784ccf2551600e7776a6cb782de54cae8919..324338b2aa76860bdcf9e9810aa82c571084bd4c 100644 (file)
@@ -28,6 +28,7 @@
 /src/igr-tests/check-cycle/output.txt
 /src/igr-tests/reload1/sd
 /src/igr-tests/reload2/sd
+/src/igr-tests/no-command-error/dinit-run.log
 
 # Generated man pages:
 /doc/manpages/*.5
index 130cfed472f220def3f457b9d525b2b5f194502d..bc26801c602cfbc039dc04d259d82f205af30492 100644 (file)
@@ -13,7 +13,7 @@ extern char **environ;
 int main(int argc, char **argv)
 {
     const char * const test_dirs[] = { "basic", "environ", "ps-environ", "chain-to", "force-stop", "restart",
-            "check-basic", "check-cycle", "reload1", "reload2" };
+            "check-basic", "check-cycle", "reload1", "reload2", "no-command-error" };
     constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]);
 
     int passed = 0;
diff --git a/src/igr-tests/no-command-error/dinit-run.expected b/src/igr-tests/no-command-error/dinit-run.expected
new file mode 100644 (file)
index 0000000..028a7c8
--- /dev/null
@@ -0,0 +1 @@
+dinit: no-command: Service command not specified.
diff --git a/src/igr-tests/no-command-error/run-test.sh b/src/igr-tests/no-command-error/run-test.sh
new file mode 100755 (executable)
index 0000000..ca0ec8f
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# Check that a service without a command configured causes the appropriate error.
+#
+
+rm -f dinit-run.log
+
+../../dinit -d sd -u -p socket -q \
+       no-command -l dinit-run.log
+
+STATUS=FAIL
+if [ -e dinit-run.log ]; then
+   if [ "$(cat dinit-run.log)" = "$(cat dinit-run.expected)" ]; then
+       STATUS=PASS
+   fi
+fi
+
+if [ $STATUS = PASS ]; then exit 0; fi
+exit 1
diff --git a/src/igr-tests/no-command-error/sd/no-command b/src/igr-tests/no-command-error/sd/no-command
new file mode 100644 (file)
index 0000000..72ab343
--- /dev/null
@@ -0,0 +1,2 @@
+type=scripted
+# no command= setting!