From f6a37740f2ba6668bee4952fdd35c46cb6d79cba Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 28 Mar 2014 14:37:45 +0000 Subject: [PATCH] rescue: Add a regression test for virt-rescue --suggest option. --- rescue/Makefile.am | 10 ++++++- rescue/test-virt-rescue-suggest.sh | 43 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 rescue/test-virt-rescue-suggest.sh diff --git a/rescue/Makefile.am b/rescue/Makefile.am index 8afaddc77..c2a9b9ea4 100644 --- a/rescue/Makefile.am +++ b/rescue/Makefile.am @@ -19,6 +19,7 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ test-virt-rescue.pl \ + test-virt-rescue-suggest.sh \ virt-rescue.pod CLEANFILES = stamp-virt-rescue.pod @@ -78,6 +79,13 @@ stamp-virt-rescue.pod: virt-rescue.pod TESTS_ENVIRONMENT = $(top_builddir)/run --test +TESTS = + if ENABLE_APPLIANCE -TESTS = test-virt-rescue.pl +TESTS += \ + test-virt-rescue.pl \ + test-virt-rescue-suggest.sh endif ENABLE_APPLIANCE + +check-valgrind: + $(MAKE) TESTS="test-virt-rescue-suggest.sh" VG="$(top_builddir)/run @VG@" check diff --git a/rescue/test-virt-rescue-suggest.sh b/rescue/test-virt-rescue-suggest.sh new file mode 100755 index 000000000..f3fbebc56 --- /dev/null +++ b/rescue/test-virt-rescue-suggest.sh @@ -0,0 +1,43 @@ +#!/bin/bash - +# test virt-rescue --suggest +# Copyright (C) 2014 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +export LANG=C +set -e + +guest=../tests/guests/fedora.img + +if [ ! -s "$guest" ]; then + echo "$0: test skipped because $guest does not exist or is an empty file" + exit 77 +fi + +rm -f virt-rescue-suggest.out + +$VG ./virt-rescue --suggest "$guest" > virt-rescue-suggest.out +if [ "$(grep '^mount ' virt-rescue-suggest.out)" != "mount /dev/VG/Root /sysroot/ +mount /dev/sda1 /sysroot/boot +mount --bind /dev /sysroot/dev +mount --bind /dev/pts /sysroot/dev/pts +mount --bind /proc /sysroot/proc +mount --bind /sys /sysroot/sys" ]; then + echo "$0: unexpected output from virt-rescue --suggest command:" + cat virt-rescue-suggest.out + exit 1 +fi + +rm virt-rescue-suggest.out