blob: c04a72b9fa94c067515787a75a04d9ecf7712edd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/bin/bash
[ -f testing.sh ] && . testing.sh
if [ "$(id -u)" -ne 0 ]
then
echo "$SHOWSKIP: losetup (not root)"
return 2>/dev/null
exit
fi
#testing "name" "command" "result" "infile" "stdin"
truncate -s 1M blah.img &&
FILE="$(readlink -f blah.img)"
DEV="$(stat --format %d blah.img)"
NODE="$(stat --format %i blah.img)"
# 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
|