Introduce regression tests for various qemu failures.
authorRichard Jones <rjones@trick.home.annexia.org>
Mon, 6 Jul 2009 12:10:25 +0000 (13:10 +0100)
committerRichard Jones <rjones@trick.home.annexia.org>
Mon, 6 Jul 2009 12:10:25 +0000 (13:10 +0100)
Test failure of qemu and recovery of the library:
 - mid-command
 - between commands
 - during launch [test not working yet]
 - explicitly killed by guestfs_kill_subprocess

Also this patch cleans up the other tests in this directory
and disables the long-winded test-bootbootboot test.

regressions/Makefile.am
regressions/rhbz503169c10.sh
regressions/rhbz503169c13.sh
regressions/test-bootbootboot.sh
regressions/test-qemudie-killsub.sh [new file with mode: 0755]
regressions/test-qemudie-launchfail.sh [moved from regressions/test-cleanup.sh with 79% similarity]
regressions/test-qemudie-midcommand.sh [new file with mode: 0755]
regressions/test-qemudie-synch.sh [new file with mode: 0755]

index 78ecfaa..874e898 100644 (file)
 TESTS = \
        rhbz503169c10.sh \
        rhbz503169c13.sh \
 TESTS = \
        rhbz503169c10.sh \
        rhbz503169c13.sh \
+       test-qemudie-midcommand.sh \
+       test-qemudie-killsub.sh \
+       test-qemudie-synch.sh
+
+SKIPPED_TESTS = \
        test-bootbootboot.sh
 
        test-bootbootboot.sh
 
+FAILING_TESTS = \
+       test-qemudie-launchfail.sh
+
+TESTS_ENVIRONMENT = \
+       LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
+       LIBGUESTFS_PATH=$(top_builddir)/appliance
+
 EXTRA_DIST = \
 EXTRA_DIST = \
-       test-cleanup.sh \
+       $(FAILING_TESTS) \
+       $(SKIPPED_TESTS) \
        $(TESTS)
        $(TESTS)
index 8cdad50..2cfdbca 100755 (executable)
@@ -24,8 +24,6 @@ set -e
 rm -f test1.img
 dd if=/dev/zero of=test1.img bs=1024k count=10
 
 rm -f test1.img
 dd if=/dev/zero of=test1.img bs=1024k count=10
 
-export LIBGUESTFS_PATH=../appliance
-
 ../fish/guestfish -a test1.img <<EOF
 launch
 ll /../dev/console
 ../fish/guestfish -a test1.img <<EOF
 launch
 ll /../dev/console
index 71e29ce..b6b4b94 100755 (executable)
@@ -29,8 +29,6 @@ set -e
 rm -f test1.img
 dd if=/dev/zero of=test1.img bs=1024k count=10
 
 rm -f test1.img
 dd if=/dev/zero of=test1.img bs=1024k count=10
 
-export LIBGUESTFS_PATH=../appliance
-
 ../fish/guestfish -a test1.img <<EOF
 run
 sfdisk /dev/sda 0 0 0 ,
 ../fish/guestfish -a test1.img <<EOF
 run
 sfdisk /dev/sda 0 0 0 ,
index 05ff6df..4586aff 100755 (executable)
@@ -30,7 +30,6 @@ n=10
 if [ -n "$1" ]; then n=$1; fi
 
 export LIBGUESTFS_DEBUG=1
 if [ -n "$1" ]; then n=$1; fi
 
 export LIBGUESTFS_DEBUG=1
-export LIBGUESTFS_PATH=../appliance
 
 for i in $(seq 1 $n); do
   echo Test boot $i of $n ...
 
 for i in $(seq 1 $n); do
   echo Test boot $i of $n ...
diff --git a/regressions/test-qemudie-killsub.sh b/regressions/test-qemudie-killsub.sh
new file mode 100755 (executable)
index 0000000..9848ebf
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh -
+# libguestfs
+# Copyright (C) 2009 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# Test if we can handle qemu death from the kill-subprocess command.
+
+set -e
+
+rm -f test.img
+
+../fish/guestfish <<'EOF'
+alloc test.img 10M
+run
+
+# Kill the subprocess.
+kill-subprocess
+
+# XXX The following sleep should NOT be necessary.
+echo "Expect an error from the next command"
+-sleep 1
+
+# We should now be able to rerun the subprocess.
+run
+ping-daemon
+EOF
+
+rm -f test.img
similarity index 79%
rename from regressions/test-cleanup.sh
rename to regressions/test-qemudie-launchfail.sh
index a68f57e..7da1c35 100755 (executable)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-# XXX Unfortunately we can't enable this by default since it
-# requires './configure --enable-debug-command'
+# Test if we can handle qemu failure during launch.
 
 
-./fish/guestfish <<EOF
-alloc /tmp/test.img 100M
-run
+set -e
+
+rm -f test.img
 
 
-# Force a segfault inside the daemon.
--debug segv ''
+../fish/guestfish <<'EOF'
+alloc test.img 10M
+
+append "root=/dev/null"
+-run
 
 # We should now be able to rerun the subprocess.
 
 # We should now be able to rerun the subprocess.
+append ""
 run
 ping-daemon
 EOF
 run
 ping-daemon
 EOF
+
+rm -f test.img
diff --git a/regressions/test-qemudie-midcommand.sh b/regressions/test-qemudie-midcommand.sh
new file mode 100755 (executable)
index 0000000..2aca922
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh -
+# libguestfs
+# Copyright (C) 2009 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# Test if we can handle qemu death in the middle of a command.
+
+set -e
+
+rm -f test.pid test.img
+
+../fish/guestfish <<'EOF'
+alloc test.img 10M
+run
+
+# Kill the subprocess after a short wait.
+pid | cat > test.pid
+! sleep 2 ; kill $(cat test.pid) &
+
+echo "Expect: 'guestfs_sleep reply failed, see earlier error messages'"
+-sleep 1000
+
+# We should now be able to rerun the subprocess.
+run
+ping-daemon
+EOF
+
+rm -f test.pid test.img
diff --git a/regressions/test-qemudie-synch.sh b/regressions/test-qemudie-synch.sh
new file mode 100755 (executable)
index 0000000..96e879d
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh -
+# libguestfs
+# Copyright (C) 2009 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# Test if we can handle qemu death synchronously.
+
+set -e
+
+rm -f test.pid test.img
+
+../fish/guestfish <<'EOF'
+alloc test.img 10M
+run
+
+# Kill subprocess.
+pid | cat > test.pid
+! kill $(cat test.pid) ; sleep 2
+
+# XXX The following sleep should NOT be necessary.
+echo "Expect an error from the next command"
+-sleep 1
+
+# We should now be able to rerun the subprocess.
+run
+ping-daemon
+EOF
+
+rm -f test.pid test.img