[Libguestfs] [PATCH v2 4/4] inspector: Add a regression test for LUKS images (RHBZ#1602353).

Richard W.M. Jones rjones at redhat.com
Wed Jul 25 11:45:38 UTC 2018


---
 .gitignore                               |  1 +
 configure.ac                             |  2 +
 inspector/Makefile.am                    |  7 +++-
 inspector/expected-fedora-luks.img.xml   | 52 ++++++++++++++++++++++++
 inspector/test-virt-inspector-luks.sh.in | 42 +++++++++++++++++++
 5 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index bb4f45e0a..6c6ca7ac6 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 @@
+<?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>
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
-- 
2.18.0




More information about the Libguestfs mailing list