diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2010-11-23 12:05:04 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2010-11-25 18:58:13 +0000 |
commit | 18374b5b7d3154e0b8b8a07e3590f6eee762b58e (patch) | |
tree | 13a8254ab4e06a1736761005866fc313182b8e58 /tools/test-virt-df.sh | |
parent | 4838ec3326d2970e6afe3cde6b368aeae840b969 (diff) | |
download | libguestfs-18374b5b7d3154e0b8b8a07e3590f6eee762b58e.tar.gz libguestfs-18374b5b7d3154e0b8b8a07e3590f6eee762b58e.tar.xz libguestfs-18374b5b7d3154e0b8b8a07e3590f6eee762b58e.zip |
df: Rewrite virt-df in C.
I have diffed the output from the original virt-df with this
new version, and they agree very closely. Some differences:
- Old virt-df have a divide-by-zero error in cases where the
number of used inodes was 0. New virt-df fixes this.
- New virt-df uses gnulib human_readable library which displays
numbers to 3 significant figures for -h output (old version
used an ad hoc function).
Diffstat (limited to 'tools/test-virt-df.sh')
-rwxr-xr-x | tools/test-virt-df.sh | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/tools/test-virt-df.sh b/tools/test-virt-df.sh deleted file mode 100755 index 6878327d..00000000 --- a/tools/test-virt-df.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - - -export LANG=C -set -e - -# Run virt-df. -output=$(./virt-df ../images/fedora.img) - -# Check title is the first line. -if [[ ! $output =~ ^Filesystem.* ]]; then - echo "$0: error: no title line" - exit 1 -fi - -# Check 6 lines (title line + 5 * filesystems). -if [ $(echo "$output" | wc -l) -ne 6 ]; then - echo "$0: error: not all filesystems were found" - exit 1 -fi - -# Check /dev/VG/LV[1-3] and /dev/VG/Root were found. -if [[ ! $output =~ fedora.img:/dev/VG/LV1 ]]; then - echo "$0: error: filesystem /dev/VG/LV1 was not found" - exit 1 -fi -if [[ ! $output =~ fedora.img:/dev/VG/LV2 ]]; then - echo "$0: error: filesystem /dev/VG/LV2 was not found" - exit 1 -fi -if [[ ! $output =~ fedora.img:/dev/VG/LV3 ]]; then - echo "$0: error: filesystem /dev/VG/LV3 was not found" - exit 1 -fi -if [[ ! $output =~ fedora.img:/dev/VG/Root ]]; then - echo "$0: error: filesystem /dev/VG/Root was not found" - exit 1 -fi - -# Check /dev/sda1 was found. Might be called /dev/vda1. -if [[ ! $output =~ fedora.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): -# -# ><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 -# ><rescue> 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 -# ><rescue> 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 |