xfstests: standard way of handling loop devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

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):

_create_loop_device()
{
        size=${1}
        dev=`losetup -f`
        file="$TEST_DIR/$(basename $dev).fs"
        truncate -s $size $file || _fail "Cannot create image file $file"
        losetup $dev $file || _fail "Cannot associate $file with $dev"
        echo $dev
}

_destroy_loop_device()
{
        dev=${1}
        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!

Tomas

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs


[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux