summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-07-06 13:10:25 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-07-06 13:10:25 +0100
commit51ecd63944bb1374ebad518d814deaa2096bc365 (patch)
tree7ef6b1daea5d66f3516a4ef47416d638a2f4adec
parentf1fadb92179b68519b57680718e30a389a63d5e5 (diff)
downloadlibguestfs-51ecd63944bb1374ebad518d814deaa2096bc365.tar.gz
libguestfs-51ecd63944bb1374ebad518d814deaa2096bc365.tar.xz
libguestfs-51ecd63944bb1374ebad518d814deaa2096bc365.zip
Introduce regression tests for various qemu failures.
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.
-rw-r--r--regressions/Makefile.am15
-rwxr-xr-xregressions/rhbz503169c10.sh2
-rwxr-xr-xregressions/rhbz503169c13.sh2
-rwxr-xr-xregressions/test-bootbootboot.sh1
-rwxr-xr-xregressions/test-qemudie-killsub.sh41
-rwxr-xr-xregressions/test-qemudie-launchfail.sh (renamed from regressions/test-cleanup.sh)19
-rwxr-xr-xregressions/test-qemudie-midcommand.sh41
-rwxr-xr-xregressions/test-qemudie-synch.sh42
8 files changed, 150 insertions, 13 deletions
diff --git a/regressions/Makefile.am b/regressions/Makefile.am
index 78ecfaa4..874e898e 100644
--- a/regressions/Makefile.am
+++ b/regressions/Makefile.am
@@ -24,8 +24,21 @@
TESTS = \
rhbz503169c10.sh \
rhbz503169c13.sh \
+ test-qemudie-midcommand.sh \
+ test-qemudie-killsub.sh \
+ test-qemudie-synch.sh
+
+SKIPPED_TESTS = \
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 = \
- test-cleanup.sh \
+ $(FAILING_TESTS) \
+ $(SKIPPED_TESTS) \
$(TESTS)
diff --git a/regressions/rhbz503169c10.sh b/regressions/rhbz503169c10.sh
index 8cdad50f..2cfdbca8 100755
--- a/regressions/rhbz503169c10.sh
+++ b/regressions/rhbz503169c10.sh
@@ -24,8 +24,6 @@ set -e
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
diff --git a/regressions/rhbz503169c13.sh b/regressions/rhbz503169c13.sh
index 71e29cee..b6b4b94a 100755
--- a/regressions/rhbz503169c13.sh
+++ b/regressions/rhbz503169c13.sh
@@ -29,8 +29,6 @@ set -e
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 ,
diff --git a/regressions/test-bootbootboot.sh b/regressions/test-bootbootboot.sh
index 05ff6dfe..4586aff8 100755
--- a/regressions/test-bootbootboot.sh
+++ b/regressions/test-bootbootboot.sh
@@ -30,7 +30,6 @@ n=10
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 ...
diff --git a/regressions/test-qemudie-killsub.sh b/regressions/test-qemudie-killsub.sh
new file mode 100755
index 00000000..9848ebf2
--- /dev/null
+++ b/regressions/test-qemudie-killsub.sh
@@ -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
diff --git a/regressions/test-cleanup.sh b/regressions/test-qemudie-launchfail.sh
index a68f57e6..7da1c35e 100755
--- a/regressions/test-cleanup.sh
+++ b/regressions/test-qemudie-launchfail.sh
@@ -16,17 +16,22 @@
# 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.
+append ""
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
index 00000000..2aca9225
--- /dev/null
+++ b/regressions/test-qemudie-midcommand.sh
@@ -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
index 00000000..96e879d0
--- /dev/null
+++ b/regressions/test-qemudie-synch.sh
@@ -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