source: rtems/testsuites/libtests/tar01/tar01.scn @ ff3f3490

5
Last change on this file since ff3f3490 was ff3f3490, checked in by Christian Mauderer <christian.mauderer@…>, on 12/01/21 at 15:39:46

untar: Make behavior similar to GNU or BSD tar

RTEMS untar implementation had problems with overwriting or integrating
archives into existing directory structures. This patch adapts the
behavior to mimic that of a GNU tar or BSD tar and extends the tar01
test to check for the behavior. That is:

  • If a directory structure exists, the files from the archive will be integrated. Existing files are overwritten.
  • If a file exists and the archive contains a directory with the same name, the file is removed and a directory is created. In the above example: if l1/l2 is a file it will be overwritten with a new directory.
  • If a directory exists and the archive contains a file with the same name, the directory will be replaced if it is empty. If it contains files, the result is an error.
  • An archive also can contain only a file without the parent directories. If in that case one of the parent directories exists as a file extracting the archive results in an error. In the example: if l1/l2 is a file and the archive doesn't contain the directories but only the file l1/l2/x.txt that would be an error.
  • In case of an error, it is possible that the archive has been partially extracted.

Closes #4552

  • Property mode set to 100644
File size: 2.6 KB
Line 
1*** BEGIN OF TEST TAR 1 ***
2*** TEST VERSION: 6.0.0.e1efb4eb8a9d6dd5f6f37dafc9feb0a9e6a888f1
3*** TEST STATE: EXPECTED_PASS
4*** TEST BUILD: RTEMS_POSIX_API
5*** TEST TOOLS: 10.3.1 20210409 (RTEMS 6, RSB ad54d1dd3cf8249d9d39deb1dd28b2f294df062d-modified, Newlib eb03ac1)
6Untaring from memory - untar: memory at 0x11ece8 (10240)
7untar: symlink: home/test_file -> symlink
8untar: file: home/test_file (s:73,m:0644)
9untar: file: home/abc/def/test_script (s:21,m:0755)
10untar: dir: home/dir
11untar: file: home/dir/file (s:12,m:0644)
12successful
13========= /home/test_file =========
14(0)This is a test of loading an RTEMS filesystem from an
15initial tar image.
16
17========= /home/abc/def/test_script =========
18(0)#! joel
19ls -las /dev
20
21 /home/abc/def/test_script: mode: 0755 want: 0755
22========= /symlink =========
23(0)This is a test of loading an RTEMS filesystem from an
24initial tar image.
25
26
27Copy tar image to test.tar
28Untaring from file - successful
29Untar from file into existing structure with one missing file - successful
30Untar from file; overwrite empty directory with file - successful
31Untar from file; file exists where parent dir should be created - expected fail
32Untar from file; non-empty dir where file should be created - expected fail
33Untar from file; overwrite file with explicit directory - successful
34========= /dest/home/test_file =========
35(0)This is a test of loading an RTEMS filesystem from an
36initial tar image.
37
38========= /dest/home/abc/def/test_script =========
39(0)#! joel
40ls -las /dev
41
42 /dest/home/abc/def/test_script: mode: 0755 want: 0755
43========= /dest/symlink =========
44(0)This is a test of loading an RTEMS filesystem from an
45initial tar image.
46
47
48Untaring chunks from memory - untar: symlink: home/test_file -> symlink
49untar: file: home/test_file (s:73,m:0644)
50untar: file: home/abc/def/test_script (s:21,m:0755)
51untar: dir: home/dir
52untar: file: home/dir/file (s:12,m:0644)
53successful
54========= /dest2/home/test_file =========
55(0)This is a test of loading an RTEMS filesystem from an
56initial tar image.
57
58========= /dest2/home/abc/def/test_script =========
59(0)#! joel
60ls -las /dev
61
62 /dest2/home/abc/def/test_script: mode: 0755 want: 0755
63========= /dest2/symlink =========
64(0)This is a test of loading an RTEMS filesystem from an
65initial tar image.
66
67
68Untaring chunks from tgz - successful
69========= /dest3/home/test_file =========
70(0)This is a test of loading an RTEMS filesystem from an
71initial tar image.
72
73========= /dest3/home/abc/def/test_script =========
74(0)#! joel
75ls -las /dev
76
77 /dest3/home/abc/def/test_script: mode: 0755 want: 0755
78========= /dest3/symlink =========
79(0)This is a test of loading an RTEMS filesystem from an
80initial tar image.
81
82
83*** END OF TEST TAR 1 ***
Note: See TracBrowser for help on using the repository browser.