inspector: Add a regression test for LUKS images (RHBZ#1602353).

This commit is contained in:
Richard W.M. Jones
2018-07-18 13:37:30 +01:00
parent 55dfcb2211
commit ec2228ea05
5 changed files with 102 additions and 2 deletions

1
.gitignore vendored
View File

@@ -352,6 +352,7 @@ Makefile.in
/inspector/actual-*.xml
/inspector/stamp-virt-inspector.pod
/inspector/test-virt-inspector.sh
/inspector/test-virt-inspector-luks.sh
/inspector/test-xmllint.sh
/inspector/virt-inspector
/inspector/virt-inspector.1

View File

@@ -192,6 +192,8 @@ AC_CONFIG_FILES([inspector/test-xmllint.sh],
[chmod +x,-w inspector/test-xmllint.sh])
AC_CONFIG_FILES([inspector/test-virt-inspector.sh],
[chmod +x,-w inspector/test-virt-inspector.sh])
AC_CONFIG_FILES([inspector/test-virt-inspector-luks.sh],
[chmod +x,-w inspector/test-virt-inspector-luks.sh])
AC_CONFIG_FILES([installcheck.sh],
[chmod +x,-w installcheck.sh])
AC_CONFIG_FILES([ocaml-dep.sh],

View File

@@ -27,11 +27,13 @@ example_xml = \
EXTRA_DIST = \
expected-debian.img.xml \
expected-fedora.img.xml \
expected-fedora-luks.img.xml \
expected-ubuntu.img.xml \
expected-archlinux.img.xml \
expected-coreos.img.xml \
expected-windows.img.xml \
test-virt-inspector.sh \
test-virt-inspector-luks.sh \
test-virt-inspector-docs.sh \
test-xmllint.sh.in \
virt-inspector.pod
@@ -92,14 +94,15 @@ TESTS = \
if ENABLE_APPLIANCE
TESTS += \
test-virt-inspector.sh
test-virt-inspector.sh \
test-virt-inspector-luks.sh
endif ENABLE_APPLIANCE
if HAVE_XMLLINT
TESTS += test-xmllint.sh
endif
check-valgrind:
$(MAKE) TESTS="test-virt-inspector.sh" VG="@VG@" check
$(MAKE) TESTS="test-virt-inspector.sh test-virt-inspector-luks.sh" VG="@VG@" check
check-valgrind-local-guests:
for g in $(GUESTS); do \

View File

@@ -0,0 +1,52 @@
<?xml version="1.0"?>
<operatingsystems>
<operatingsystem>
<root>/dev/VG/Root</root>
<name>linux</name>
<arch>x86_64</arch>
<distro>fedora</distro>
<product_name>Fedora release 14 (Phony)</product_name>
<major_version>14</major_version>
<minor_version>0</minor_version>
<package_format>rpm</package_format>
<package_management>yum</package_management>
<hostname>fedora.invalid</hostname>
<osinfo>fedora14</osinfo>
<mountpoints>
<mountpoint dev="/dev/VG/Root">/</mountpoint>
<mountpoint dev="/dev/sda1">/boot</mountpoint>
</mountpoints>
<filesystems>
<filesystem dev="/dev/VG/Root">
<type>ext2</type>
<label>ROOT</label>
<uuid>01234567-0123-0123-0123-012345678902</uuid>
</filesystem>
<filesystem dev="/dev/sda1">
<type>ext2</type>
<label>BOOT</label>
<uuid>01234567-0123-0123-0123-012345678901</uuid>
</filesystem>
</filesystems>
<applications>
<application>
<name>test1</name>
<version>1.0</version>
<release>1.fc14</release>
<arch>x86_64</arch>
</application>
<application>
<name>test2</name>
<version>2.0</version>
<release>2.fc14</release>
<arch>x86_64</arch>
</application>
<application>
<name>test3</name>
<version>3.0</version>
<release>3.fc14</release>
<arch>x86_64</arch>
</application>
</applications>
</operatingsystem>
</operatingsystems>

View File

@@ -0,0 +1,42 @@
#!/bin/bash -
# libguestfs virt-inspector test script
# Copyright (C) 2012-2018 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.
# Test that virt-inspector can work on encrypted images when the
# right password is supplied.
#
# Regression test for https://bugzilla.redhat.com/show_bug.cgi?id=1602353
set -e
set -x
$TEST_FUNCTIONS
skip_if_skipped
f=../test-data/phony-guests/fedora-luks.img
# Ignore zero-sized file.
if [ -s "$f" ]; then
b=$(basename "$f")
echo FEDORA |
$VG virt-inspector --keys-from-stdin --format=raw -a "$f" > "actual-$b.xml"
# Check the generated output validate the schema.
@XMLLINT@ --noout --relaxng "$srcdir/virt-inspector.rng" "actual-$b.xml"
# This 'diff' command will fail (because of -e option) if there
# are any differences.
diff -ur $diff_ignore "expected-$b.xml" "actual-$b.xml"
fi