[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH v2 9/9] tests/md: Don't hard code /dev/vda in expected output of tests.



From: "Richard W.M. Jones" <rjones redhat com>

Use a small sed script to canonicalize the device names.
---
 tests/md/test-inspect-fstab.sh    |   15 ++++++++-------
 tests/md/test-list-filesystems.sh |   12 ++++++------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/tests/md/test-inspect-fstab.sh b/tests/md/test-inspect-fstab.sh
index d1cf610..62e2e94 100755
--- a/tests/md/test-inspect-fstab.sh
+++ b/tests/md/test-inspect-fstab.sh
@@ -23,6 +23,7 @@ set -e
 export LANG=C
 
 guestfish=../../fish/guestfish
+canonical="sed s,/dev/vd,/dev/sd,g"
 
 rm -f test1.img test.fstab test.output
 
@@ -50,12 +51,12 @@ $guestfish -a test1.img <<'EOF'
 EOF
 
 # This will give a warning, but should not fail.
-$guestfish -a test1.img -i <<'EOF' | sort > test.output
+$guestfish -a test1.img -i <<'EOF' | sort | $canonical > test.output
   inspect-get-mountpoints /dev/VG/Root
 EOF
 
 if [ "$(cat test.output)" != "/: /dev/VG/Root
-/boot: /dev/vda1
+/boot: /dev/sda1
 /nosuchfile: /dev/VG/LV1
 /var: /dev/sdb3" ]; then
     echo "$0: error #1: unexpected output from inspect-get-mountpoints command"
@@ -78,7 +79,7 @@ $guestfish -a test1.img <<'EOF'
   upload test.fstab /etc/fstab
 EOF
 
-$guestfish <<'EOF' > test.output
+$guestfish <<'EOF' | $canonical > test.output
   add-drive-opts test1.img readonly:true name:xvdg
   run
   inspect-os
@@ -87,7 +88,7 @@ EOF
 
 if [ "$(cat test.output)" != "/dev/VG/Root
 /: /dev/VG/Root
-/boot: /dev/vda1" ]; then
+/boot: /dev/sda1" ]; then
     echo "$0: error #2: unexpected output from inspect-get-mountpoints command"
     cat test.output
     exit 1
@@ -109,7 +110,7 @@ $guestfish -a test1.img <<'EOF'
   upload test.fstab /etc/fstab
 EOF
 
-$guestfish <<'EOF' > test.output
+$guestfish <<'EOF' | $canonical > test.output
   add-drive-opts test1.img readonly:true name:cciss/c1d3
   run
   inspect-os
@@ -118,8 +119,8 @@ EOF
 
 if [ "$(cat test.output)" != "/dev/VG/Root
 /: /dev/VG/Root
-/boot: /dev/vda1
-/var: /dev/vda" ]; then
+/boot: /dev/sda1
+/var: /dev/sda" ]; then
     echo "$0: error #3: unexpected output from inspect-get-mountpoints command"
     cat test.output
     exit 1
diff --git a/tests/md/test-list-filesystems.sh b/tests/md/test-list-filesystems.sh
index 9aea21a..b9a0340 100755
--- a/tests/md/test-list-filesystems.sh
+++ b/tests/md/test-list-filesystems.sh
@@ -20,6 +20,8 @@
 
 set -e
 
+rm -f test.output
+
 # Create 2 disks partitioned as:
 # sda1: 20M ext3
 # sda2: 20M MD (md127)
@@ -30,8 +32,7 @@ set -e
 # md127 : 20M ext4
 # vg0 : 16M LV (lv0)
 # lv0 : 16M vfat
-output=$(
-../../fish/guestfish <<EOF
+../../fish/guestfish <<EOF | sed s,/dev/vd,/dev/sd,g > test.output
 # Add 2 empty disks
 sparse fs-test1.img 50M
 sparse fs-test2.img 50M
@@ -59,18 +60,17 @@ mkfs vfat /dev/vg0/lv0
 
 list-filesystems
 EOF
-)
 
-expected="/dev/vda1: ext3
+expected="/dev/sda1: ext3
 /dev/md127: ext4
 /dev/vg0/lv0: vfat"
 
 # Check the output of list-filesystems
-if [ "$output" != "$expected" ]; then
+if [ "$(cat test.output)" != "$expected" ]; then
     echo "$0: error: output of list-filesystems did not match expected output"
     printf "%s\n" "$output"
     exit 1;
 fi
 
 
-rm -f fs-test1.img fs-test2.img
+rm -f fs-test1.img fs-test2.img test.output
-- 
1.7.10.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]