[Libguestfs] [PATCH v2 3/5] v2v:test:win: actually check the eventual layout

Roman Kagan rkagan at virtuozzo.com
Thu Oct 8 13:50:34 UTC 2015


v2v/test-v2v-windows-conversion.sh used to query if the expected
directories and files were present in the VM upon conversion; however it
would ignore the results of that query.

That lead to the test passing even though the checks failed.

To fix it, parse the output of guestfish and verify that all is-file and
is-dir commands report the expected "true".

The approach taken is slightly more elaborate than what is being used in
other components, but it allows to generate comprehensible reports in
case of test failure, and facilitates future expansion of the set of
checks including negative ones.

Signed-off-by: Roman Kagan <rkagan at virtuozzo.com>
---
changes since v1:
 - changed the way the presence of files in the guest is checked to
   address the comments to v1

 v2v/test-v2v-windows-conversion.sh | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh
index 1688d11..3e3d645 100755
--- a/v2v/test-v2v-windows-conversion.sh
+++ b/v2v/test-v2v-windows-conversion.sh
@@ -67,12 +67,31 @@ test -f $d/windows.xml
 test -f $d/windows-sda
 
 # Test some aspects of the target disk image.
-guestfish --ro -a $d/windows-sda -i <<EOF
-  is-dir "/Program Files/Red Hat/Firstboot"
-  is-file "/Program Files/Red Hat/Firstboot/firstboot.bat"
-  is-dir "/Program Files/Red Hat/Firstboot/scripts"
-  is-dir "/Windows/Drivers/VirtIO"
-EOF
+script="$d/test.fish"
+expected="$d/expected"
+response="$d/response"
+
+mktest ()
+{
+    local cmd="$1" exp="$2"
+
+    echo "echo '$cmd'" >> "$script"
+    echo "$cmd" >> "$expected"
+
+    echo "$cmd" >> "$script"
+    echo "$exp" >> "$expected"
+}
+
+:> "$script"
+:> "$expected"
+
+mktest "is-dir \"/Program Files/Red Hat/Firstboot\"" true
+mktest "is-file \"/Program Files/Red Hat/Firstboot/firstboot.bat\"" true
+mktest "is-dir \"/Program Files/Red Hat/Firstboot/scripts\"" true
+mktest "is-dir \"/Windows/Drivers/VirtIO\"" true
+
+guestfish --ro -a "$d/windows-sda" -i < "$script" > "$response"
+diff -u "$expected" "$response"
 
 # We also update the Registry several times, for firstboot, and (ONLY
 # if the virtio-win drivers are installed locally) the critical device
-- 
2.4.3




More information about the Libguestfs mailing list