Browse Source

Add int. test for failing to load service

Davin McCall 4 years ago
parent
commit
8d357dc388

+ 1 - 0
.gitignore

@@ -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

+ 1 - 1
src/igr-tests/igr-runner.cc

@@ -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;

+ 1 - 0
src/igr-tests/no-command-error/dinit-run.expected

@@ -0,0 +1 @@
+dinit: no-command: Service command not specified.

+ 19 - 0
src/igr-tests/no-command-error/run-test.sh

@@ -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

+ 2 - 0
src/igr-tests/no-command-error/sd/no-command

@@ -0,0 +1,2 @@
+type=scripted
+# no command= setting!