From aec194e573e6f94a7bf3c3d64b2a86c1f2057638 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 25 Jun 2019 08:40:18 -0700 Subject: losetup: minor fixes. Fix `losetup -f` to not fail with an error. Add the missing \n for `losetup -f --show FILE`. Use decimal for the device number, like the desktop losetup. Switch to the FLAG macro. Make the tests runnable as tests, and expand coverage a bit. With this patch, the tests pass both with and without TEST_HOST on the desktop. Note though that this patch is part of fixing some real-life losetup issues, not part of the "test cleanup" I'm also looking at. losetup is low down that list! --- tests/losetup.test | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/losetup.test b/tests/losetup.test index f30a0fe2..c04a72b9 100755 --- a/tests/losetup.test +++ b/tests/losetup.test @@ -13,13 +13,17 @@ fi truncate -s 1M blah.img && FILE="$(readlink -f blah.img)" -DEV="$(printf '%04s' $(stat -t blah.img | awk '{print $7}'))" -NODE="$(stat -t blah.img | awk '{print $8}')" +DEV="$(stat --format %d blah.img)" +NODE="$(stat --format %i blah.img)" -losetup -f -losetup -f -s -losetup -f file - -losetup -d +# TODO: assumes there are no loopback devices! +testcmd "-f" "-f" "/dev/loop0\n" "" "" +testcmd "-f blah.img" "-f blah.img" "" "" "" +testcmd "-f --show" "-f --show blah.img" "/dev/loop1\n" "" "" +testcmd "-a" "-a | sort" \ + "/dev/loop0: [$DEV]:$NODE ($FILE)\n/dev/loop1: [$DEV]:$NODE ($FILE)\n" "" "" +testcmd "-d /dev/loop0" "-d /dev/loop0 && losetup -a" \ + "/dev/loop1: [$DEV]:$NODE ($FILE)\n" "" "" +testcmd "-D" "-D && losetup -a" "" "" "" rm blah.img -- cgit v1.2.3