[Libguestfs] [PATCH 2/2] build: Drop serial_tests.

Richard W.M. Jones rjones at redhat.com
Thu Nov 5 13:03:34 UTC 2015


Use (implicitly) parallel tests on new enough automake.  The tests run
a bit quicker with this change.  On my laptop, I measured 27 mins down
to 18 mins.

Change the ./run function so that ./run --test no longer spools the
test output to a file.  That is not necessary when using parallel
tests, since the test harness does the same thing.

Fix a few tests that either shouldn't be run in parallel, or weren't
using uniquely named test files and so would break when tests were run
in parallel.

Note: This commit breaks the $RUN_OUTPUT_FILE functionality.
---
 .gitignore                        |  4 ++--
 builder/test-virt-builder.sh      |  8 ++++----
 configure.ac                      | 19 ++-----------------
 fish/test-events.sh               | 10 +++++-----
 fish/test-file-attrs.sh           | 10 +++++-----
 fish/test-find0.sh                | 10 +++++-----
 fish/test-read-file.sh            |  8 ++++----
 run.in                            | 34 +++++++++++++---------------------
 tests/btrfs/test-btrfs-replace.sh |  8 ++++----
 tests/qemu/Makefile.am            |  4 ++++
 tests/regressions/rhbz563450.sh   | 10 +++++-----
 tests/regressions/rhbz563450b.sh  | 10 +++++-----
 tests/regressions/rhbz789960.sh   | 10 +++++-----
 v2v/test-v2v-oa-option.sh         |  2 +-
 v2v/test-v2v-of-option.sh         |  2 +-
 v2v/test-v2v-on-option.sh         |  2 +-
 16 files changed, 66 insertions(+), 85 deletions(-)

diff --git a/.gitignore b/.gitignore
index 091a943..8091608 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,11 +14,13 @@
 *.jar
 *.la
 *.lo
+*.log
 *.o
 *.orig
 *.patch
 *.rej
 *.swp
+*.trs
 
 bindtests.tmp
 cscope.out
@@ -462,8 +464,6 @@ Makefile.in
 /sysprep/sysprep-operations.pod
 /sysprep/virt-sysprep
 /sysprep/virt-sysprep.1
-/test.err
-/test.out
 /tests/c-api/test-add-drive-opts
 /tests/c-api/test-add-libvirt-dom
 /tests/c-api/test-backend-settings
diff --git a/builder/test-virt-builder.sh b/builder/test-virt-builder.sh
index f357d12..2a9227b 100755
--- a/builder/test-virt-builder.sh
+++ b/builder/test-virt-builder.sh
@@ -74,7 +74,7 @@ $VG virt-builder phony-fedora \
     --firstboot-install "minicom,inkscape"
 
 # Check that some modifications were made.
-$VG guestfish --ro -i -a $output > test.out <<EOF
+$VG guestfish --ro -i -a $output > test-virt-builder.out <<EOF
 # Uploaded files
 is-file /etc/foo/bar/baz/Makefile
 cat /etc/foo/bar/baz/foo
@@ -99,7 +99,7 @@ is-file /etc/shadow
 cat /etc/shadow | sed -r '/^root:/!d;s,^(root:\\\$6\\\$).*,\\1,g'
 EOF
 
-if [ "$(cat test.out)" != "true
+if [ "$(cat test-virt-builder.out)" != "true
 Hello World
 true
 true
@@ -115,9 +115,9 @@ true
 true
 root:\$6\$" ]; then
     echo "$0: unexpected output:"
-    cat test.out
+    cat test-virt-builder.out
     exit 1
 fi
 
 rm $output
-rm test.out
+rm test-virt-builder.out
diff --git a/configure.ac b/configure.ac
index 88f5568..bd3e5e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,23 +30,8 @@ AC_SUBST([RELEASE_DATE], [2015-11-04])
 
 AC_CONFIG_AUX_DIR([build-aux])
 
-dnl Initialize automake.  automake < 1.12 didn't have serial-tests and
-dnl gives an error if it sees this, but for automake >= 1.13
-dnl serial-tests is required so we have to include it.  Solution is to
-dnl test for the version of automake (by running an external command)
-dnl and provide it if necessary.  Note we have to do this entirely using
-dnl m4 macros since automake queries this macro by running
-dnl 'autoconf --trace'.
-m4_define([serial_tests], [
-    m4_esyscmd([automake --version | head -1 | awk '
-                     {
-                       split ($NF, version, ".");
-                       if (version[1] == 1 && version[2] >= 12)
-                         print "serial-tests";
-                     }'
-    ])
-])
-AM_INIT_AUTOMAKE(foreign serial_tests subdir-objects) dnl NB: Do not [quote] this parameter.
+dnl Initialize automake.
+AM_INIT_AUTOMAKE(foreign subdir-objects) dnl NB: Do not [quote] this parameter.
 
 m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
diff --git a/fish/test-events.sh b/fish/test-events.sh
index 3f65164..7d4cd82 100755
--- a/fish/test-events.sh
+++ b/fish/test-events.sh
@@ -20,9 +20,9 @@
 
 set -e
 
-rm -f test.out
+rm -f test-events.out
 
-$VG guestfish -a /dev/null <<'EOF' | grep -v get_verbose | grep -v get_trace | grep -v 'library .*0x' | grep -v 'library command' | grep -v 'get_path' > test.out
+$VG guestfish -a /dev/null <<'EOF' | grep -v get_verbose | grep -v get_trace | grep -v 'library .*0x' | grep -v 'library command' | grep -v 'get_path' > test-events.out
 trace true
 
 event ev1 * "echo $EVENT $@"
@@ -49,7 +49,7 @@ list-events
 
 EOF
 
-if [ "$(cat test.out)" != '"ev1" (0): *: echo $EVENT $@
+if [ "$(cat test-events.out)" != '"ev1" (0): *: echo $EVENT $@
 "ev1" (1): *: echo $EVENT $@
 "ev2" (2): *: echo $EVENT $@
 "ev2" (2): *: echo $EVENT $@
@@ -75,8 +75,8 @@ close
 "ev2" (1): close,subprocess_quit: echo $EVENT $@
 close' ]; then
     echo "$0: unexpected output from guestfish events"
-    cat test.out
+    cat test-events.out
     exit 1
 fi
 
-rm test.out
+rm test-events.out
diff --git a/fish/test-file-attrs.sh b/fish/test-file-attrs.sh
index 55d602c..7f34348 100755
--- a/fish/test-file-attrs.sh
+++ b/fish/test-file-attrs.sh
@@ -21,9 +21,9 @@
 set -e
 export LANG=C
 
-rm -f test.out
+rm -f test-file-attrs.out
 
-$VG guestfish > test.out <<EOF
+$VG guestfish > test-file-attrs.out <<EOF
 scratch 50MB
 run
 part-disk /dev/sda mbr
@@ -72,7 +72,7 @@ copy-attributes /foo /new mode:true
 stat /new | grep mode:
 EOF
 
-if [ "$(cat test.out)" != "mode: 33226
+if [ "$(cat test-file-attrs.out)" != "mode: 33226
 mode: 33226
 -----
 uid: 0
@@ -150,8 +150,8 @@ gid: 11
 }
 mode: 33226" ]; then
     echo "$0: unexpected output:"
-    cat test.out
+    cat test-file-attrs.out
     exit 1
 fi
 
-rm test.out
+rm test-file-attrs.out
diff --git a/fish/test-find0.sh b/fish/test-find0.sh
index 042e4ef..f327761 100755
--- a/fish/test-find0.sh
+++ b/fish/test-find0.sh
@@ -20,20 +20,20 @@
 
 set -e
 
-rm -f test.out
+rm -f test-find0.out
 
 $VG guestfish <<'EOF'
 add-ro ../test-data/test.iso
 run
 mount-ro /dev/sda /
-find0 / test.out
+find0 / test-find0.out
 EOF
 
-n=$(tr '\0' '\n' < test.out | grep '^known-[1-5]' | wc -l)
+n=$(tr '\0' '\n' < test-find0.out | grep '^known-[1-5]' | wc -l)
 [ "$n" = 5 ] || {
   echo find0: Invalid list of files
-  tr '\0' '\n' < test.out
+  tr '\0' '\n' < test-find0.out
   exit 1
 }
 
-rm -f test.out
+rm -f test-find0.out
diff --git a/fish/test-read-file.sh b/fish/test-read-file.sh
index 7819041..b83faa9 100755
--- a/fish/test-read-file.sh
+++ b/fish/test-read-file.sh
@@ -20,15 +20,15 @@
 
 set -e
 
-rm -f test.out
+rm -f test-read-file.out
 
-$VG guestfish <<'EOF' > test.out
+$VG guestfish <<'EOF' > test-read-file.out
 add-ro ../test-data/test.iso
 run
 mount-ro /dev/sda /
 read-file /helloworld.tar
 EOF
 
-cmp $srcdir/../test-data/files/helloworld.tar test.out
+cmp $srcdir/../test-data/files/helloworld.tar test-read-file.out
 
-rm -f test.out
+rm -f test-read-file.out
diff --git a/run.in b/run.in
index 46dbaf0..d59da7f 100755
--- a/run.in
+++ b/run.in
@@ -31,15 +31,20 @@
 # For lots more ways to use this script, see the libguestfs README
 # file.
 #
-# The script can also be used to make the output of tests shorter:
+# The script should also be used for tests like this:
+#
 #   TESTS_ENVIRONMENT = ... $(top_builddir)/run --test [$(VG)]
-# (Use the optional $(VG) when the tests must also be run under
-# valgrind).
+#
+# The --test parameter introduces a timeout, stopping tests from
+# running forever.
+#
+# Use the optional $(VG) when the tests must also be run under
+# valgrind.
 
 #----------------------------------------------------------------------
 
 if [ "$1" = "--test" ]; then
-    test_mode=1
+    timeout_mode=1
     shift
 fi
 
@@ -223,14 +228,11 @@ export GNOME_KEYRING_CONTROL=
 export GNOME_KEYRING_PID=
 
 # Run the program.
-if [ -z "$test_mode" ]; then
+if [ -z "$timeout_mode" ]; then
     exec $libtool "$@"
 fi
 
 # For tests (./run --test):
-#  - redirect all output to a file, and only print the file if the
-#    test fails
-#  - print how long it takes to run the test
 #  - timeout if the test takes too long to run
 
 # Originally 1h, but that is not long enough to run the C API
@@ -246,28 +248,19 @@ if timeout --foreground 2 sleep 0 >/dev/null 2>&1; then
     fi
 fi
 
-pid=$$
-tmpout=$b/tmp/run-$pid
-rm -f $tmpout
-start_t="$(date +'%s')"
-$timeout $libtool "$@" > $tmpout 2>&1
+$timeout $libtool "$@"
 fail=$?
-end_t="$(date +'%s')"
 if [ "$fail" -eq 0 ]; then
     # Test successful.
-    echo $(($end_t - $start_t)) seconds: "$@"
+    :
 elif [ "$fail" -eq 77 ]; then
     # Tests return 77 to mean skipped.
-    cat $tmpout
+    :
 elif [ "$fail" -eq 124 ]; then
     # Timed out.
-    echo "$b/run --test" "$@"
-    cat $tmpout
     echo "$b/run: command timed out after $timeout_period"
 else
     # Test failed.
-    echo "$b/run --test" "$@"
-    cat $tmpout
     echo "$b/run: command failed with exit code $fail"
 fi
 if [ -n "$RUN_OUTPUT_FILE" ]; then
@@ -282,5 +275,4 @@ if [ -n "$RUN_OUTPUT_FILE" ]; then
     echo "]]>" >> $RUN_OUTPUT_FILE
     echo "</test>" >> $RUN_OUTPUT_FILE
 fi
-rm -f $tmpout
 exit $fail
diff --git a/tests/btrfs/test-btrfs-replace.sh b/tests/btrfs/test-btrfs-replace.sh
index b0f4a1e..77aeb46 100755
--- a/tests/btrfs/test-btrfs-replace.sh
+++ b/tests/btrfs/test-btrfs-replace.sh
@@ -32,12 +32,12 @@ if ! guestfish -a /dev/null run : available btrfs; then
     exit 77
 fi
 
-rm -f test-btrfs-devices-{1,2}.img replace.output
+rm -f test-btrfs-replace-{1,2}.img replace.output
 
 guestfish  <<EOF > replace.output
 # Add 2 empty disks
-sparse test-btrfs-devices-1.img 1G
-sparse test-btrfs-devices-2.img 1G
+sparse test-btrfs-replace-1.img 1G
+sparse test-btrfs-replace-2.img 1G
 run
 
 mkfs-btrfs /dev/sda
@@ -63,4 +63,4 @@ filesanddirs-10M.tar.xz" ]; then
     exit 1
 fi
 
-rm test-btrfs-devices-{1,2}.img replace.output
+rm test-btrfs-replace-{1,2}.img replace.output
diff --git a/tests/qemu/Makefile.am b/tests/qemu/Makefile.am
index 478b3f1..6c72b18 100644
--- a/tests/qemu/Makefile.am
+++ b/tests/qemu/Makefile.am
@@ -75,3 +75,7 @@ qemu_speed_test_LDADD = \
 	$(LIBVIRT_LIBS) \
 	$(LTLIBINTL) \
 	$(top_builddir)/gnulib/lib/libgnu.la
+
+# Don't run these tests in parallel, since they are designed to check
+# the integrity of qemu.
+.NOTPARALLEL:
diff --git a/tests/regressions/rhbz563450.sh b/tests/regressions/rhbz563450.sh
index 90397a2..5215676 100755
--- a/tests/regressions/rhbz563450.sh
+++ b/tests/regressions/rhbz563450.sh
@@ -27,9 +27,9 @@ if [ ! -s ../../test-data/phony-guests/fedora.img -o ! -s ../../test-data/test.i
     exit 77
 fi
 
-rm -f test.out
+rm -f rhbz563450.out
 
-guestfish --ro > test.out <<EOF
+guestfish --ro > rhbz563450.out <<EOF
 add-drive-ro ../../test-data/phony-guests/fedora.img
 add-cdrom ../../test-data/test.iso
 add-drive-ro ../../test-data/phony-guests/debian.img
@@ -43,7 +43,7 @@ list-partitions | sed -r 's,^/dev/[abce-ln-z]+d,/dev/sd,'
 ping-daemon
 EOF
 
-if [ "$(cat test.out)" != "/dev/sda
+if [ "$(cat rhbz563450.out)" != "/dev/sda
 /dev/sdb
 /dev/sdc
 ----
@@ -52,8 +52,8 @@ if [ "$(cat test.out)" != "/dev/sda
 /dev/sdc1
 /dev/sdc2" ]; then
     echo "$0: unexpected output:"
-    cat test.out
+    cat rhbz563450.out
     exit 1
 fi
 
-rm -f test.out
+rm -f rhbz563450.out
diff --git a/tests/regressions/rhbz563450b.sh b/tests/regressions/rhbz563450b.sh
index f17b8f3..30f07b0 100755
--- a/tests/regressions/rhbz563450b.sh
+++ b/tests/regressions/rhbz563450b.sh
@@ -27,9 +27,9 @@ if [ ! -s ../../test-data/test.iso ]; then
     exit 77
 fi
 
-rm -f test.out
+rm -f rhbz563450b.out
 
-guestfish --ro > test.out <<EOF
+guestfish --ro > rhbz563450b.out <<EOF
 add-cdrom ../../test-data/test.iso
 
 run
@@ -39,10 +39,10 @@ list-devices | sed -r 's,^/dev/[abce-ln-z]+d,/dev/sd,'
 ping-daemon
 EOF
 
-if [ "$(cat test.out)" != "/dev/sda" ]; then
+if [ "$(cat rhbz563450b.out)" != "/dev/sda" ]; then
     echo "$0: unexpected output:"
-    cat test.out
+    cat rhbz563450b.out
     exit 1
 fi
 
-rm -f test.out
+rm -f rhbz563450b.out
diff --git a/tests/regressions/rhbz789960.sh b/tests/regressions/rhbz789960.sh
index adfb10a..57c04c3 100755
--- a/tests/regressions/rhbz789960.sh
+++ b/tests/regressions/rhbz789960.sh
@@ -22,9 +22,9 @@
 set -e
 export LANG=C
 
-rm -f test.out
+rm -f rhbz789960.out
 
-guestfish -a ../../test-data/phony-guests/fedora.img --ro > test.out <<EOF
+guestfish -a ../../test-data/phony-guests/fedora.img --ro > rhbz789960.out <<EOF
 run
 
 # Not a device at all, should fail.
@@ -59,10 +59,10 @@ echo done
 
 EOF
 
-if [ "$(cat test.out)" != "done" ]; then
+if [ "$(cat rhbz789960.out)" != "done" ]; then
     echo "$0: unexpected output:"
-    cat test.out
+    cat rhbz789960.out
     exit 1
 fi
 
-rm -f test.out
+rm -f rhbz789960.out
diff --git a/v2v/test-v2v-oa-option.sh b/v2v/test-v2v-oa-option.sh
index 5648f95..f3ffed8 100755
--- a/v2v/test-v2v-oa-option.sh
+++ b/v2v/test-v2v-oa-option.sh
@@ -43,7 +43,7 @@ fi
 
 export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools"
 
-d=test-v2v-windows-conversion.d
+d=test-v2v-oa-option.d
 rm -rf $d
 mkdir $d
 
diff --git a/v2v/test-v2v-of-option.sh b/v2v/test-v2v-of-option.sh
index a151c73..16e2fd0 100755
--- a/v2v/test-v2v-of-option.sh
+++ b/v2v/test-v2v-of-option.sh
@@ -43,7 +43,7 @@ fi
 
 export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools"
 
-d=test-v2v-windows-conversion.d
+d=test-v2v-of-option.d
 rm -rf $d
 mkdir $d
 
diff --git a/v2v/test-v2v-on-option.sh b/v2v/test-v2v-on-option.sh
index 5aaad2f..da55fe3 100755
--- a/v2v/test-v2v-on-option.sh
+++ b/v2v/test-v2v-on-option.sh
@@ -43,7 +43,7 @@ fi
 
 export VIRT_TOOLS_DATA_DIR="$PWD/fake-virt-tools"
 
-d=test-v2v-windows-conversion.d
+d=test-v2v-on-option.d
 rm -rf $d
 mkdir $d
 
-- 
2.5.0




More information about the Libguestfs mailing list