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 | |
Mike Frysinger | caa7940 | 2009-11-04 18:41:22 -0500 | [diff] [blame] | 5 | . ./testing.sh |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 6 | |
Denis Vlasenko | 29ec0b9 | 2008-07-11 21:43:11 +0000 | [diff] [blame] | 7 | # ls -ln shows date. Need to remove that, it's variable. |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 8 | # sed: coalesce spaces |
| 9 | # cut: remove date |
| 10 | FILTER_LS="sed 's/ */ /g' | cut -d' ' -f 1-5,9-" |
| 11 | |
| 12 | |
| 13 | # newc cpio archive of directory cpio.testdir with empty x and y hardlinks |
| 14 | hexdump="\ |
Denis Vlasenko | 29ec0b9 | 2008-07-11 21:43:11 +0000 | [diff] [blame] | 15 | \x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x64\x1e\x91\x8c\x00\x00\ |
| 16 | \x48\x7f\x80\x4c\x48\x08\x00\x28\x01\xff\xe0\x3f\x24\x14\x00\x0e\ |
| 17 | \x20\xdc\x60\x20\x00\x92\x11\xea\xa0\x1a\x00\x00\x00\x03\x20\x8a\ |
| 18 | \x93\xd4\x9a\x68\x1a\x0d\x1e\x91\xa1\xa0\x06\x98\xe3\x5c\x2f\xd9\ |
| 19 | \x26\xa1\x25\x24\x20\xed\x47\xc7\x21\x40\x2b\x6e\xf2\xe6\xfe\x98\ |
| 20 | \x13\x68\xa8\xbd\x82\xb2\x4f\x26\x02\x24\x16\x5b\x22\x16\x72\x74\ |
| 21 | \x15\xcd\xc1\xa6\x9e\xa6\x5e\x6c\x16\x37\x35\x01\x99\xc4\x81\x21\ |
| 22 | \x29\x28\x4b\x69\x51\xa9\x3c\x1a\x9b\x0a\xe1\xe4\xb4\xaf\x85\x73\ |
| 23 | \xba\x23\x10\x59\xe8\xb3\xe1\xa1\x63\x05\x8c\x4f\xc5\xdc\x91\x4e\ |
| 24 | \x14\x24\x19\x07\xa4\x63\x00" |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 25 | |
Denis Vlasenko | 687a26f | 2008-05-02 21:46:30 +0000 | [diff] [blame] | 26 | user=$(id -u) |
| 27 | group=$(id -g) |
| 28 | |
Denis Vlasenko | 29ec0b9 | 2008-07-11 21:43:11 +0000 | [diff] [blame] | 29 | rm -rf cpio.testdir cpio.testdir2 2>/dev/null |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 30 | |
Denis Vlasenko | 29ec0b9 | 2008-07-11 21:43:11 +0000 | [diff] [blame] | 31 | # testing "test name" "command" "expected result" "file input" "stdin" |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 32 | |
| 33 | testing "cpio extracts zero-sized hardlinks" \ |
Denis Vlasenko | 29ec0b9 | 2008-07-11 21:43:11 +0000 | [diff] [blame] | 34 | "$ECHO -ne '$hexdump' | bzcat | cpio -i; echo \$?; |
| 35 | ls -ln cpio.testdir | $FILTER_LS" \ |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 36 | "\ |
| 37 | 1 blocks |
| 38 | 0 |
Denis Vlasenko | 687a26f | 2008-05-02 21:46:30 +0000 | [diff] [blame] | 39 | -rw-r--r-- 2 $user $group 0 x |
| 40 | -rw-r--r-- 2 $user $group 0 y |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 41 | " \ |
| 42 | "" "" |
| 43 | |
Denys Vlasenko | 6ae6426 | 2009-07-18 16:22:26 +0200 | [diff] [blame] | 44 | test x"$SKIP_KNOWN_BUGS" = x"" && { |
Denys Vlasenko | 398c659 | 2009-05-28 02:03:29 +0200 | [diff] [blame] | 45 | # Currently fails. Numerous buglets: "1 blocks" versus "1 block", |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 46 | # "1 block" must go to stderr, does not list cpio.testdir/x and cpio.testdir/y |
| 47 | testing "cpio lists hardlinks" \ |
Denis Vlasenko | 29ec0b9 | 2008-07-11 21:43:11 +0000 | [diff] [blame] | 48 | "$ECHO -ne '$hexdump' | bzcat | cpio -t 2>&1; echo \$?" \ |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 49 | "\ |
| 50 | 1 block |
| 51 | cpio.testdir |
| 52 | cpio.testdir/x |
| 53 | cpio.testdir/y |
| 54 | 0 |
| 55 | " \ |
| 56 | "" "" |
Denys Vlasenko | 6ae6426 | 2009-07-18 16:22:26 +0200 | [diff] [blame] | 57 | } |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 58 | |
Denis Vlasenko | 29ec0b9 | 2008-07-11 21:43:11 +0000 | [diff] [blame] | 59 | # More complex case |
| 60 | rm -rf cpio.testdir cpio.testdir2 2>/dev/null |
| 61 | mkdir cpio.testdir |
| 62 | touch cpio.testdir/solo |
| 63 | touch cpio.testdir/empty |
| 64 | echo x >cpio.testdir/nonempty |
| 65 | ln cpio.testdir/empty cpio.testdir/empty1 |
| 66 | ln cpio.testdir/nonempty cpio.testdir/nonempty1 |
| 67 | mkdir cpio.testdir2 |
| 68 | |
| 69 | testing "cpio extracts zero-sized hardlinks 2" \ |
| 70 | "find cpio.testdir | cpio -H newc --create | (cd cpio.testdir2 && cpio -i); echo \$?; |
| 71 | ls -ln cpio.testdir2/cpio.testdir | $FILTER_LS" \ |
| 72 | "\ |
Denys Vlasenko | 398c659 | 2009-05-28 02:03:29 +0200 | [diff] [blame] | 73 | 2 blocks |
Denis Vlasenko | 29ec0b9 | 2008-07-11 21:43:11 +0000 | [diff] [blame] | 74 | 0 |
| 75 | -rw-r--r-- 2 $user $group 0 empty |
| 76 | -rw-r--r-- 2 $user $group 0 empty1 |
| 77 | -rw-r--r-- 2 $user $group 2 nonempty |
| 78 | -rw-r--r-- 2 $user $group 2 nonempty1 |
| 79 | -rw-r--r-- 1 $user $group 0 solo |
| 80 | " \ |
| 81 | "" "" |
| 82 | |
| 83 | # Clean up |
| 84 | rm -rf cpio.testdir cpio.testdir2 2>/dev/null |
Denis Vlasenko | 0a38bcf | 2008-04-05 02:46:47 +0000 | [diff] [blame] | 85 | |
| 86 | exit $FAILCOUNT |