X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=tools%2Ftest-virt-df.sh;h=a7b50b8fe310623e2cb9b8e712cc8ef4bfb67f6c;hp=8e6106326fcfab99d533aa113062fe031d2a9086;hb=29c78cc979297b95407a5956b4caa34240a2f5a8;hpb=fc5fbd460aa0aaf6bb65ca5fa1be59345f4f079f diff --git a/tools/test-virt-df.sh b/tools/test-virt-df.sh index 8e61063..a7b50b8 100755 --- a/tools/test-virt-df.sh +++ b/tools/test-virt-df.sh @@ -4,13 +4,10 @@ export LANG=C set -e # Run virt-df. -output=$(./virt-df test.img -h) - -# The output will be slightly different from one machine to another. -# So just do some tests to make sure it looks reasonable. +output=$(./virt-df test.img) # Check title is the first line. -if [[ ! $output =~ ^Filesystem[[:space:]]+Size[[:space:]]+Used[[:space:]]+Available[[:space:]]+Use% ]]; then +if [[ ! $output =~ ^Filesystem.* ]]; then echo "$0: error: no title line" exit 1 fi @@ -44,3 +41,32 @@ if [[ ! $output =~ test.img:/dev/[hsv]da1 ]]; then echo "$0: error: filesystem /dev/VG/sda1 was not found" exit 1 fi + +# This is what df itself prints for these filesystems (determined +# by running the test image under virt-rescue): +# +# > df -h +# Filesystem Size Used Avail Use% Mounted on +# /dev/dm-1 31M 28K 30M 1% /sysroot/lv1 +# /dev/dm-2 31M 395K 29M 2% /sysroot/lv2 +# /dev/dm-3 62M 144K 59M 1% /sysroot/lv3 +# > df -i +# Filesystem Inodes IUsed IFree IUse% Mounted on +# /dev/dm-1 8192 11 8181 1% /sysroot/lv1 +# /dev/dm-2 8192 11 8181 1% /sysroot/lv2 +# /dev/dm-3 16384 11 16373 1% /sysroot/lv3 +# > df +# Filesystem 1K-blocks Used Available Use% Mounted on +# /dev/dm-1 31728 28 30064 1% /sysroot/lv1 +# /dev/dm-2 31729 395 29696 2% /sysroot/lv2 +# /dev/dm-3 63472 144 60052 1% /sysroot/lv3 +# +# Only test plain 'df' output at the moment (XXX). + +if [ "$(echo "$output" | sort | awk '/VG.LV[123]/ { print $2 " " $3 " " $4 " " $5 }')" != \ +"31728 28 30064 1% +31729 395 29696 2% +63472 144 60052 1%" ]; then + echo "$0: error: output of virt-df did not match expected (df) output" + exit 1 +fi