Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright 2008 by Denys Vlasenko |
| 3 | # Licensed under GPL v2, see file LICENSE for details. |
| 4 | |
| 5 | . testing.sh |
| 6 | |
Denis Vlasenko | 687a26f | 2008-05-02 21:46:30 +0000 | [diff] [blame] | 7 | # check if hexdump supports the '-R' option |
| 8 | hexdump -R </dev/null >/dev/null 2>&1 || { |
| 9 | echo "'hexdump -R' is not available" >&2 |
Denis Vlasenko | 687a26f | 2008-05-02 21:46:30 +0000 | [diff] [blame] | 10 | exit 1 |
| 11 | } |
| 12 | |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 13 | # ls -ln is showing date. Need to remove that, it's variable |
| 14 | # sed: coalesce spaces |
| 15 | # cut: remove date |
| 16 | FILTER_LS="sed 's/ */ /g' | cut -d' ' -f 1-5,9-" |
| 17 | |
| 18 | |
| 19 | # newc cpio archive of directory cpio.testdir with empty x and y hardlinks |
| 20 | hexdump="\ |
| 21 | 00000000 42 5a 68 39 31 41 59 26 53 59 64 1e 91 8c 00 00 |
| 22 | 00000010 48 7f 80 4c 48 08 00 28 01 ff e0 3f 24 14 00 0e |
| 23 | 00000020 20 dc 60 20 00 92 11 ea a0 1a 00 00 00 03 20 8a |
| 24 | 00000030 93 d4 9a 68 1a 0d 1e 91 a1 a0 06 98 e3 5c 2f d9 |
| 25 | 00000040 26 a1 25 24 20 ed 47 c7 21 40 2b 6e f2 e6 fe 98 |
| 26 | 00000050 13 68 a8 bd 82 b2 4f 26 02 24 16 5b 22 16 72 74 |
| 27 | 00000060 15 cd c1 a6 9e a6 5e 6c 16 37 35 01 99 c4 81 21 |
| 28 | 00000070 29 28 4b 69 51 a9 3c 1a 9b 0a e1 e4 b4 af 85 73 |
| 29 | 00000080 ba 23 10 59 e8 b3 e1 a1 63 05 8c 4f c5 dc 91 4e |
| 30 | 00000090 14 24 19 07 a4 63 00 |
| 31 | " |
| 32 | |
Denis Vlasenko | 687a26f | 2008-05-02 21:46:30 +0000 | [diff] [blame] | 33 | user=$(id -u) |
| 34 | group=$(id -g) |
| 35 | |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 36 | rm -rf cpio.testdir |
| 37 | |
| 38 | # testing "test name" "options" "expected result" "file input" "stdin" |
| 39 | |
| 40 | testing "cpio extracts zero-sized hardlinks" \ |
| 41 | "echo '$hexdump' | hexdump -R | bzcat | cpio -i; echo \$?; |
| 42 | ls -ln cpio.testdir | $FILTER_LS" \ |
| 43 | "\ |
| 44 | 1 blocks |
| 45 | 0 |
Denis Vlasenko | 687a26f | 2008-05-02 21:46:30 +0000 | [diff] [blame] | 46 | -rw-r--r-- 2 $user $group 0 x |
| 47 | -rw-r--r-- 2 $user $group 0 y |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 48 | " \ |
| 49 | "" "" |
| 50 | |
| 51 | # Currently fails. Numerous: "1 blocks" versus "1 block", |
| 52 | # "1 block" must go to stderr, does not list cpio.testdir/x and cpio.testdir/y |
| 53 | testing "cpio lists hardlinks" \ |
| 54 | "echo '$hexdump' | hexdump -R | bzcat | cpio -t 2>&1; echo \$?" \ |
| 55 | "\ |
| 56 | 1 block |
| 57 | cpio.testdir |
| 58 | cpio.testdir/x |
| 59 | cpio.testdir/y |
| 60 | 0 |
| 61 | " \ |
| 62 | "" "" |
| 63 | |
| 64 | # clean up |
| 65 | rm -rf cpio.testdir |
| 66 | |
| 67 | exit $FAILCOUNT |