]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: move custom result checks from TEST-02-UNITTESTS to test-functions
authorLuca Boccassi <luca.boccassi@microsoft.com>
Mon, 21 Jun 2021 19:05:47 +0000 (20:05 +0100)
committerLuca Boccassi <luca.boccassi@microsoft.com>
Mon, 21 Jun 2021 19:45:56 +0000 (20:45 +0100)
test/TEST-02-UNITTESTS/test.sh
test/test-functions

index e4964cfca465aeb183046aebf211af888e2d1662..440d7b8b297bfb69c94b3b11ce8a1dc8f008f402 100755 (executable)
@@ -16,63 +16,11 @@ $KERNEL_APPEND
 . "${TEST_BASE_DIR:?}/test-functions"
 
 check_result_nspawn() {
-    local workspace="${1:?}"
-    local ret=1
-
-    [[ -e "$workspace/testok" ]] && ret=0
-
-    if [[ -s "$workspace/failed" ]]; then
-        ret=$((ret + 1))
-        echo "=== Failed test log ==="
-        cat "$workspace/failed"
-    else
-        if [[ -s "$workspace/skipped" ]]; then
-            echo "=== Skipped test log =="
-            cat "$workspace/skipped"
-            # We might have only skipped tests - that should not fail the job
-            ret=0
-        fi
-        if [[ -s "$workspace/testok" ]]; then
-            echo "=== Passed tests ==="
-            cat "$workspace/testok"
-        fi
-    fi
-
-    save_journal "$workspace/var/log/journal"
-    _umount_dir "${initdir:?}"
-
-    [[ -n "${TIMED_OUT:=}" ]] && ret=1
-    return $ret
+    check_result_nspawn_unittests "${1}"
 }
 
 check_result_qemu() {
-    local ret=1
-
-    mount_initdir
-    [[ -e "${initdir:?}/testok" ]] && ret=0
-
-    if [[ -s "$initdir/failed" ]]; then
-        ret=$((ret + 1))
-        echo "=== Failed test log ==="
-        cat "$initdir/failed"
-    else
-        if [[ -s "$initdir/skipped" ]]; then
-            echo "=== Skipped test log =="
-            cat "$initdir/skipped"
-            # We might have only skipped tests - that should not fail the job
-            ret=0
-        fi
-        if [[ -s "$initdir/testok" ]]; then
-            echo "=== Passed tests ==="
-            cat "$initdir/testok"
-        fi
-    fi
-
-    save_journal "$initdir/var/log/journal"
-    _umount_dir "$initdir"
-
-    [[ -n "${TIMED_OUT:=}" ]] && ret=1
-    return $ret
+    check_result_qemu_unittests
 }
 
 do_test "$@"
index 69921442bae187df4f8d9661e47354a176160114..7edb55251db5085368fbedc1c0a2907c5e08575a 100644 (file)
@@ -1229,6 +1229,66 @@ check_result_qemu() {
     return $ret
 }
 
+check_result_nspawn_unittests() {
+    local workspace="${1:?}"
+    local ret=1
+
+    [[ -e "$workspace/testok" ]] && ret=0
+
+    if [[ -s "$workspace/failed" ]]; then
+        ret=$((ret + 1))
+        echo "=== Failed test log ==="
+        cat "$workspace/failed"
+    else
+        if [[ -s "$workspace/skipped" ]]; then
+            echo "=== Skipped test log =="
+            cat "$workspace/skipped"
+            # We might have only skipped tests - that should not fail the job
+            ret=0
+        fi
+        if [[ -s "$workspace/testok" ]]; then
+            echo "=== Passed tests ==="
+            cat "$workspace/testok"
+        fi
+    fi
+
+    save_journal "$workspace/var/log/journal"
+    _umount_dir "${initdir:?}"
+
+    [[ -n "${TIMED_OUT:=}" ]] && ret=1
+    return $ret
+}
+
+check_result_qemu_unittests() {
+    local ret=1
+
+    mount_initdir
+    [[ -e "${initdir:?}/testok" ]] && ret=0
+
+    if [[ -s "$initdir/failed" ]]; then
+        ret=$((ret + 1))
+        echo "=== Failed test log ==="
+        cat "$initdir/failed"
+    else
+        if [[ -s "$initdir/skipped" ]]; then
+            echo "=== Skipped test log =="
+            cat "$initdir/skipped"
+            # We might have only skipped tests - that should not fail the job
+            ret=0
+        fi
+        if [[ -s "$initdir/testok" ]]; then
+            echo "=== Passed tests ==="
+            cat "$initdir/testok"
+        fi
+    fi
+
+    save_journal "$initdir/var/log/journal"
+    _umount_dir "$initdir"
+
+    [[ -n "${TIMED_OUT:=}" ]] && ret=1
+    return $ret
+}
+
 strip_binaries() {
     dinfo "Strip binaries"
     if [[ "$STRIP_BINARIES" = "no" ]]; then