Mercurial > hg > toybox
comparison tests/losetup.test @ 1485:8700cbe1cb29 draft
Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 20 Sep 2014 13:09:14 -0500 |
parents | scripts/test/losetup.test@24ee3b04af3b |
children |
comparison
equal
deleted
inserted
replaced
1484:19435f12ec63 | 1485:8700cbe1cb29 |
---|---|
1 #!/bin/bash | |
2 | |
3 [ -f testing.sh ] && . testing.sh | |
4 | |
5 if [ "$(id -u)" -ne 0 ] | |
6 then | |
7 echo "SKIPPED: losetup (not root)" | |
8 continue 2>/dev/null | |
9 exit | |
10 fi | |
11 | |
12 #testing "name" "command" "result" "infile" "stdin" | |
13 | |
14 truncate -s 1M blah.img && | |
15 FILE="$(readlink -f blah.img)" | |
16 DEV="$(printf '%04d' $(stat -t blah.img | awk '{print $7}'))" | |
17 NODE="$(awk '{print $7}')" | |
18 | |
19 losetup -f | |
20 losetup -f -s | |
21 losetup -f file | |
22 testing "cat" "cat && echo yes" "oneyes\n" "" "one" | |
23 testing "cat -" "cat - && echo yes" "oneyes\n" "" "one" | |
24 testing "cat file1 file2" "cat file1 file2" "one\ntwo\n" "" "" | |
25 testing "cat - file" "cat - file1" "zero\none\n" "" "zero\n" | |
26 testing "cat file -" "cat file1 -" "one\nzero\n" "" "zero\n" | |
27 | |
28 testing "cat file1 notfound file2" \ | |
29 "cat file1 notfound file2 2>stderr && echo ok ; cat stderr; rm stderr" \ | |
30 "one\ntwo\ncat: notfound: No such file or directory\n" "" "" | |
31 | |
32 testing "cat file1" \ | |
33 "cat /proc/self/exe > file1 && cmp /proc/self/exe file1 && echo yes" \ | |
34 "yes\n" "" "" | |
35 | |
36 testing "cat - file1" \ | |
37 "cat - file1 | diff -a -U 0 - file1 | tail -n 1" \ | |
38 "-hello\n" "" "hello\n" | |
39 | |
40 testing "cat > /dev/full" \ | |
41 "cat - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \ | |
42 "cat: xwrite: No space left on device\n" "" "zero\n" | |
43 | |
44 losetup -d | |
45 | |
46 rm blah.img |