1 |
jpp |
1.1 |
diff --git a/Makefile.am b/Makefile.am |
2 |
|
|
index 9b0632b..a22ea43 100644 |
3 |
|
|
--- a/Makefile.am |
4 |
|
|
+++ b/Makefile.am |
5 |
|
|
@@ -277,7 +277,6 @@ libarchive_test_SOURCES= \ |
6 |
|
|
libarchive/test/test_read_format_isorr_bz2.c \ |
7 |
|
|
libarchive/test/test_read_format_isorr_ce.c \ |
8 |
|
|
libarchive/test/test_read_format_isorr_new_bz2.c \ |
9 |
|
|
- libarchive/test/test_read_format_isorr_rr_moved.c \ |
10 |
|
|
libarchive/test/test_read_format_isozisofs_bz2.c \ |
11 |
|
|
libarchive/test/test_read_format_mtree.c \ |
12 |
|
|
libarchive/test/test_read_format_pax_bz2.c \ |
13 |
|
|
@@ -288,7 +287,6 @@ libarchive_test_SOURCES= \ |
14 |
|
|
libarchive/test/test_read_format_tgz.c \ |
15 |
|
|
libarchive/test/test_read_format_tlz.c \ |
16 |
|
|
libarchive/test/test_read_format_txz.c \ |
17 |
|
|
- libarchive/test/test_read_format_tz.c \ |
18 |
|
|
libarchive/test/test_read_format_xar.c \ |
19 |
|
|
libarchive/test/test_read_format_zip.c \ |
20 |
|
|
libarchive/test/test_read_large.c \ |
21 |
|
|
@@ -305,14 +303,12 @@ libarchive_test_SOURCES= \ |
22 |
|
|
libarchive/test/test_write_compress_lzma.c \ |
23 |
|
|
libarchive/test/test_write_compress_program.c \ |
24 |
|
|
libarchive/test/test_write_compress_xz.c \ |
25 |
|
|
- libarchive/test/test_write_disk.c \ |
26 |
|
|
libarchive/test/test_write_disk_failures.c \ |
27 |
|
|
libarchive/test/test_write_disk_hardlink.c \ |
28 |
|
|
libarchive/test/test_write_disk_perms.c \ |
29 |
|
|
libarchive/test/test_write_disk_secure.c \ |
30 |
|
|
libarchive/test/test_write_disk_sparse.c \ |
31 |
|
|
libarchive/test/test_write_disk_symlink.c \ |
32 |
|
|
- libarchive/test/test_write_disk_times.c \ |
33 |
|
|
libarchive/test/test_write_format_ar.c \ |
34 |
|
|
libarchive/test/test_write_format_cpio.c \ |
35 |
|
|
libarchive/test/test_write_format_cpio_empty.c \ |
36 |
|
|
diff --git a/libarchive/test/test_read_format_isorr_rr_moved.c b/libarchive/test/test_read_format_isorr_rr_moved.c |
37 |
|
|
deleted file mode 100644 |
38 |
|
|
index d59b346..0000000 |
39 |
|
|
--- a/libarchive/test/test_read_format_isorr_rr_moved.c |
40 |
|
|
+++ /dev/null |
41 |
|
|
@@ -1,270 +0,0 @@ |
42 |
|
|
-/*- |
43 |
|
|
- * Copyright (c) 2003-2007 Tim Kientzle |
44 |
|
|
- * Copyright (c) 2009 Michihiro NAKAJIMA |
45 |
|
|
- * All rights reserved. |
46 |
|
|
- * |
47 |
|
|
- * Redistribution and use in source and binary forms, with or without |
48 |
|
|
- * modification, are permitted provided that the following conditions |
49 |
|
|
- * are met: |
50 |
|
|
- * 1. Redistributions of source code must retain the above copyright |
51 |
|
|
- * notice, this list of conditions and the following disclaimer. |
52 |
|
|
- * 2. Redistributions in binary form must reproduce the above copyright |
53 |
|
|
- * notice, this list of conditions and the following disclaimer in the |
54 |
|
|
- * documentation and/or other materials provided with the distribution. |
55 |
|
|
- * |
56 |
|
|
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR |
57 |
|
|
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
58 |
|
|
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
59 |
|
|
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, |
60 |
|
|
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
61 |
|
|
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
62 |
|
|
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
63 |
|
|
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
64 |
|
|
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
65 |
|
|
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
66 |
|
|
- */ |
67 |
|
|
-#include "test.h" |
68 |
|
|
-__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_isorr_rr_moved.c 201247 2009-12-30 05:59:21Z kientzle $"); |
69 |
|
|
- |
70 |
|
|
-/* |
71 |
|
|
-Execute the following command to rebuild the data for this program: |
72 |
|
|
- tail -n +32 test_read_format_isorr_rr_moved.c | /bin/sh |
73 |
|
|
- |
74 |
|
|
-dirname=/tmp/iso |
75 |
|
|
-rm -rf $dirname |
76 |
|
|
-mkdir -p $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10 |
77 |
|
|
-echo "hello" >$dirname/file |
78 |
|
|
-dd if=/dev/zero count=1 bs=12345678 >>$dirname/file |
79 |
|
|
-deepfile=$dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10/deep |
80 |
|
|
-echo "hello" >$deepfile |
81 |
|
|
-dd if=/dev/zero count=1 bs=12345678 >>$deepfile |
82 |
|
|
-time="197001020000.01" |
83 |
|
|
-TZ=utc touch -afhm -t $time $deepfile |
84 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10 |
85 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9 |
86 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8 |
87 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7 |
88 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6 |
89 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5 |
90 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4 |
91 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3 |
92 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1/dir2 |
93 |
|
|
-TZ=utc touch -afhm -t $time $dirname/dir1 |
94 |
|
|
-TZ=utc touch -afhm -t $time $dirname/file |
95 |
|
|
-TZ=utc touch -afhm -t $time $dirname |
96 |
|
|
-F=test_read_format_isorr_rockridge_moved.iso.Z |
97 |
|
|
-mkhybrid -R -uid 1 -gid 2 $dirname | compress > $F |
98 |
|
|
-uuencode $F $F > $F.uu |
99 |
|
|
-exit 1 |
100 |
|
|
- */ |
101 |
|
|
- |
102 |
|
|
-DEFINE_TEST(test_read_format_isorr_rr_moved) |
103 |
|
|
-{ |
104 |
|
|
- const char *refname = "test_read_format_iso_rockridge_rr_moved.iso.Z"; |
105 |
|
|
- struct archive_entry *ae; |
106 |
|
|
- struct archive *a; |
107 |
|
|
- const void *p; |
108 |
|
|
- size_t size; |
109 |
|
|
- off_t offset; |
110 |
|
|
- int i; |
111 |
|
|
- |
112 |
|
|
- extract_reference_file(refname); |
113 |
|
|
- assert((a = archive_read_new()) != NULL); |
114 |
|
|
- assertEqualInt(0, archive_read_support_compression_all(a)); |
115 |
|
|
- assertEqualInt(0, archive_read_support_format_all(a)); |
116 |
|
|
- assertEqualInt(ARCHIVE_OK, |
117 |
|
|
- archive_read_open_filename(a, refname, 10240)); |
118 |
|
|
- |
119 |
|
|
- /* Retrieve each of the 8 files on the ISO image and |
120 |
|
|
- * verify that each one is what we expect. */ |
121 |
|
|
- for (i = 0; i < 13; ++i) { |
122 |
|
|
- assertEqualInt(0, archive_read_next_header(a, &ae)); |
123 |
|
|
- |
124 |
|
|
- if (strcmp(".", archive_entry_pathname(ae)) == 0) { |
125 |
|
|
- /* '.' root directory. */ |
126 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
127 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
128 |
|
|
- /* Now, we read timestamp recorded by RRIP "TF". */ |
129 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
130 |
|
|
- assertEqualInt(0, archive_entry_mtime_nsec(ae)); |
131 |
|
|
- /* Now, we read links recorded by RRIP "PX". */ |
132 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
133 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
134 |
|
|
- assertEqualIntA(a, ARCHIVE_EOF, |
135 |
|
|
- archive_read_data_block(a, &p, &size, &offset)); |
136 |
|
|
- assertEqualInt((int)size, 0); |
137 |
|
|
- } else if (strcmp("dir1", archive_entry_pathname(ae)) == 0) { |
138 |
|
|
- /* A directory. */ |
139 |
|
|
- assertEqualString("dir1", archive_entry_pathname(ae)); |
140 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
141 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
142 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
143 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
144 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
145 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
146 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
147 |
|
|
- } else if (strcmp("dir1/dir2", |
148 |
|
|
- archive_entry_pathname(ae)) == 0) { |
149 |
|
|
- /* A directory. */ |
150 |
|
|
- assertEqualString("dir1/dir2", |
151 |
|
|
- archive_entry_pathname(ae)); |
152 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
153 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
154 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
155 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
156 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
157 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
158 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
159 |
|
|
- } else if (strcmp("dir1/dir2/dir3", |
160 |
|
|
- archive_entry_pathname(ae)) == 0) { |
161 |
|
|
- /* A directory. */ |
162 |
|
|
- assertEqualString("dir1/dir2/dir3", |
163 |
|
|
- archive_entry_pathname(ae)); |
164 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
165 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
166 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
167 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
168 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
169 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
170 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
171 |
|
|
- } else if (strcmp("dir1/dir2/dir3/dir4", |
172 |
|
|
- archive_entry_pathname(ae)) == 0) { |
173 |
|
|
- /* A directory. */ |
174 |
|
|
- assertEqualString("dir1/dir2/dir3/dir4", |
175 |
|
|
- archive_entry_pathname(ae)); |
176 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
177 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
178 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
179 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
180 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
181 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
182 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
183 |
|
|
- } else if (strcmp("dir1/dir2/dir3/dir4/dir5", |
184 |
|
|
- archive_entry_pathname(ae)) == 0) { |
185 |
|
|
- /* A directory. */ |
186 |
|
|
- assertEqualString("dir1/dir2/dir3/dir4/dir5", |
187 |
|
|
- archive_entry_pathname(ae)); |
188 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
189 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
190 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
191 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
192 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
193 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
194 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
195 |
|
|
- } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6", |
196 |
|
|
- archive_entry_pathname(ae)) == 0) { |
197 |
|
|
- /* A directory. */ |
198 |
|
|
- assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6", |
199 |
|
|
- archive_entry_pathname(ae)); |
200 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
201 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
202 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
203 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
204 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
205 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
206 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
207 |
|
|
- } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7", |
208 |
|
|
- archive_entry_pathname(ae)) == 0) { |
209 |
|
|
- /* A directory. */ |
210 |
|
|
- assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7", |
211 |
|
|
- archive_entry_pathname(ae)); |
212 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
213 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
214 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
215 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
216 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
217 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
218 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
219 |
|
|
- } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7" |
220 |
|
|
- "/dir8", |
221 |
|
|
- archive_entry_pathname(ae)) == 0) { |
222 |
|
|
- /* A directory. */ |
223 |
|
|
- assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7" |
224 |
|
|
- "/dir8", |
225 |
|
|
- archive_entry_pathname(ae)); |
226 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
227 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
228 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
229 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
230 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
231 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
232 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
233 |
|
|
- } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7" |
234 |
|
|
- "/dir8/dir9", |
235 |
|
|
- archive_entry_pathname(ae)) == 0) { |
236 |
|
|
- /* A directory. */ |
237 |
|
|
- assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7" |
238 |
|
|
- "/dir8/dir9", |
239 |
|
|
- archive_entry_pathname(ae)); |
240 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
241 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
242 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
243 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
244 |
|
|
- assertEqualInt(3, archive_entry_stat(ae)->st_nlink); |
245 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
246 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
247 |
|
|
- } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7" |
248 |
|
|
- "/dir8/dir9/dir10", |
249 |
|
|
- archive_entry_pathname(ae)) == 0) { |
250 |
|
|
- /* A directory. */ |
251 |
|
|
- assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7" |
252 |
|
|
- "/dir8/dir9/dir10", |
253 |
|
|
- archive_entry_pathname(ae)); |
254 |
|
|
- assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); |
255 |
|
|
- assertEqualInt(2048, archive_entry_size(ae)); |
256 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
257 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
258 |
|
|
- assertEqualInt(2, archive_entry_stat(ae)->st_nlink); |
259 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
260 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
261 |
|
|
- } else if (strcmp("file", archive_entry_pathname(ae)) == 0) { |
262 |
|
|
- /* A regular file. */ |
263 |
|
|
- assertEqualString("file", archive_entry_pathname(ae)); |
264 |
|
|
- assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); |
265 |
|
|
- assertEqualInt(12345684, archive_entry_size(ae)); |
266 |
|
|
- assertEqualInt(0, |
267 |
|
|
- archive_read_data_block(a, &p, &size, &offset)); |
268 |
|
|
- assertEqualInt(0, offset); |
269 |
|
|
- assertEqualMem(p, "hello\n", 6); |
270 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
271 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
272 |
|
|
- assertEqualInt(1, archive_entry_stat(ae)->st_nlink); |
273 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
274 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
275 |
|
|
- } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7" |
276 |
|
|
- "/dir8/dir9/dir10/deep", |
277 |
|
|
- archive_entry_pathname(ae)) == 0) { |
278 |
|
|
- /* A regular file. */ |
279 |
|
|
- assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7" |
280 |
|
|
- "/dir8/dir9/dir10/deep", |
281 |
|
|
- archive_entry_pathname(ae)); |
282 |
|
|
- assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); |
283 |
|
|
- assertEqualInt(12345684, archive_entry_size(ae)); |
284 |
|
|
- assertEqualInt(0, |
285 |
|
|
- archive_read_data_block(a, &p, &size, &offset)); |
286 |
|
|
- assertEqualInt(0, offset); |
287 |
|
|
- assertEqualMem(p, "hello\n", 6); |
288 |
|
|
- assertEqualInt(86401, archive_entry_mtime(ae)); |
289 |
|
|
- assertEqualInt(86401, archive_entry_atime(ae)); |
290 |
|
|
- assertEqualInt(1, archive_entry_stat(ae)->st_nlink); |
291 |
|
|
- assertEqualInt(1, archive_entry_uid(ae)); |
292 |
|
|
- assertEqualInt(2, archive_entry_gid(ae)); |
293 |
|
|
- } else { |
294 |
|
|
- failure("Saw a file that shouldn't have been there"); |
295 |
|
|
- assertEqualString(archive_entry_pathname(ae), ""); |
296 |
|
|
- } |
297 |
|
|
- } |
298 |
|
|
- |
299 |
|
|
- /* End of archive. */ |
300 |
|
|
- assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae)); |
301 |
|
|
- |
302 |
|
|
- /* Verify archive format. */ |
303 |
|
|
- assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS); |
304 |
|
|
- assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE); |
305 |
|
|
- |
306 |
|
|
- /* Close the archive. */ |
307 |
|
|
- assertEqualInt(0, archive_read_close(a)); |
308 |
|
|
- assertEqualInt(0, archive_read_finish(a)); |
309 |
|
|
-} |
310 |
|
|
- |
311 |
|
|
- |
312 |
|
|
diff --git a/libarchive/test/test_read_format_tz.c b/libarchive/test/test_read_format_tz.c |
313 |
|
|
deleted file mode 100644 |
314 |
|
|
index eb06601..0000000 |
315 |
|
|
--- a/libarchive/test/test_read_format_tz.c |
316 |
|
|
+++ /dev/null |
317 |
|
|
@@ -1,61 +0,0 @@ |
318 |
|
|
-/*- |
319 |
|
|
- * Copyright (c) 2003-2007 Tim Kientzle |
320 |
|
|
- * All rights reserved. |
321 |
|
|
- * |
322 |
|
|
- * Redistribution and use in source and binary forms, with or without |
323 |
|
|
- * modification, are permitted provided that the following conditions |
324 |
|
|
- * are met: |
325 |
|
|
- * 1. Redistributions of source code must retain the above copyright |
326 |
|
|
- * notice, this list of conditions and the following disclaimer. |
327 |
|
|
- * 2. Redistributions in binary form must reproduce the above copyright |
328 |
|
|
- * notice, this list of conditions and the following disclaimer in the |
329 |
|
|
- * documentation and/or other materials provided with the distribution. |
330 |
|
|
- * |
331 |
|
|
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR |
332 |
|
|
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
333 |
|
|
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
334 |
|
|
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, |
335 |
|
|
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
336 |
|
|
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
337 |
|
|
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
338 |
|
|
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
339 |
|
|
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
340 |
|
|
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
341 |
|
|
- */ |
342 |
|
|
-#include "test.h" |
343 |
|
|
-__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tz.c 189381 2009-03-05 00:31:48Z kientzle $"); |
344 |
|
|
- |
345 |
|
|
-static unsigned char archive[] = { |
346 |
|
|
-31,157,144,'.',0,8,28,'H',176,160,193,131,8,19,'*','\\',200,176,'!','B',24, |
347 |
|
|
-16,'o',212,168,1,2,0,196,24,18,'a','T',188,152,'q','#',196,143,' ','5',198, |
348 |
|
|
-128,'1','c',6,13,24,'4','0',206,176,1,2,198,200,26,'6','b',0,0,'Q',195,161, |
349 |
|
|
-205,155,'8','s',234,4,'P','g',14,157,'0','r',',',194,160,147,166,205,206, |
350 |
|
|
-132,'D',141,30,'=',24,'R',163,'P',144,21,151,'J',157,'J',181,170,213,171, |
351 |
|
|
-'X',179,'j',221,202,181,171,215,175,'`',195,138,29,'K',182,172,217,179,'h', |
352 |
|
|
-211,170,']',203,182,173,219,183,'g',1}; |
353 |
|
|
- |
354 |
|
|
-DEFINE_TEST(test_read_format_tz) |
355 |
|
|
-{ |
356 |
|
|
- struct archive_entry *ae; |
357 |
|
|
- struct archive *a; |
358 |
|
|
- assert((a = archive_read_new()) != NULL); |
359 |
|
|
- assertEqualIntA(a, ARCHIVE_OK, |
360 |
|
|
- archive_read_support_compression_all(a)); |
361 |
|
|
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); |
362 |
|
|
- assertEqualIntA(a, ARCHIVE_OK, |
363 |
|
|
- archive_read_open_memory(a, archive, sizeof(archive))); |
364 |
|
|
- assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); |
365 |
|
|
- failure("archive_compression_name(a)=\"%s\"", |
366 |
|
|
- archive_compression_name(a)); |
367 |
|
|
- assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS); |
368 |
|
|
- failure("archive_format_name(a)=\"%s\"", archive_format_name(a)); |
369 |
|
|
- assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); |
370 |
|
|
- assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); |
371 |
|
|
-#if ARCHIVE_VERSION_NUMBER < 2000000 |
372 |
|
|
- archive_read_finish(a); |
373 |
|
|
-#else |
374 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); |
375 |
|
|
-#endif |
376 |
|
|
-} |
377 |
|
|
- |
378 |
|
|
- |
379 |
|
|
diff --git a/libarchive/test/test_write_disk.c b/libarchive/test/test_write_disk.c |
380 |
|
|
deleted file mode 100644 |
381 |
|
|
index 169f4f2..0000000 |
382 |
|
|
--- a/libarchive/test/test_write_disk.c |
383 |
|
|
+++ /dev/null |
384 |
|
|
@@ -1,332 +0,0 @@ |
385 |
|
|
-/*- |
386 |
|
|
- * Copyright (c) 2003-2007 Tim Kientzle |
387 |
|
|
- * All rights reserved. |
388 |
|
|
- * |
389 |
|
|
- * Redistribution and use in source and binary forms, with or without |
390 |
|
|
- * modification, are permitted provided that the following conditions |
391 |
|
|
- * are met: |
392 |
|
|
- * 1. Redistributions of source code must retain the above copyright |
393 |
|
|
- * notice, this list of conditions and the following disclaimer. |
394 |
|
|
- * 2. Redistributions in binary form must reproduce the above copyright |
395 |
|
|
- * notice, this list of conditions and the following disclaimer in the |
396 |
|
|
- * documentation and/or other materials provided with the distribution. |
397 |
|
|
- * |
398 |
|
|
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR |
399 |
|
|
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
400 |
|
|
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
401 |
|
|
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, |
402 |
|
|
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
403 |
|
|
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
404 |
|
|
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
405 |
|
|
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
406 |
|
|
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
407 |
|
|
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
408 |
|
|
- */ |
409 |
|
|
-#include "test.h" |
410 |
|
|
-__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk.c 201247 2009-12-30 05:59:21Z kientzle $"); |
411 |
|
|
- |
412 |
|
|
-#if ARCHIVE_VERSION_NUMBER >= 1009000 |
413 |
|
|
- |
414 |
|
|
-#define UMASK 022 |
415 |
|
|
-/* |
416 |
|
|
- * When comparing mode values, ignore high-order bits |
417 |
|
|
- * that are set on some OSes. This should cover the bits |
418 |
|
|
- * we're interested in (standard mode bits + file type bits) |
419 |
|
|
- * while ignoring extra markers such as Haiku/BeOS index |
420 |
|
|
- * flags. |
421 |
|
|
- */ |
422 |
|
|
-#define MODE_MASK 0777777 |
423 |
|
|
- |
424 |
|
|
-static void create(struct archive_entry *ae, const char *msg) |
425 |
|
|
-{ |
426 |
|
|
- struct archive *ad; |
427 |
|
|
- struct stat st; |
428 |
|
|
- |
429 |
|
|
- /* Write the entry to disk. */ |
430 |
|
|
- assert((ad = archive_write_disk_new()) != NULL); |
431 |
|
|
- failure("%s", msg); |
432 |
|
|
- assertEqualIntA(ad, 0, archive_write_header(ad, ae)); |
433 |
|
|
- assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); |
434 |
|
|
-#if ARCHIVE_VERSION_NUMBER < 2000000 |
435 |
|
|
- archive_write_finish(ad); |
436 |
|
|
-#else |
437 |
|
|
- assertEqualInt(0, archive_write_finish(ad)); |
438 |
|
|
-#endif |
439 |
|
|
- /* Test the entries on disk. */ |
440 |
|
|
- assert(0 == stat(archive_entry_pathname(ae), &st)); |
441 |
|
|
- failure("%s", msg); |
442 |
|
|
- |
443 |
|
|
-#if !defined(_WIN32) || defined(__CYGWIN__) |
444 |
|
|
- /* When verifying a dir, ignore the S_ISGID bit, as some systems set |
445 |
|
|
- * that automatically. */ |
446 |
|
|
- if (archive_entry_filetype(ae) == AE_IFDIR) |
447 |
|
|
- st.st_mode &= ~S_ISGID; |
448 |
|
|
- assertEqualInt(st.st_mode & MODE_MASK, |
449 |
|
|
- archive_entry_mode(ae) & ~UMASK & MODE_MASK); |
450 |
|
|
-#endif |
451 |
|
|
-} |
452 |
|
|
- |
453 |
|
|
-static void create_reg_file(struct archive_entry *ae, const char *msg) |
454 |
|
|
-{ |
455 |
|
|
- static const char data[]="abcdefghijklmnopqrstuvwxyz"; |
456 |
|
|
- struct archive *ad; |
457 |
|
|
- |
458 |
|
|
- /* Write the entry to disk. */ |
459 |
|
|
- assert((ad = archive_write_disk_new()) != NULL); |
460 |
|
|
- archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME); |
461 |
|
|
- failure("%s", msg); |
462 |
|
|
- /* |
463 |
|
|
- * A touchy API design issue: archive_write_data() does (as of |
464 |
|
|
- * 2.4.12) enforce the entry size as a limit on the data |
465 |
|
|
- * written to the file. This was not enforced prior to |
466 |
|
|
- * 2.4.12. The change was prompted by the refined |
467 |
|
|
- * hardlink-restore semantics introduced at that time. In |
468 |
|
|
- * short, libarchive needs to know whether a "hardlink entry" |
469 |
|
|
- * is going to overwrite the contents so that it can know |
470 |
|
|
- * whether or not to open the file for writing. This implies |
471 |
|
|
- * that there is a fundamental semantic difference between an |
472 |
|
|
- * entry with a zero size and one with a non-zero size in the |
473 |
|
|
- * case of hardlinks and treating the hardlink case |
474 |
|
|
- * differently from the regular file case is just asking for |
475 |
|
|
- * trouble. So, a zero size must always mean that no data |
476 |
|
|
- * will be accepted, which is consistent with the file size in |
477 |
|
|
- * the entry being a maximum size. |
478 |
|
|
- */ |
479 |
|
|
- archive_entry_set_size(ae, sizeof(data)); |
480 |
|
|
- archive_entry_set_mtime(ae, 123456789, 0); |
481 |
|
|
- assertEqualIntA(ad, 0, archive_write_header(ad, ae)); |
482 |
|
|
- assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data))); |
483 |
|
|
- assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); |
484 |
|
|
-#if ARCHIVE_VERSION_NUMBER < 2000000 |
485 |
|
|
- archive_write_finish(ad); |
486 |
|
|
-#else |
487 |
|
|
- assertEqualInt(0, archive_write_finish(ad)); |
488 |
|
|
-#endif |
489 |
|
|
- /* Test the entries on disk. */ |
490 |
|
|
- assertIsReg(archive_entry_pathname(ae), archive_entry_mode(ae) & 0777); |
491 |
|
|
- assertFileSize(archive_entry_pathname(ae), sizeof(data)); |
492 |
|
|
- /* test_write_disk_times has more detailed tests of this area. */ |
493 |
|
|
- assertFileMtime(archive_entry_pathname(ae), 123456789, 0); |
494 |
|
|
- failure("No atime given, so atime should get set to current time"); |
495 |
|
|
- assertFileAtimeRecent(archive_entry_pathname(ae)); |
496 |
|
|
-} |
497 |
|
|
- |
498 |
|
|
-static void create_reg_file2(struct archive_entry *ae, const char *msg) |
499 |
|
|
-{ |
500 |
|
|
- const int datasize = 100000; |
501 |
|
|
- char *data; |
502 |
|
|
- struct archive *ad; |
503 |
|
|
- int i; |
504 |
|
|
- |
505 |
|
|
- data = malloc(datasize); |
506 |
|
|
- for (i = 0; i < datasize; i++) |
507 |
|
|
- data[i] = (char)(i % 256); |
508 |
|
|
- |
509 |
|
|
- /* Write the entry to disk. */ |
510 |
|
|
- assert((ad = archive_write_disk_new()) != NULL); |
511 |
|
|
- failure("%s", msg); |
512 |
|
|
- /* |
513 |
|
|
- * See above for an explanation why this next call |
514 |
|
|
- * is necessary. |
515 |
|
|
- */ |
516 |
|
|
- archive_entry_set_size(ae, datasize); |
517 |
|
|
- assertEqualIntA(ad, 0, archive_write_header(ad, ae)); |
518 |
|
|
- for (i = 0; i < datasize - 999; i += 1000) { |
519 |
|
|
- assertEqualIntA(ad, ARCHIVE_OK, |
520 |
|
|
- archive_write_data_block(ad, data + i, 1000, i)); |
521 |
|
|
- } |
522 |
|
|
- assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); |
523 |
|
|
- assertEqualInt(0, archive_write_finish(ad)); |
524 |
|
|
- |
525 |
|
|
- /* Test the entries on disk. */ |
526 |
|
|
- assertIsReg(archive_entry_pathname(ae), archive_entry_mode(ae) & 0777); |
527 |
|
|
- assertFileSize(archive_entry_pathname(ae), i); |
528 |
|
|
- assertFileContents(data, datasize, archive_entry_pathname(ae)); |
529 |
|
|
- free(data); |
530 |
|
|
-} |
531 |
|
|
- |
532 |
|
|
-static void create_reg_file3(struct archive_entry *ae, const char *msg) |
533 |
|
|
-{ |
534 |
|
|
- static const char data[]="abcdefghijklmnopqrstuvwxyz"; |
535 |
|
|
- struct archive *ad; |
536 |
|
|
- struct stat st; |
537 |
|
|
- |
538 |
|
|
- /* Write the entry to disk. */ |
539 |
|
|
- assert((ad = archive_write_disk_new()) != NULL); |
540 |
|
|
- failure("%s", msg); |
541 |
|
|
- /* Set the size smaller than the data and verify the truncation. */ |
542 |
|
|
- archive_entry_set_size(ae, 5); |
543 |
|
|
- assertEqualIntA(ad, 0, archive_write_header(ad, ae)); |
544 |
|
|
- assertEqualInt(5, archive_write_data(ad, data, sizeof(data))); |
545 |
|
|
- assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); |
546 |
|
|
-#if ARCHIVE_VERSION_NUMBER < 2000000 |
547 |
|
|
- archive_write_finish(ad); |
548 |
|
|
-#else |
549 |
|
|
- assertEqualInt(0, archive_write_finish(ad)); |
550 |
|
|
-#endif |
551 |
|
|
- /* Test the entry on disk. */ |
552 |
|
|
- assert(0 == stat(archive_entry_pathname(ae), &st)); |
553 |
|
|
- failure("st.st_mode=%o archive_entry_mode(ae)=%o", |
554 |
|
|
- st.st_mode, archive_entry_mode(ae)); |
555 |
|
|
-#if !defined(_WIN32) || defined(__CYGWIN__) |
556 |
|
|
- assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); |
557 |
|
|
-#endif |
558 |
|
|
- assertEqualInt(st.st_size, 5); |
559 |
|
|
-} |
560 |
|
|
- |
561 |
|
|
- |
562 |
|
|
-static void create_reg_file4(struct archive_entry *ae, const char *msg) |
563 |
|
|
-{ |
564 |
|
|
- static const char data[]="abcdefghijklmnopqrstuvwxyz"; |
565 |
|
|
- struct archive *ad; |
566 |
|
|
- struct stat st; |
567 |
|
|
- |
568 |
|
|
- /* Write the entry to disk. */ |
569 |
|
|
- assert((ad = archive_write_disk_new()) != NULL); |
570 |
|
|
- /* Leave the size unset. The data should not be truncated. */ |
571 |
|
|
- assertEqualIntA(ad, 0, archive_write_header(ad, ae)); |
572 |
|
|
- assertEqualInt(ARCHIVE_OK, |
573 |
|
|
- archive_write_data_block(ad, data, sizeof(data), 0)); |
574 |
|
|
- assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); |
575 |
|
|
-#if ARCHIVE_VERSION_NUMBER < 2000000 |
576 |
|
|
- archive_write_finish(ad); |
577 |
|
|
-#else |
578 |
|
|
- assertEqualInt(0, archive_write_finish(ad)); |
579 |
|
|
-#endif |
580 |
|
|
- /* Test the entry on disk. */ |
581 |
|
|
- assert(0 == stat(archive_entry_pathname(ae), &st)); |
582 |
|
|
- failure("st.st_mode=%o archive_entry_mode(ae)=%o", |
583 |
|
|
- st.st_mode, archive_entry_mode(ae)); |
584 |
|
|
-#if !defined(_WIN32) || defined(__CYGWIN__) |
585 |
|
|
- assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); |
586 |
|
|
-#endif |
587 |
|
|
- failure(msg); |
588 |
|
|
- assertEqualInt(st.st_size, sizeof(data)); |
589 |
|
|
-} |
590 |
|
|
- |
591 |
|
|
-#if defined(_WIN32) && !defined(__CYGWIN__) |
592 |
|
|
-static void create_reg_file_win(struct archive_entry *ae, const char *msg) |
593 |
|
|
-{ |
594 |
|
|
- static const char data[]="abcdefghijklmnopqrstuvwxyz"; |
595 |
|
|
- struct archive *ad; |
596 |
|
|
- struct stat st; |
597 |
|
|
- char *p, *fname; |
598 |
|
|
- size_t l; |
599 |
|
|
- |
600 |
|
|
- /* Write the entry to disk. */ |
601 |
|
|
- assert((ad = archive_write_disk_new()) != NULL); |
602 |
|
|
- archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME); |
603 |
|
|
- failure("%s", msg); |
604 |
|
|
- archive_entry_set_size(ae, sizeof(data)); |
605 |
|
|
- archive_entry_set_mtime(ae, 123456789, 0); |
606 |
|
|
- assertEqualIntA(ad, 0, archive_write_header(ad, ae)); |
607 |
|
|
- assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data))); |
608 |
|
|
- assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); |
609 |
|
|
-#if ARCHIVE_VERSION_NUMBER < 2000000 |
610 |
|
|
- archive_write_finish(ad); |
611 |
|
|
-#else |
612 |
|
|
- assertEqualInt(0, archive_write_finish(ad)); |
613 |
|
|
-#endif |
614 |
|
|
- /* Test the entries on disk. */ |
615 |
|
|
- l = strlen(archive_entry_pathname(ae)); |
616 |
|
|
- fname = malloc(l + 1); |
617 |
|
|
- assert(NULL != fname); |
618 |
|
|
- strcpy(fname, archive_entry_pathname(ae)); |
619 |
|
|
- /* Replace unusable characters in Windows to '_' */ |
620 |
|
|
- for (p = fname; *p != '\0'; p++) |
621 |
|
|
- if (*p == ':' || *p == '*' || *p == '?' || |
622 |
|
|
- *p == '"' || *p == '<' || *p == '>' || *p == '|') |
623 |
|
|
- *p = '_'; |
624 |
|
|
- assert(0 == stat(fname, &st)); |
625 |
|
|
- failure("st.st_mode=%o archive_entry_mode(ae)=%o", |
626 |
|
|
- st.st_mode, archive_entry_mode(ae)); |
627 |
|
|
- assertEqualInt(st.st_size, sizeof(data)); |
628 |
|
|
-} |
629 |
|
|
-#endif /* _WIN32 && !__CYGWIN__ */ |
630 |
|
|
-#endif |
631 |
|
|
- |
632 |
|
|
-DEFINE_TEST(test_write_disk) |
633 |
|
|
-{ |
634 |
|
|
-#if ARCHIVE_VERSION_NUMBER < 1009000 |
635 |
|
|
- skipping("archive_write_disk interface"); |
636 |
|
|
-#else |
637 |
|
|
- struct archive_entry *ae; |
638 |
|
|
- |
639 |
|
|
- /* Force the umask to something predictable. */ |
640 |
|
|
- assertUmask(UMASK); |
641 |
|
|
- |
642 |
|
|
- /* A regular file. */ |
643 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
644 |
|
|
- archive_entry_copy_pathname(ae, "file"); |
645 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0755); |
646 |
|
|
- create_reg_file(ae, "Test creating a regular file"); |
647 |
|
|
- archive_entry_free(ae); |
648 |
|
|
- |
649 |
|
|
- /* Another regular file. */ |
650 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
651 |
|
|
- archive_entry_copy_pathname(ae, "file2"); |
652 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0755); |
653 |
|
|
- create_reg_file2(ae, "Test creating another regular file"); |
654 |
|
|
- archive_entry_free(ae); |
655 |
|
|
- |
656 |
|
|
- /* A regular file with a size restriction */ |
657 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
658 |
|
|
- archive_entry_copy_pathname(ae, "file3"); |
659 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0755); |
660 |
|
|
- create_reg_file3(ae, "Regular file with size restriction"); |
661 |
|
|
- archive_entry_free(ae); |
662 |
|
|
- |
663 |
|
|
- /* A regular file with an unspecified size */ |
664 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
665 |
|
|
- archive_entry_copy_pathname(ae, "file3"); |
666 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0755); |
667 |
|
|
- create_reg_file4(ae, "Regular file with unspecified size"); |
668 |
|
|
- archive_entry_free(ae); |
669 |
|
|
- |
670 |
|
|
- /* A regular file over an existing file */ |
671 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
672 |
|
|
- archive_entry_copy_pathname(ae, "file"); |
673 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0724); |
674 |
|
|
- create(ae, "Test creating a file over an existing file."); |
675 |
|
|
- archive_entry_free(ae); |
676 |
|
|
- |
677 |
|
|
- /* A directory. */ |
678 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
679 |
|
|
- archive_entry_copy_pathname(ae, "dir"); |
680 |
|
|
- archive_entry_set_mode(ae, S_IFDIR | 0555); |
681 |
|
|
- create(ae, "Test creating a regular dir."); |
682 |
|
|
- archive_entry_free(ae); |
683 |
|
|
- |
684 |
|
|
- /* A directory over an existing file. */ |
685 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
686 |
|
|
- archive_entry_copy_pathname(ae, "file"); |
687 |
|
|
- archive_entry_set_mode(ae, S_IFDIR | 0742); |
688 |
|
|
- create(ae, "Test creating a dir over an existing file."); |
689 |
|
|
- archive_entry_free(ae); |
690 |
|
|
- |
691 |
|
|
- /* A file over an existing dir. */ |
692 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
693 |
|
|
- archive_entry_copy_pathname(ae, "file"); |
694 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0744); |
695 |
|
|
- create(ae, "Test creating a file over an existing dir."); |
696 |
|
|
- archive_entry_free(ae); |
697 |
|
|
- |
698 |
|
|
-#if defined(_WIN32) && !defined(__CYGWIN__) |
699 |
|
|
- /* A file with unusable characters in its file name. */ |
700 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
701 |
|
|
- archive_entry_copy_pathname(ae, "f:i*l?e\"f<i>l|e"); |
702 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0755); |
703 |
|
|
- create_reg_file_win(ae, "Test creating a regular file" |
704 |
|
|
- " with unusable characters in its file name"); |
705 |
|
|
- archive_entry_free(ae); |
706 |
|
|
- |
707 |
|
|
- /* A file with unusable characters in its directory name. */ |
708 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
709 |
|
|
- archive_entry_copy_pathname(ae, "d:i*r?e\"c<t>o|ry/file1"); |
710 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0755); |
711 |
|
|
- create_reg_file_win(ae, "Test creating a regular file" |
712 |
|
|
- " with unusable characters in its file name"); |
713 |
|
|
- archive_entry_free(ae); |
714 |
|
|
-#endif /* _WIN32 && !__CYGWIN__ */ |
715 |
|
|
-#endif |
716 |
|
|
-} |
717 |
|
|
diff --git a/libarchive/test/test_write_disk_times.c b/libarchive/test/test_write_disk_times.c |
718 |
|
|
deleted file mode 100644 |
719 |
|
|
index 9ecbff6..0000000 |
720 |
|
|
--- a/libarchive/test/test_write_disk_times.c |
721 |
|
|
+++ /dev/null |
722 |
|
|
@@ -1,167 +0,0 @@ |
723 |
|
|
-/*- |
724 |
|
|
- * Copyright (c) 2003-2008 Tim Kientzle |
725 |
|
|
- * All rights reserved. |
726 |
|
|
- * |
727 |
|
|
- * Redistribution and use in source and binary forms, with or without |
728 |
|
|
- * modification, are permitted provided that the following conditions |
729 |
|
|
- * are met: |
730 |
|
|
- * 1. Redistributions of source code must retain the above copyright |
731 |
|
|
- * notice, this list of conditions and the following disclaimer. |
732 |
|
|
- * 2. Redistributions in binary form must reproduce the above copyright |
733 |
|
|
- * notice, this list of conditions and the following disclaimer in the |
734 |
|
|
- * documentation and/or other materials provided with the distribution. |
735 |
|
|
- * |
736 |
|
|
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR |
737 |
|
|
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
738 |
|
|
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
739 |
|
|
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, |
740 |
|
|
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
741 |
|
|
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
742 |
|
|
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
743 |
|
|
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
744 |
|
|
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
745 |
|
|
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
746 |
|
|
- */ |
747 |
|
|
-#include "test.h" |
748 |
|
|
-__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_times.c 201247 2009-12-30 05:59:21Z kientzle $"); |
749 |
|
|
- |
750 |
|
|
-/* |
751 |
|
|
- * Exercise time restores in archive_write_disk(), including |
752 |
|
|
- * correct handling of omitted time values. |
753 |
|
|
- * On FreeBSD, we also test birthtime and high-res time restores. |
754 |
|
|
- */ |
755 |
|
|
- |
756 |
|
|
-DEFINE_TEST(test_write_disk_times) |
757 |
|
|
-{ |
758 |
|
|
- struct archive *a; |
759 |
|
|
- struct archive_entry *ae; |
760 |
|
|
- |
761 |
|
|
- /* Create an archive_write_disk object. */ |
762 |
|
|
- assert((a = archive_write_disk_new()) != NULL); |
763 |
|
|
- assertEqualInt(ARCHIVE_OK, |
764 |
|
|
- archive_write_disk_set_options(a, ARCHIVE_EXTRACT_TIME)); |
765 |
|
|
- |
766 |
|
|
- /* |
767 |
|
|
- * Easy case: mtime and atime both specified. |
768 |
|
|
- */ |
769 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
770 |
|
|
- archive_entry_copy_pathname(ae, "file1"); |
771 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0777); |
772 |
|
|
- archive_entry_set_atime(ae, 123456, 0); |
773 |
|
|
- archive_entry_set_mtime(ae, 234567, 0); |
774 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae)); |
775 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a)); |
776 |
|
|
- archive_entry_free(ae); |
777 |
|
|
- /* Verify */ |
778 |
|
|
- assertFileAtime("file1", 123456, 0); |
779 |
|
|
- assertFileMtime("file1", 234567, 0); |
780 |
|
|
- |
781 |
|
|
- /* |
782 |
|
|
- * mtime specified, but not atime |
783 |
|
|
- */ |
784 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
785 |
|
|
- archive_entry_copy_pathname(ae, "file2"); |
786 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0777); |
787 |
|
|
- archive_entry_set_mtime(ae, 234567, 0); |
788 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae)); |
789 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a)); |
790 |
|
|
- archive_entry_free(ae); |
791 |
|
|
- assertFileMtime("file2", 234567, 0); |
792 |
|
|
- assertFileAtimeRecent("file2"); |
793 |
|
|
- |
794 |
|
|
- /* |
795 |
|
|
- * atime specified, but not mtime |
796 |
|
|
- */ |
797 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
798 |
|
|
- archive_entry_copy_pathname(ae, "file3"); |
799 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0777); |
800 |
|
|
- archive_entry_set_atime(ae, 345678, 0); |
801 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae)); |
802 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a)); |
803 |
|
|
- archive_entry_free(ae); |
804 |
|
|
- /* Verify: Current mtime and atime as specified. */ |
805 |
|
|
- assertFileAtime("file3", 345678, 0); |
806 |
|
|
- assertFileMtimeRecent("file3"); |
807 |
|
|
- |
808 |
|
|
- /* |
809 |
|
|
- * Neither atime nor mtime specified. |
810 |
|
|
- */ |
811 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
812 |
|
|
- archive_entry_copy_pathname(ae, "file4"); |
813 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0777); |
814 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae)); |
815 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a)); |
816 |
|
|
- archive_entry_free(ae); |
817 |
|
|
- /* Verify: Current mtime and atime. */ |
818 |
|
|
- assertFileAtimeRecent("file4"); |
819 |
|
|
- assertFileMtimeRecent("file4"); |
820 |
|
|
- |
821 |
|
|
-#if defined(__FreeBSD__) |
822 |
|
|
- /* |
823 |
|
|
- * High-res mtime and atime on FreeBSD. |
824 |
|
|
- */ |
825 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
826 |
|
|
- archive_entry_copy_pathname(ae, "file10"); |
827 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0777); |
828 |
|
|
- archive_entry_set_atime(ae, 1234567, 23456); |
829 |
|
|
- archive_entry_set_mtime(ae, 2345678, 4567); |
830 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae)); |
831 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a)); |
832 |
|
|
- archive_entry_free(ae); |
833 |
|
|
- /* Verify */ |
834 |
|
|
- assertFileMtime("file10", 2345678, 4567); |
835 |
|
|
- assertFileAtime("file10", 1234567, 23456); |
836 |
|
|
- |
837 |
|
|
- /* |
838 |
|
|
- * Birthtime, mtime and atime on FreeBSD |
839 |
|
|
- */ |
840 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
841 |
|
|
- archive_entry_copy_pathname(ae, "file11"); |
842 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0777); |
843 |
|
|
- archive_entry_set_atime(ae, 1234567, 23456); |
844 |
|
|
- archive_entry_set_birthtime(ae, 3456789, 12345); |
845 |
|
|
- /* mtime must be later than birthtime! */ |
846 |
|
|
- archive_entry_set_mtime(ae, 12345678, 4567); |
847 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae)); |
848 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a)); |
849 |
|
|
- archive_entry_free(ae); |
850 |
|
|
- /* Verify */ |
851 |
|
|
- assertFileAtime("file11", 1234567, 23456); |
852 |
|
|
- assertFileBirthtime("file11", 3456789, 12345); |
853 |
|
|
- assertFileMtime("file11", 12345678, 4567); |
854 |
|
|
- |
855 |
|
|
- /* |
856 |
|
|
- * Birthtime only on FreeBSD. |
857 |
|
|
- */ |
858 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
859 |
|
|
- archive_entry_copy_pathname(ae, "file12"); |
860 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0777); |
861 |
|
|
- archive_entry_set_birthtime(ae, 3456789, 12345); |
862 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae)); |
863 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a)); |
864 |
|
|
- archive_entry_free(ae); |
865 |
|
|
- /* Verify */ |
866 |
|
|
- assertFileAtimeRecent("file12"); |
867 |
|
|
- assertFileBirthtime("file12", 3456789, 12345); |
868 |
|
|
- assertFileMtimeRecent("file12"); |
869 |
|
|
- |
870 |
|
|
- /* |
871 |
|
|
- * mtime only on FreeBSD. |
872 |
|
|
- */ |
873 |
|
|
- assert((ae = archive_entry_new()) != NULL); |
874 |
|
|
- archive_entry_copy_pathname(ae, "file13"); |
875 |
|
|
- archive_entry_set_mode(ae, S_IFREG | 0777); |
876 |
|
|
- archive_entry_set_mtime(ae, 4567890, 23456); |
877 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae)); |
878 |
|
|
- assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a)); |
879 |
|
|
- archive_entry_free(ae); |
880 |
|
|
- /* Verify */ |
881 |
|
|
- assertFileAtimeRecent("file13"); |
882 |
|
|
- assertFileBirthtime("file13", 4567890, 23456); |
883 |
|
|
- assertFileMtime("file13", 4567890, 23456); |
884 |
|
|
-#else |
885 |
|
|
- skipping("Platform-specific time restore tests"); |
886 |
|
|
-#endif |
887 |
|
|
- |
888 |
|
|
- archive_write_finish(a); |
889 |
|
|
-} |