3 [ -f testing.sh ] && . testing.sh
5 # We need to test name and file padding.
6 # This means all possible values of strlen(name)+1 % 4,
7 # plus file sizes of at least 0-4.
10 testing "name padding" "cpio -o -H newc|cpio -it" "a\nbb\nccc\ndddd\n" "" "a\nbb\nccc\ndddd\n"
17 testing "file padding" "cpio -o -H newc|cpio -it" "a\nb\nc\nd\n" "" "a\nb\nc\nd\n"
24 # With the proper padding, header length, and file length,
25 # the relevant bit should be here:
26 # 110*5 + 4*3 + 2 + 6*3 = 550 + 12 + 20 = 582
27 # files are padded to n*4, names are padded to 2 + n*4 due to the header length
28 testing "archive length" "cpio -o -H newc|dd ibs=2 skip=291 count=5 2>/dev/null" "TRAILER!!!" "" "a\nbb\nccc\ndddd\n"
29 testing "archive magic" "cpio -o -H newc|dd ibs=2 count=3 2>/dev/null" "070701" "" "a\n"
30 # check name length (8 bytes before the empty "crc")
31 testing "name length" "cpio -o -H newc|dd ibs=2 skip=47 count=4 2>/dev/null" "00000002" "" "a\n"
34 # archive dangling symlinks and empty files even if we cannot open them
35 touch a; chmod a-rwx a; ln -s a/cant b
36 testing "archives unreadable empty files" "cpio -o -H newc|cpio -it" "a\nb\n" "" "a\nb\n"
37 chmod u+rw a; rm -f a b