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