8e6106326fcfab99d533aa113062fe031d2a9086
[libguestfs.git] / tools / test-virt-df.sh
1 #!/bin/bash -
2
3 export LANG=C
4 set -e
5
6 # Run virt-df.
7 output=$(./virt-df test.img -h)
8
9 # The output will be slightly different from one machine to another.
10 # So just do some tests to make sure it looks reasonable.
11
12 # Check title is the first line.
13 if [[ ! $output =~ ^Filesystem[[:space:]]+Size[[:space:]]+Used[[:space:]]+Available[[:space:]]+Use% ]]; then
14     echo "$0: error: no title line"
15     exit 1
16 fi
17
18 # Check 6 lines (title line + 5 * filesystems).
19 if [ $(echo "$output" | wc -l) -ne 6 ]; then
20     echo "$0: error: not all filesystems were found"
21     exit 1
22 fi
23
24 # Check /dev/VG/LV[1-3] and /dev/VG/Root were found.
25 if [[ ! $output =~ test.img:/dev/VG/LV1 ]]; then
26     echo "$0: error: filesystem /dev/VG/LV1 was not found"
27     exit 1
28 fi
29 if [[ ! $output =~ test.img:/dev/VG/LV2 ]]; then
30     echo "$0: error: filesystem /dev/VG/LV2 was not found"
31     exit 1
32 fi
33 if [[ ! $output =~ test.img:/dev/VG/LV3 ]]; then
34     echo "$0: error: filesystem /dev/VG/LV3 was not found"
35     exit 1
36 fi
37 if [[ ! $output =~ test.img:/dev/VG/Root ]]; then
38     echo "$0: error: filesystem /dev/VG/Root was not found"
39     exit 1
40 fi
41
42 # Check /dev/sda1 was found.  Might be called /dev/vda1.
43 if [[ ! $output =~ test.img:/dev/[hsv]da1 ]]; then
44     echo "$0: error: filesystem /dev/VG/sda1 was not found"
45     exit 1
46 fi