]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: merge check_nspawn() into run_nspawn() 3587/head
authorMartin Pitt <martin.pitt@ubuntu.com>
Fri, 24 Jun 2016 14:23:39 +0000 (16:23 +0200)
committerMartin Pitt <martin.pitt@ubuntu.com>
Fri, 24 Jun 2016 14:23:39 +0000 (16:23 +0200)
This makes nspawn tests symmetric with run_qemu() which also exits with 1 if
QEMU is not available.

test/TEST-01-BASIC/test.sh
test/TEST-03-JOBS/test.sh
test/TEST-04-JOURNAL/test.sh
test/TEST-05-RLIMITS/test.sh
test/TEST-07-ISSUE-1981/test.sh
test/TEST-12-ISSUE-3171/test.sh
test/test-functions

index 21eed9b22acf3a21809097d980a2258fdbdffa0b..041195dcd8dc79794100ab053f4f52d02a41dbe9 100755 (executable)
@@ -25,8 +25,7 @@ test_run() {
     else
         dwarn "can't run QEMU, skipping"
     fi
-    if check_nspawn; then
-        run_nspawn
+    if run_nspawn; then
         check_result_nspawn || return 1
     else
         dwarn "can't run systemd-nspawn, skipping"
index 83393435f0a48126443cd0f11d28281f8569c6f5..ab0de0bfd14fc9060b5782a06c9ec72b20160a15 100755 (executable)
@@ -25,8 +25,7 @@ test_run() {
     else
         dwarn "can't run QEMU, skipping"
     fi
-    if check_nspawn; then
-        run_nspawn
+    if run_nspawn; then
         check_result_nspawn || return 1
     else
         dwarn "can't run systemd-nspawn, skipping"
index 1a14f76060d268ec65dc503b81f7f45cfb7687b1..3ccf1130190f0033d6cd0d4f222ca1d70a3a2608 100755 (executable)
@@ -25,8 +25,7 @@ test_run() {
     else
         dwarn "can't run QEMU, skipping"
     fi
-    if check_nspawn; then
-        run_nspawn
+    if run_nspawn; then
         check_result_nspawn || return 1
     else
         dwarn "can't run systemd-nspawn, skipping"
index 6eaa0b8f34c5d05d18f1d84250a16f44ee02eca4..a5f7e8de0bba5443bc8a369e915c2ac063cf945c 100755 (executable)
@@ -25,8 +25,7 @@ test_run() {
     else
         dwarn "can't run QEMU, skipping"
     fi
-    if check_nspawn; then
-        run_nspawn
+    if run_nspawn; then
         check_result_nspawn || return 1
     else
         dwarn "can't run systemd-nspawn, skipping"
index d97c4ec27d8eafc276ae08edb47a5f8ceaf64a0f..2f7f01058eeb0b447cba8c3d0fa8e46d494ab5b2 100755 (executable)
@@ -5,11 +5,11 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
 
 . $TEST_BASE_DIR/test-functions
 
+NSPAWN_TIMEOUT=30s
+
 test_run() {
     dwarn "skipping QEMU"
-    if check_nspawn; then
-        NSPAWN_TIMEOUT=30s
-        run_nspawn
+    if run_nspawn; then
         check_result_nspawn || return 1
     else
         dwarn "can't run systemd-nspawn, skipping"
index d0e934898c60ace629744e8eac46705397c627e7..e20f47014396257f4e99cebb8f9a2488f8267a7c 100755 (executable)
@@ -6,8 +6,7 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171"
 . $TEST_BASE_DIR/test-functions
 
 test_run() {
-    if check_nspawn; then
-        run_nspawn
+    if run_nspawn; then
         check_result_nspawn || return 1
     else
         dwarn "can't run systemd-nspawn, skipping"
index d8b7109671e726e0d513b95ce72286e4f460df00..4583c02f972b1458d660d2b59e15c133b537b705 100644 (file)
@@ -108,7 +108,11 @@ $KERNEL_APPEND \
     return 0
 }
 
+# Return 0 if nspawn did run (then you must check the result state/logs for actual
+# success), or 1 if nspawn is not available.
 run_nspawn() {
+    [[ -d /run/systemd/system ]] || return 1
+
     local _nspawn_cmd="../../systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND"
     if [[ "$NSPAWN_TIMEOUT" != "infinity" ]]; then
         _nspawn_cmd="timeout --foreground $NSPAWN_TIMEOUT $_nspawn_cmd"
@@ -1284,11 +1288,6 @@ inst_libdir_file() {
     fi
 }
 
-check_nspawn() {
-    [[ -d /run/systemd/system ]]
-}
-
-
 do_test() {
     if [[ $UID != "0" ]]; then
         echo "TEST: $TEST_DESCRIPTION [SKIPPED]: not root" >&2