diff --git a/.gitignore b/.gitignore index 930998007..79ef7c017 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/configure.ac b/configure.ac index b2b64bdd9..baed62f92 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/inspector/Makefile.am b/inspector/Makefile.am index 00d894199..82ff4be77 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -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 \ diff --git a/inspector/expected-fedora-luks.img.xml b/inspector/expected-fedora-luks.img.xml new file mode 100644 index 000000000..df6060a73 --- /dev/null +++ b/inspector/expected-fedora-luks.img.xml @@ -0,0 +1,52 @@ + + + + /dev/VG/Root + linux + x86_64 + fedora + Fedora release 14 (Phony) + 14 + 0 + rpm + yum + fedora.invalid + fedora14 + + / + /boot + + + + ext2 + + 01234567-0123-0123-0123-012345678902 + + + ext2 + + 01234567-0123-0123-0123-012345678901 + + + + + test1 + 1.0 + 1.fc14 + x86_64 + + + test2 + 2.0 + 2.fc14 + x86_64 + + + test3 + 3.0 + 3.fc14 + x86_64 + + + + diff --git a/inspector/test-virt-inspector-luks.sh.in b/inspector/test-virt-inspector-luks.sh.in new file mode 100755 index 000000000..8579846f6 --- /dev/null +++ b/inspector/test-virt-inspector-luks.sh.in @@ -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