annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
908
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 if [ "$(id -u)" -ne 0 ]
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
6 then
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 echo "SKIPPED: losetup (not root)"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 continue 2>/dev/null
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 exit
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 fi
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
11
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 #testing "name" "command" "result" "infile" "stdin"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
13
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 truncate -s 1M blah.img &&
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 FILE="$(readlink -f blah.img)"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 DEV="$(printf '%04d' $(stat -t blah.img | awk '{print $7}'))"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 NODE="$(awk '{print $7}')"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
18
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 losetup -f
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 losetup -f -s
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 losetup -f file
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 testing "cat" "cat && echo yes" "oneyes\n" "" "one"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 testing "cat -" "cat - && echo yes" "oneyes\n" "" "one"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 testing "cat file1 file2" "cat file1 file2" "one\ntwo\n" "" ""
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 testing "cat - file" "cat - file1" "zero\none\n" "" "zero\n"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 testing "cat file -" "cat file1 -" "one\nzero\n" "" "zero\n"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
27
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 testing "cat file1 notfound file2" \
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 "cat file1 notfound file2 2>stderr && echo ok ; cat stderr; rm stderr" \
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 "one\ntwo\ncat: notfound: No such file or directory\n" "" ""
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
31
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
32 testing "cat file1" \
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 "cat /proc/self/exe > file1 && cmp /proc/self/exe file1 && echo yes" \
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 "yes\n" "" ""
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
35
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 testing "cat - file1" \
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 "cat - file1 | diff -a -U 0 - file1 | tail -n 1" \
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 "-hello\n" "" "hello\n"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
39
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 testing "cat > /dev/full" \
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 "cat - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 "cat: xwrite: No space left on device\n" "" "zero\n"
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
43
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
44 losetup -d
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
45
24ee3b04af3b Tests for losetup.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 rm blah.img