#!/bin/bash - size=1G sizemegabytes=1024 develdir=$HOME/d/libguestfs for guestfish in "$develdir/run $develdir/fish/guestfish" /usr/bin/guestfish do echo Making sure the appliance is cached before we run the test ... $guestfish -a /dev/null run $guestfish -a /dev/null run echo Sparse raw all zeroes test with "$guestfish" ... rm -f test.img test.qcow2 truncate -s $size test.img du -sh test.img $guestfish -a test.img run : time zero-device /dev/sda du -sh test.img echo Non-sparse raw all zeroes test with "$guestfish" ... rm -f test.img test.qcow2 dd if=/dev/zero of=test.img bs=1024k count=$sizemegabytes >/dev/null 2>&1 du -sh test.img $guestfish -a test.img run : time zero-device /dev/sda du -sh test.img echo Non-sparse raw random data test with "$guestfish" ... rm -f test.img test.qcow2 dd if=/dev/urandom of=test.img bs=1024k count=$sizemegabytes >/dev/null 2>&1 du -sh test.img $guestfish -a test.img run : time zero-device /dev/sda du -sh test.img echo QCow2 no preallocation all zeroes test with "$guestfish" ... rm -f test.img test.qcow2 qemu-img create -f qcow2 test.qcow2 $size >/dev/null du -sh test.qcow2 $guestfish -a test.qcow2 run : time zero-device /dev/sda du -sh test.qcow2 echo QCow2 with preallocation all zeroes test with "$guestfish" ... rm -f test.img test.qcow2 qemu-img create -f qcow2 -o preallocation=metadata test.qcow2 $size >/dev/null du -sh test.qcow2 $guestfish -a test.qcow2 run : time zero-device /dev/sda du -sh test.qcow2 done