aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-06-25 08:40:18 -0700
committerRob Landley <rob@landley.net>2019-06-25 12:03:12 -0500
commitaec194e573e6f94a7bf3c3d64b2a86c1f2057638 (patch)
treebb096be086f7167f507a711cfc997285fd4a0b8e /tests
parent2eefbe410740c165c71aca9f9d8e06096140c16a (diff)
downloadtoybox-aec194e573e6f94a7bf3c3d64b2a86c1f2057638.tar.gz
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!
Diffstat (limited to 'tests')
-rwxr-xr-xtests/losetup.test18
1 files changed, 11 insertions, 7 deletions
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