Contents of /trunk/mkinitrd-magellan/busybox/testsuite/cpio.tests
Parent Directory | Revision Log
Revision 1123 -
(show annotations)
(download)
Wed Aug 18 21:56:57 2010 UTC (14 years, 1 month ago) by niro
File size: 3327 byte(s)
Wed Aug 18 21:56:57 2010 UTC (14 years, 1 month ago) by niro
File size: 3327 byte(s)
-updated to busybox-1.17.1
1 | #!/bin/sh |
2 | # Copyright 2008 by Denys Vlasenko |
3 | # Licensed under GPL v2, see file LICENSE for details. |
4 | |
5 | . ./testing.sh |
6 | |
7 | # ls -ln shows date. Need to remove that, it's variable. |
8 | # sed: coalesce spaces |
9 | # cut: remove date |
10 | # grep: remove "total NNN" lines |
11 | FILTER_LS="sed 's/ */ /g' | cut -d' ' -f 1-5,9- | grep -v '^total '" |
12 | |
13 | |
14 | # newc cpio archive of directory cpio.testdir with empty x and y hardlinks |
15 | hexdump="\ |
16 | \x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x64\x1e\x91\x8c\x00\x00\ |
17 | \x48\x7f\x80\x4c\x48\x08\x00\x28\x01\xff\xe0\x3f\x24\x14\x00\x0e\ |
18 | \x20\xdc\x60\x20\x00\x92\x11\xea\xa0\x1a\x00\x00\x00\x03\x20\x8a\ |
19 | \x93\xd4\x9a\x68\x1a\x0d\x1e\x91\xa1\xa0\x06\x98\xe3\x5c\x2f\xd9\ |
20 | \x26\xa1\x25\x24\x20\xed\x47\xc7\x21\x40\x2b\x6e\xf2\xe6\xfe\x98\ |
21 | \x13\x68\xa8\xbd\x82\xb2\x4f\x26\x02\x24\x16\x5b\x22\x16\x72\x74\ |
22 | \x15\xcd\xc1\xa6\x9e\xa6\x5e\x6c\x16\x37\x35\x01\x99\xc4\x81\x21\ |
23 | \x29\x28\x4b\x69\x51\xa9\x3c\x1a\x9b\x0a\xe1\xe4\xb4\xaf\x85\x73\ |
24 | \xba\x23\x10\x59\xe8\xb3\xe1\xa1\x63\x05\x8c\x4f\xc5\xdc\x91\x4e\ |
25 | \x14\x24\x19\x07\xa4\x63\x00" |
26 | |
27 | user=$(id -u) |
28 | group=$(id -g) |
29 | |
30 | rm -rf cpio.testdir cpio.testdir2 2>/dev/null |
31 | |
32 | # testing "test name" "command" "expected result" "file input" "stdin" |
33 | |
34 | optional FEATURE_LS_SORTFILES FEATURE_LS_TIMESTAMPS |
35 | testing "cpio extracts zero-sized hardlinks" \ |
36 | "$ECHO -ne '$hexdump' | bzcat | cpio -i 2>&1; echo \$?; |
37 | ls -ln cpio.testdir | $FILTER_LS" \ |
38 | "\ |
39 | 1 blocks |
40 | 0 |
41 | -rw-r--r-- 2 $user $group 0 x |
42 | -rw-r--r-- 2 $user $group 0 y |
43 | " "" "" |
44 | SKIP= |
45 | |
46 | |
47 | test x"$SKIP_KNOWN_BUGS" = x"" && { |
48 | # Currently fails. Numerous buglets: "1 blocks" versus "1 block", |
49 | # does not list cpio.testdir/x and cpio.testdir/y |
50 | testing "cpio lists hardlinks" \ |
51 | "$ECHO -ne '$hexdump' | bzcat | cpio -t 2>&1; echo \$?" \ |
52 | "\ |
53 | cpio.testdir |
54 | cpio.testdir/x |
55 | cpio.testdir/y |
56 | 1 blocks |
57 | 0 |
58 | " "" "" |
59 | } |
60 | |
61 | |
62 | # More complex case |
63 | rm -rf cpio.testdir cpio.testdir2 2>/dev/null |
64 | mkdir cpio.testdir |
65 | touch cpio.testdir/solo |
66 | touch cpio.testdir/empty |
67 | echo x >cpio.testdir/nonempty |
68 | ln cpio.testdir/empty cpio.testdir/empty1 |
69 | ln cpio.testdir/nonempty cpio.testdir/nonempty1 |
70 | mkdir cpio.testdir2 |
71 | |
72 | optional FEATURE_CPIO_O LONG_OPTS FEATURE_LS_SORTFILES FEATURE_LS_TIMESTAMPS |
73 | testing "cpio extracts zero-sized hardlinks 2" \ |
74 | "find cpio.testdir | cpio -H newc --create | (cd cpio.testdir2 && cpio -i 2>&1); echo \$?; |
75 | ls -ln cpio.testdir2/cpio.testdir | $FILTER_LS" \ |
76 | "\ |
77 | 2 blocks |
78 | 0 |
79 | -rw-r--r-- 2 $user $group 0 empty |
80 | -rw-r--r-- 2 $user $group 0 empty1 |
81 | -rw-r--r-- 2 $user $group 2 nonempty |
82 | -rw-r--r-- 2 $user $group 2 nonempty1 |
83 | -rw-r--r-- 1 $user $group 0 solo |
84 | " "" "" |
85 | SKIP= |
86 | |
87 | # Was trying to create "/usr/bin", correct is "usr/bin". |
88 | rm -rf cpio.testdir |
89 | optional FEATURE_CPIO_P |
90 | testing "cpio -p with absolute paths" \ |
91 | "echo /usr/bin | cpio -dp cpio.testdir 2>&1; echo \$?; |
92 | ls cpio.testdir" \ |
93 | "\ |
94 | 1 blocks |
95 | 0 |
96 | usr |
97 | " "" "" |
98 | SKIP= |
99 | |
100 | # chown on a link was affecting file, dropping its suid/sgid bits |
101 | rm -rf cpio.testdir |
102 | optional FEATURE_CPIO_O FEATURE_STAT_FORMAT |
103 | mkdir cpio.testdir |
104 | touch cpio.testdir/file |
105 | chmod 6755 cpio.testdir/file # sets suid/sgid bits |
106 | ln -sf file cpio.testdir/link |
107 | testing "cpio restores suid/sgid bits" \ |
108 | "cd cpio.testdir && { echo file; echo link; } | cpio -ovHnewc >pack.cpio && rm ???? && cpio -idmvu <pack.cpio 2>/dev/null; |
109 | stat -c '%a %n' file" \ |
110 | "\ |
111 | file |
112 | link |
113 | 6755 file |
114 | " "" "" |
115 | SKIP= |
116 | |
117 | |
118 | # Clean up |
119 | rm -rf cpio.testdir cpio.testdir2 2>/dev/null |
120 | |
121 | exit $FAILCOUNT |