Harald Hoyer 9d5d75
From 82fe4ea0a5a745c920aa396775b9ebb52b4d2927 Mon Sep 17 00:00:00 2001
Harald Hoyer 9d5d75
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 9d5d75
Date: Tue, 14 Aug 2018 11:04:17 +0200
Harald Hoyer 9d5d75
Subject: [PATCH] enable parallel test suite
Harald Hoyer 9d5d75
Harald Hoyer 9d5d75
$ time sudo make -j SKIP=14 V=2 check
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-13-ENC-RAID-LVM'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-40-NBD'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-04-FULL-SYSTEMD'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-12-RAID-DEG'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-15-BTRFSRAID'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-16-DMSQUASH'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-17-LVM-THIN'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-11-LVM'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-31-ISCSI-MULTI'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-20-NFS'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-99-RPM'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-02-SYSTEMD'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-30-ISCSI'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-01-BASIC'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-03-USR-MOUNT'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-70-BONDBRIDGETEAMVLAN'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-50-MULTINIC'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-10-RAID'
Harald Hoyer 9d5d75
make[1]: Entering directory '/home/harald/git/dracut/test/TEST-18-LVM-ENC-LV'
Harald Hoyer 9d5d75
TEST: root filesystem on an encrypted LVM PV on a degraded RAID-5 [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on NBD [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on NBD [SKIPPED]
Harald Hoyer 9d5d75
TEST: Full systemd serialization/deserialization test with /usr mount [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on multiple device btrfs [STARTED]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-40-NBD'
Harald Hoyer 9d5d75
TEST: root filesystem on a LiveCD dmsquash filesystem [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on a LiveCD dmsquash filesystem [SKIPPED]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-16-DMSQUASH'
Harald Hoyer 9d5d75
TEST: root filesystem on LVM on encrypted partitions of a RAID-5 [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on LVM PV [STARTED]
Harald Hoyer 9d5d75
TEST: rpm integrity after dracut and kernel install [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on NFS [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem over iSCSI [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on LVM PV with thin pool [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem over iSCSI [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on a ext3 filesystem [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on a ext3 filesystem [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on a btrfs filesystem with /usr subvolume [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on NFS with bridging/bonding/vlan [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on NFS with multiple nics [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on an encrypted LVM PV on a RAID-5 [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on LVM on encrypted partitions of a RAID-5 [STARTED]
Harald Hoyer 9d5d75
TEST: root filesystem on LVM PV [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-11-LVM'
Harald Hoyer 9d5d75
TEST: root filesystem on multiple device btrfs [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-15-BTRFSRAID'
Harald Hoyer 9d5d75
TEST: root filesystem on LVM PV with thin pool [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-17-LVM-THIN'
Harald Hoyer 9d5d75
TEST: root filesystem on a ext3 filesystem [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-02-SYSTEMD'
Harald Hoyer 9d5d75
TEST: root filesystem on a btrfs filesystem with /usr subvolume [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-03-USR-MOUNT'
Harald Hoyer 9d5d75
TEST: root filesystem on LVM on encrypted partitions of a RAID-5 [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-18-LVM-ENC-LV'
Harald Hoyer 9d5d75
TEST: Full systemd serialization/deserialization test with /usr mount [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-04-FULL-SYSTEMD'
Harald Hoyer 9d5d75
TEST: root filesystem on an encrypted LVM PV on a RAID-5 [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-10-RAID'
Harald Hoyer 9d5d75
TEST: root filesystem on LVM on encrypted partitions of a RAID-5 [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-13-ENC-RAID-LVM'
Harald Hoyer 9d5d75
TEST: root filesystem over iSCSI [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-30-ISCSI'
Harald Hoyer 9d5d75
TEST: root filesystem on a ext3 filesystem [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-01-BASIC'
Harald Hoyer 9d5d75
TEST: root filesystem over iSCSI [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-31-ISCSI-MULTI'
Harald Hoyer 9d5d75
TEST: rpm integrity after dracut and kernel install [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-99-RPM'
Harald Hoyer 9d5d75
TEST: root filesystem on NFS [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-20-NFS'
Harald Hoyer 9d5d75
TEST: root filesystem on NFS with bridging/bonding/vlan [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-70-BONDBRIDGETEAMVLAN'
Harald Hoyer 9d5d75
TEST: root filesystem on an encrypted LVM PV on a degraded RAID-5 [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-12-RAID-DEG'
Harald Hoyer 9d5d75
TEST: root filesystem on NFS with multiple nics [OK]
Harald Hoyer 9d5d75
make[1]: Leaving directory '/home/harald/git/dracut/test/TEST-50-MULTINIC'
Harald Hoyer 9d5d75
Harald Hoyer 9d5d75
real	9m3,969s
Harald Hoyer 9d5d75
user	22m50,323s
Harald Hoyer 9d5d75
sys	5m24,411s
Harald Hoyer 9d5d75
---
Harald Hoyer 9d5d75
 test/Makefile       | 21 +++++++++--------
Harald Hoyer 9d5d75
 test/test-functions | 68 ++++++++++++++++++++++++++++-------------------------
Harald Hoyer 9d5d75
 2 files changed, 47 insertions(+), 42 deletions(-)
Harald Hoyer 9d5d75
Harald Hoyer 9d5d75
diff --git a/test/Makefile b/test/Makefile
Harald Hoyer 9d5d75
index eaa944fb..0b33660b 100644
Harald Hoyer 9d5d75
--- a/test/Makefile
Harald Hoyer 9d5d75
+++ b/test/Makefile
Harald Hoyer 9d5d75
@@ -1,15 +1,16 @@
Harald Hoyer 9d5d75
-.PHONY: all check clean
Harald Hoyer 9d5d75
+.PHONY: all check clean $(wildcard TEST-??-*)
Harald Hoyer 9d5d75
 
Harald Hoyer 9d5d75
-check:
Harald Hoyer 9d5d75
+$(wildcard TEST-??-*):
Harald Hoyer 9d5d75
 	@[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
Harald Hoyer 9d5d75
-	@{ ret=0; \
Harald Hoyer 9d5d75
-	for i in TEST-[0-9]*; do \
Harald Hoyer 9d5d75
-		[ -d $$i ] || continue ; \
Harald Hoyer 9d5d75
-		[ -f $$i/Makefile ] || continue ; \
Harald Hoyer 9d5d75
-		if [ -n "$$TESTS" ]; then t=$${i##TEST-}; t=$${t%%-*}; [ "$${TESTS#*$$t*}" != "$$TESTS" ] || continue; fi; \
Harald Hoyer 9d5d75
-		if [ -n "$$SKIP" ]; then t=$${i##TEST-}; t=$${t%%-*}; [ "$${SKIP#*$$t*}" != "$$SKIP" ] && continue; fi; \
Harald Hoyer 9d5d75
-		$(MAKE) -C $$i all ; ret=$$((ret + $$?)); \
Harald Hoyer 9d5d75
-	done; exit $$ret; }
Harald Hoyer 9d5d75
+	@{ \
Harald Hoyer 9d5d75
+		[ -d $@ ] || exit 0; \
Harald Hoyer 9d5d75
+		[ -f $@/Makefile ] || exit 0; \
Harald Hoyer 9d5d75
+		if [ -n "$$TESTS" ]; then t=$${$@##TEST-}; t=$${t%%-*}; [ "$${TESTS#*$$t*}" != "$$TESTS" ] || exit 0; fi; \
Harald Hoyer 9d5d75
+		if [ -n "$$SKIP" ]; then t=$${$@##TEST-}; t=$${t%%-*}; [ "$${SKIP#*$$t*}" != "$$SKIP" ] && exit 0; fi; \
Harald Hoyer 9d5d75
+		$(MAKE) -C $@ all ; \
Harald Hoyer 9d5d75
+	}
Harald Hoyer 9d5d75
+
Harald Hoyer 9d5d75
+check: $(wildcard TEST-??-*)
Harald Hoyer 9d5d75
 
Harald Hoyer 9d5d75
 clean:
Harald Hoyer 9d5d75
 	@for i in TEST-[0-9]*; do \
Harald Hoyer 9d5d75
diff --git a/test/test-functions b/test/test-functions
Harald Hoyer 9d5d75
index 2b8a4d26..57611ff5 100644
Harald Hoyer 9d5d75
--- a/test/test-functions
Harald Hoyer 9d5d75
+++ b/test/test-functions
Harald Hoyer 9d5d75
@@ -4,14 +4,14 @@ export PATH
Harald Hoyer 9d5d75
 
Harald Hoyer 9d5d75
 [[ -e .testdir ]] && . .testdir
Harald Hoyer 9d5d75
 if [[ -z "$TESTDIR" ]] || [[ ! -d "$TESTDIR" ]]; then
Harald Hoyer 9d5d75
-   TESTDIR=$(mktemp -d -p "/var/tmp" -t dracut-test.XXXXXX)
Harald Hoyer 9d5d75
+    TESTDIR=$(mktemp -d -p "/var/tmp" -t dracut-test.XXXXXX)
Harald Hoyer 9d5d75
 fi
Harald Hoyer 9d5d75
 echo "TESTDIR=\"$TESTDIR\"" > .testdir
Harald Hoyer 9d5d75
 export TESTDIR
Harald Hoyer 9d5d75
 
Harald Hoyer 9d5d75
 command -v test_check &>/dev/null || test_check() {
Harald Hoyer 9d5d75
-    :
Harald Hoyer 9d5d75
-}
Harald Hoyer 9d5d75
+        :
Harald Hoyer 9d5d75
+    }
Harald Hoyer 9d5d75
 
Harald Hoyer 9d5d75
 # terminal sequence to set color to a 'success' color (currently: green)
Harald Hoyer 9d5d75
 function SETCOLOR_SUCCESS() { echo -en '\033[0;32m'; }
Harald Hoyer 9d5d75
@@ -22,6 +22,11 @@ function SETCOLOR_WARNING() { echo -en '\033[0;33m'; }
Harald Hoyer 9d5d75
 # terminal sequence to reset to the default color.
Harald Hoyer 9d5d75
 function SETCOLOR_NORMAL() { echo -en '\033[0;39m'; }
Harald Hoyer 9d5d75
 
Harald Hoyer 9d5d75
+COLOR_SUCCESS='\033[0;32m'
Harald Hoyer 9d5d75
+COLOR_FAILURE='\033[0;31m'
Harald Hoyer 9d5d75
+COLOR_WARNING='\033[0;33m'
Harald Hoyer 9d5d75
+COLOR_NORMAL='\033[0;39m'
Harald Hoyer 9d5d75
+
Harald Hoyer 9d5d75
 check_root() {
Harald Hoyer 9d5d75
     if (( $EUID != 0 )); then
Harald Hoyer 9d5d75
         SETCOLOR_FAILURE; echo "Tests must be run as root! Please use 'sudo'."; SETCOLOR_NORMAL
Harald Hoyer 9d5d75
@@ -49,45 +54,44 @@ while (($# > 0)); do
Harald Hoyer 9d5d75
 	    exit $?;;
Harald Hoyer 9d5d75
         --all)
Harald Hoyer 9d5d75
             check_root
Harald Hoyer 9d5d75
-	    echo -n "TEST: $TEST_DESCRIPTION ";
Harald Hoyer 9d5d75
             if ! test_check 2&>test.log ; then
Harald Hoyer 9d5d75
-                SETCOLOR_WARNING
Harald Hoyer 9d5d75
-                echo "[SKIPPED]"
Harald Hoyer 9d5d75
-                SETCOLOR_NORMAL
Harald Hoyer 9d5d75
+ 	        echo -e "TEST: $TEST_DESCRIPTION " $COLOR_WARNING "[SKIPPED]" $COLOR_NORMAL
Harald Hoyer 9d5d75
 		exit 0;
Harald Hoyer 9d5d75
+            else
Harald Hoyer 9d5d75
+	        echo "TEST: $TEST_DESCRIPTION [STARTED]";
Harald Hoyer 9d5d75
             fi
Harald Hoyer 9d5d75
             if [ "$V" != "1" ]; then
Harald Hoyer 9d5d75
-	    (
Harald Hoyer 9d5d75
-		test_setup && test_run
Harald Hoyer 9d5d75
-		ret=$?
Harald Hoyer 9d5d75
-		test_cleanup
Harald Hoyer 9d5d75
-		rm -fr -- "$TESTDIR"
Harald Hoyer 9d5d75
-		rm -f -- .testdir
Harald Hoyer 9d5d75
-		exit $ret
Harald Hoyer 9d5d75
-	    ) </dev/null >test.log 2>&1
Harald Hoyer 9d5d75
+	        (
Harald Hoyer 9d5d75
+		    test_setup && test_run
Harald Hoyer 9d5d75
+		    ret=$?
Harald Hoyer 9d5d75
+		    test_cleanup
Harald Hoyer 9d5d75
+		    rm -fr -- "$TESTDIR"
Harald Hoyer 9d5d75
+		    rm -f -- .testdir
Harald Hoyer 9d5d75
+		    exit $ret
Harald Hoyer 9d5d75
+	        ) </dev/null >test.log 2>&1
Harald Hoyer 9d5d75
             else
Harald Hoyer 9d5d75
-            set -o pipefail
Harald Hoyer 9d5d75
-            (
Harald Hoyer 9d5d75
-		test_setup && test_run
Harald Hoyer 9d5d75
-		ret=$?
Harald Hoyer 9d5d75
-		test_cleanup
Harald Hoyer 9d5d75
-		rm -fr -- "$TESTDIR"
Harald Hoyer 9d5d75
-		rm -f -- .testdir
Harald Hoyer 9d5d75
-		exit $ret
Harald Hoyer 9d5d75
-	    ) </dev/null 2>&1 | tee test.log
Harald Hoyer 9d5d75
+                set -o pipefail
Harald Hoyer 9d5d75
+                (
Harald Hoyer 9d5d75
+		    test_setup && test_run
Harald Hoyer 9d5d75
+		    ret=$?
Harald Hoyer 9d5d75
+		    test_cleanup
Harald Hoyer 9d5d75
+		    rm -fr -- "$TESTDIR"
Harald Hoyer 9d5d75
+		    rm -f -- .testdir
Harald Hoyer 9d5d75
+		    exit $ret
Harald Hoyer 9d5d75
+	        ) </dev/null 2>&1 | tee test.log
Harald Hoyer 9d5d75
             fi
Harald Hoyer 9d5d75
 	    ret=$?
Harald Hoyer 9d5d75
             set +o pipefail
Harald Hoyer 9d5d75
 	    if [ $ret -eq 0 ]; then
Harald Hoyer 9d5d75
-               rm -- test.log
Harald Hoyer 9d5d75
-               SETCOLOR_SUCCESS
Harald Hoyer 9d5d75
-	       echo "[OK]"
Harald Hoyer 9d5d75
-               SETCOLOR_NORMAL
Harald Hoyer 9d5d75
+                rm -- test.log
Harald Hoyer 9d5d75
+	        echo -e "TEST: $TEST_DESCRIPTION " $COLOR_SUCCESS "[OK]" $COLOR_NORMAL
Harald Hoyer 9d5d75
 	    else
Harald Hoyer 9d5d75
-               SETCOLOR_FAILURE
Harald Hoyer 9d5d75
-	       echo "[FAILED]"
Harald Hoyer 9d5d75
-               SETCOLOR_NORMAL
Harald Hoyer 9d5d75
-	       echo "see $(pwd)/test.log"
Harald Hoyer 9d5d75
+	        echo -e "TEST: $TEST_DESCRIPTION " $COLOR_FAILURE "[FAILED]" $COLOR_NORMAL
Harald Hoyer 9d5d75
+                if [ "$V" == "2" ]; then
Harald Hoyer 9d5d75
+	            cat $(pwd)/test.log
Harald Hoyer 9d5d75
+                else
Harald Hoyer 9d5d75
+	            echo "see $(pwd)/test.log"
Harald Hoyer 9d5d75
+                fi
Harald Hoyer 9d5d75
 	    fi
Harald Hoyer 9d5d75
 	    exit $ret;;
Harald Hoyer 9d5d75
         *) break ;;
Harald Hoyer 9d5d75