I am currently working on tests that check FITRIM implementation (251, 260 and
one new I'm writing now) and I want to use loopback device as fallback if
$SCRATCH_DEV doesn't support discard. Has anybody been working on some
xfstests' standard way of creating/destroying loop devices?
I could do with something as simple as this (in common.rc):
truncate -s $size $file || _fail "Cannot create image file $file"
losetup $dev $file || _fail "Cannot associate $file with $dev"
umount $dev 2>&1
file=`losetup -a | grep $dev | sed -n "s/.*(\(.*\))$/\1/p"`
losetup -d $dev && rm -f $file || _fail "Cannot destroy loop device"
Do you think it's sufficient or do you have different opinion on handling this?
Thanks for comments!