From 0a8f95a2227a3e43f3560360f9e3580f80ffad52 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 10 Feb 2017 12:54:56 +0000 Subject: [PATCH] v2v: ova: Further fix test cases. Updates commit 7461a8fab14829086f723cba44d07d008994bd5c. Fixes and partly reverts commit 8f91d3a9b0356a701c1904e0a2efa5d272d08ac2. --- test-data/test-utils.sh | 19 ------------------- v2v/test-v2v-i-ova-subfolders.sh | 2 +- v2v/test-v2v-i-ova-tar.expected2 | 2 +- v2v/test-v2v-i-ova-tar.sh | 9 ++++++--- v2v/test-v2v-i-ova-two-disks.expected2 | 4 ++-- v2v/test-v2v-i-ova-two-disks.sh | 9 ++++++--- 6 files changed, 16 insertions(+), 29 deletions(-) diff --git a/test-data/test-utils.sh b/test-data/test-utils.sh index 1c4abe392..86a5aaf12 100755 --- a/test-data/test-utils.sh +++ b/test-data/test-utils.sh @@ -54,22 +54,3 @@ do_sha256 () ;; esac } - -# Returns 0 if QEMU version is greater or equal to the arguments -qemu_is_version() { - if [ $# -ne 2 ] ; then - echo "Usage: $0 " >&2 - return 3 - fi - - - [[ "$(qemu-img --version)" =~ 'qemu-img version '([0-9]+)\.([0-9]+) ]] || return 2 - QMAJ=${BASH_REMATCH[1]} - QMIN=${BASH_REMATCH[2]} - - if [ \( $QMAJ -gt $1 \) -o \( $QMAJ -eq $1 -a $QMIN -ge $2 \) ] ; then - return 0 - fi - - return 1 -} diff --git a/v2v/test-v2v-i-ova-subfolders.sh b/v2v/test-v2v-i-ova-subfolders.sh index 0bc109ef3..34dcd99c6 100755 --- a/v2v/test-v2v-i-ova-subfolders.sh +++ b/v2v/test-v2v-i-ova-subfolders.sh @@ -59,7 +59,7 @@ $VG virt-v2v --debug-gc --quiet \ --print-source > $d/source # Check the parsed source is what we expect. -if qemu_is_version 2 8 ; then +if grep -sq json: $d/source ; then # Normalize the output. # Remove directory prefix. # Exact offset will vary because of tar. diff --git a/v2v/test-v2v-i-ova-tar.expected2 b/v2v/test-v2v-i-ova-tar.expected2 index 1aa54dc37..200e32a70 100644 --- a/v2v/test-v2v-i-ova-tar.expected2 +++ b/v2v/test-v2v-i-ova-tar.expected2 @@ -10,7 +10,7 @@ hypervisor type: vmware video: sound: disks: - json:{ "file": { "driver": "raw", "offset": 9216, "size": 10240, "file": { "filename": "test-tar.ova" } } } (vmdk) [scsi] + json:{ "file": { "driver": "raw", "offset": x, "size": 10240, "file": { "filename": "test-tar.ova" } } } (vmdk) [scsi] removable media: CD-ROM [ide] in slot 0 NICs: diff --git a/v2v/test-v2v-i-ova-tar.sh b/v2v/test-v2v-i-ova-tar.sh index 358b442b3..99988f441 100755 --- a/v2v/test-v2v-i-ova-tar.sh +++ b/v2v/test-v2v-i-ova-tar.sh @@ -58,9 +58,12 @@ $VG virt-v2v --debug-gc --quiet \ --print-source > $d/source # Check the parsed source is what we expect. -if qemu_is_version 2 8 ; then - # normalize the output - sed -i -e "s,\"$d/,\"," $d/source +if grep -sq json: $d/source ; then + # Normalize the output. + # Remove directory prefix. + # Exact offset will vary because of tar. + sed -i -e "s,\"$d/,\"," \ + -e "s|\"offset\": [0-9]*,|\"offset\": x,|" $d/source diff -u test-v2v-i-ova-tar.expected2 $d/source else # normalize the output diff --git a/v2v/test-v2v-i-ova-two-disks.expected2 b/v2v/test-v2v-i-ova-two-disks.expected2 index b12ca1bd6..cf4cea50b 100644 --- a/v2v/test-v2v-i-ova-two-disks.expected2 +++ b/v2v/test-v2v-i-ova-two-disks.expected2 @@ -10,8 +10,8 @@ hypervisor type: vmware video: sound: disks: - json:{ "file": { "driver": "raw", "offset": 9728, "size": 10240, "file": { "filename": "test.ova" } } } (vmdk) [scsi] - json:{ "file": { "driver": "raw", "offset": 21504, "size": 102400, "file": { "filename": "test.ova" } } } (vmdk) [scsi] + json:{ "file": { "driver": "raw", "offset": x, "size": 10240, "file": { "filename": "test.ova" } } } (vmdk) [scsi] + json:{ "file": { "driver": "raw", "offset": x, "size": 102400, "file": { "filename": "test.ova" } } } (vmdk) [scsi] removable media: CD-ROM [ide] in slot 0 NICs: diff --git a/v2v/test-v2v-i-ova-two-disks.sh b/v2v/test-v2v-i-ova-two-disks.sh index 89d13093b..f02e8f2f8 100755 --- a/v2v/test-v2v-i-ova-two-disks.sh +++ b/v2v/test-v2v-i-ova-two-disks.sh @@ -63,9 +63,12 @@ $VG virt-v2v --debug-gc --quiet \ --print-source > $d/source # Check the parsed source is what we expect. -if qemu_is_version 2 8 ; then - # normalize the output - sed -i -e "s,\"$d/,\"," $d/source +if grep -sq json: $d/source ; then + # Normalize the output. + # Remove directory prefix. + # Exact offset will vary because of tar. + sed -i -e "s,\"$d/,\"," \ + -e "s|\"offset\": [0-9]*,|\"offset\": x,|" $d/source diff -u test-v2v-i-ova-two-disks.expected2 $d/source else # normalize the output