Denys Vlasenko | bf22475 | 2009-11-29 19:09:29 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright 2009 by Denys Vlasenko |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 3 | # Licensed under GPLv2, see file LICENSE in this source tree. |
Denys Vlasenko | bf22475 | 2009-11-29 19:09:29 +0100 | [diff] [blame] | 4 | |
| 5 | . ./testing.sh |
| 6 | |
Dan Fandrich | 775965d | 2010-08-10 23:33:57 -0700 | [diff] [blame] | 7 | unset LANG |
| 8 | unset LANGUAGE |
| 9 | unset LC_COLLATE |
| 10 | unset LC_ALL |
| 11 | umask 022 |
| 12 | |
Denys Vlasenko | 02365a6 | 2010-04-09 10:52:52 +0200 | [diff] [blame] | 13 | rm -rf tar.tempdir 2>/dev/null |
| 14 | mkdir tar.tempdir && cd tar.tempdir || exit 1 |
Denys Vlasenko | bf22475 | 2009-11-29 19:09:29 +0100 | [diff] [blame] | 15 | |
| 16 | # testing "test name" "script" "expected result" "file input" "stdin" |
| 17 | |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 18 | optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES |
Denys Vlasenko | 02365a6 | 2010-04-09 10:52:52 +0200 | [diff] [blame] | 19 | testing "tar hardlinks and repeated files" '\ |
Denys Vlasenko | 425ad9c | 2009-12-16 22:46:01 +0100 | [diff] [blame] | 20 | rm -rf input_* test.tar 2>/dev/null |
| 21 | >input_hard1 |
Denys Vlasenko | bf22475 | 2009-11-29 19:09:29 +0100 | [diff] [blame] | 22 | ln input_hard1 input_hard2 |
| 23 | mkdir input_dir |
| 24 | >input_dir/file |
Denys Vlasenko | 02365a6 | 2010-04-09 10:52:52 +0200 | [diff] [blame] | 25 | chmod -R 644 * |
| 26 | chmod 755 input_dir |
Denys Vlasenko | bf22475 | 2009-11-29 19:09:29 +0100 | [diff] [blame] | 27 | tar cf test.tar input input_dir/ input_hard1 input_hard2 input_hard1 input_dir/ input |
Denys Vlasenko | 02365a6 | 2010-04-09 10:52:52 +0200 | [diff] [blame] | 28 | tar tvf test.tar | sed "s/.*[0-9] input/input/" |
| 29 | tar xf test.tar 2>&1 |
| 30 | echo Ok: $? |
| 31 | ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/" |
| 32 | ' "\ |
Denys Vlasenko | 425ad9c | 2009-12-16 22:46:01 +0100 | [diff] [blame] | 33 | input |
Denys Vlasenko | bf22475 | 2009-11-29 19:09:29 +0100 | [diff] [blame] | 34 | input_dir/ |
| 35 | input_dir/file |
| 36 | input_hard1 |
| 37 | input_hard2 -> input_hard1 |
| 38 | input_hard1 -> input_hard1 |
| 39 | input_dir/ |
| 40 | input_dir/file |
| 41 | input |
Denys Vlasenko | 02365a6 | 2010-04-09 10:52:52 +0200 | [diff] [blame] | 42 | Ok: 0 |
| 43 | -rw-r--r-- input_dir/file |
| 44 | drwxr-xr-x input_dir |
| 45 | -rw-r--r-- input_hard1 |
| 46 | -rw-r--r-- input_hard2 |
| 47 | " \ |
| 48 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 49 | SKIP= |
Denys Vlasenko | 02365a6 | 2010-04-09 10:52:52 +0200 | [diff] [blame] | 50 | |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 51 | optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES |
Denys Vlasenko | 02365a6 | 2010-04-09 10:52:52 +0200 | [diff] [blame] | 52 | testing "tar hardlinks mode" '\ |
| 53 | rm -rf input_* test.tar 2>/dev/null |
| 54 | >input_hard1 |
| 55 | chmod 741 input_hard1 |
| 56 | ln input_hard1 input_hard2 |
| 57 | mkdir input_dir |
| 58 | chmod 550 input_dir |
| 59 | ln input_hard1 input_dir |
| 60 | ln input_hard2 input_dir |
| 61 | tar cf test.tar input_* |
| 62 | tar tvf test.tar | sed "s/.*[0-9] input/input/" |
| 63 | tar xf test.tar 2>&1 |
| 64 | echo Ok: $? |
| 65 | ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/" |
| 66 | ' "\ |
| 67 | input_dir/ |
| 68 | input_dir/input_hard1 |
| 69 | input_dir/input_hard2 -> input_dir/input_hard1 |
| 70 | input_hard1 -> input_dir/input_hard1 |
| 71 | input_hard2 -> input_dir/input_hard1 |
| 72 | Ok: 0 |
| 73 | -rwxr----x input_dir/input_hard1 |
| 74 | -rwxr----x input_dir/input_hard2 |
| 75 | dr-xr-x--- input_dir |
| 76 | -rwxr----x input_hard1 |
| 77 | -rwxr----x input_hard2 |
Denys Vlasenko | bf22475 | 2009-11-29 19:09:29 +0100 | [diff] [blame] | 78 | " \ |
| 79 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 80 | SKIP= |
Denys Vlasenko | bf22475 | 2009-11-29 19:09:29 +0100 | [diff] [blame] | 81 | |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 82 | optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES |
Denys Vlasenko | e69ad87 | 2010-04-09 14:11:45 +0200 | [diff] [blame] | 83 | testing "tar symlinks mode" '\ |
| 84 | rm -rf input_* test.tar 2>/dev/null |
| 85 | >input_file |
| 86 | chmod 741 input_file |
| 87 | ln -s input_file input_soft |
| 88 | mkdir input_dir |
| 89 | chmod 550 input_dir |
| 90 | ln input_file input_dir |
| 91 | ln input_soft input_dir |
| 92 | tar cf test.tar input_* |
Denys Vlasenko | e82cf33 | 2010-05-12 15:59:32 +0200 | [diff] [blame] | 93 | tar tvf test.tar | sed "s/.*[0-9] input/input/" | sort |
Denys Vlasenko | e69ad87 | 2010-04-09 14:11:45 +0200 | [diff] [blame] | 94 | tar xf test.tar 2>&1 |
| 95 | echo Ok: $? |
| 96 | ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/" |
| 97 | ' "\ |
| 98 | input_dir/ |
| 99 | input_dir/input_file |
| 100 | input_dir/input_soft -> input_file |
| 101 | input_file -> input_dir/input_file |
| 102 | input_soft -> input_dir/input_soft |
| 103 | Ok: 0 |
| 104 | -rwxr----x input_dir/input_file |
| 105 | lrwxrwxrwx input_file |
| 106 | dr-xr-x--- input_dir |
| 107 | -rwxr----x input_file |
| 108 | lrwxrwxrwx input_file |
| 109 | " \ |
| 110 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 111 | SKIP= |
Denys Vlasenko | e69ad87 | 2010-04-09 14:11:45 +0200 | [diff] [blame] | 112 | |
Denys Vlasenko | da13824 | 2010-05-11 12:02:48 +0200 | [diff] [blame] | 113 | optional FEATURE_TAR_CREATE FEATURE_TAR_LONG_OPTIONS |
Denys Vlasenko | 8a936cf | 2009-12-16 23:18:59 +0100 | [diff] [blame] | 114 | testing "tar --overwrite" "\ |
| 115 | rm -rf input_* test.tar 2>/dev/null |
| 116 | ln input input_hard |
| 117 | tar cf test.tar input_hard |
| 118 | echo WRONG >input |
| 119 | # --overwrite opens 'input_hard' without unlinking, |
| 120 | # thus 'input_hard' still linked to 'input' and we write 'Ok' into it |
| 121 | tar xf test.tar --overwrite 2>&1 && cat input |
| 122 | " "\ |
| 123 | Ok |
| 124 | " \ |
| 125 | "Ok\n" "" |
Chris Metcalf | 208d35d | 2010-04-02 09:57:27 +0200 | [diff] [blame] | 126 | SKIP= |
Denys Vlasenko | 8a936cf | 2009-12-16 23:18:59 +0100 | [diff] [blame] | 127 | |
Denys Vlasenko | 02365a6 | 2010-04-09 10:52:52 +0200 | [diff] [blame] | 128 | cd .. && rm -rf tar.tempdir || exit 1 |
Denys Vlasenko | bf22475 | 2009-11-29 19:09:29 +0100 | [diff] [blame] | 129 | |
| 130 | exit $FAILCOUNT |