2
* Copyright (c) 2003-2007 Tim Kientzle
3
* Copyright (c) 2009 Michihiro NAKAJIMA
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
15
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_isorr_ce.c 201247 2009-12-30 05:59:21Z kientzle $");
30
Execute the following command to rebuild the data for this program:
31
tail -n +32 test_read_format_isorr_ce.c | /bin/sh
40
while [ $num -lt 150 ]
51
echo "hello $((num+150))" > $dirname/$file
52
dd if=/dev/zero count=1 bs=4080 >> $dirname/$file
53
(cd $dirname; ln -s $file sym$num)
58
time1="197001020000.01"
59
time2="197001030000.02"
60
TZ=utc touch -afhm -t $time1 $dirname/dir $dirname/aaaa*
61
TZ=utc touch -afhm -t $time2 $dirname/sym*
62
TZ=utc touch -afhm -t $time1 $dirname
64
F=test_read_format_iso_rockridge_ce.iso.Z
65
mkisofs -R -uid 1 -gid 2 $dirname | compress > $F
66
uuencode $F $F > $F.uu
72
* Test reading SUSP "CE" extension is works fine.
76
mkpath(char *p, int len)
80
for (i = 0; i < len; i++)
85
DEFINE_TEST(test_read_format_isorr_ce)
87
const char *refname = "test_read_format_iso_rockridge_ce.iso.Z";
91
struct archive_entry *ae;
101
extract_reference_file(refname);
102
assert((a = archive_read_new()) != NULL);
103
assertEqualInt(0, archive_read_support_compression_all(a));
104
assertEqualInt(0, archive_read_support_format_all(a));
105
assertEqualInt(ARCHIVE_OK,
106
archive_read_open_filename(a, refname, 10240));
108
/* Retrieve each of the 8 files on the ISO image and
109
* verify that each one is what we expect. */
110
for (i = 0; i < 8; ++i) {
111
assertEqualInt(0, archive_read_next_header(a, &ae));
113
if (strcmp(".", archive_entry_pathname(ae)) == 0) {
114
/* '.' root directory. */
115
assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
116
assertEqualInt(2048, archive_entry_size(ae));
117
/* Now, we read timestamp recorded by RRIP "TF". */
118
assertEqualInt(86401, archive_entry_mtime(ae));
119
assertEqualInt(0, archive_entry_mtime_nsec(ae));
120
/* Now, we read links recorded by RRIP "PX". */
121
assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
122
assertEqualInt(1, archive_entry_uid(ae));
123
assertEqualIntA(a, ARCHIVE_EOF,
124
archive_read_data_block(a, &p, &size, &offset));
125
assertEqualInt((int)size, 0);
126
} else if (strcmp("dir", archive_entry_pathname(ae)) == 0) {
128
assertEqualString("dir", archive_entry_pathname(ae));
129
assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
130
assertEqualInt(2048, archive_entry_size(ae));
131
assertEqualInt(86401, archive_entry_mtime(ae));
132
assertEqualInt(86401, archive_entry_atime(ae));
133
assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
134
assertEqualInt(1, archive_entry_uid(ae));
135
assertEqualInt(2, archive_entry_gid(ae));
136
} else if (strcmp(path1, archive_entry_pathname(ae)) == 0) {
137
/* A regular file. */
138
assertEqualString(path1, archive_entry_pathname(ae));
139
assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
140
assertEqualInt(4090, archive_entry_size(ae));
142
archive_read_data_block(a, &p, &size, &offset));
143
assertEqualInt(0, offset);
144
assertEqualMem(p, "hello 151\n", 10);
145
assertEqualInt(86401, archive_entry_mtime(ae));
146
assertEqualInt(86401, archive_entry_atime(ae));
147
assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
148
assertEqualInt(1, archive_entry_uid(ae));
149
assertEqualInt(2, archive_entry_gid(ae));
150
} else if (strcmp(path2, archive_entry_pathname(ae)) == 0) {
151
/* A regular file. */
152
assertEqualString(path2, archive_entry_pathname(ae));
153
assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
154
assertEqualInt(4090, archive_entry_size(ae));
156
archive_read_data_block(a, &p, &size, &offset));
157
assertEqualInt(0, offset);
158
assertEqualMem(p, "hello 152\n", 10);
159
assertEqualInt(86401, archive_entry_mtime(ae));
160
assertEqualInt(86401, archive_entry_atime(ae));
161
assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
162
assertEqualInt(1, archive_entry_uid(ae));
163
assertEqualInt(2, archive_entry_gid(ae));
164
} else if (strcmp(path3, archive_entry_pathname(ae)) == 0) {
165
/* A regular file. */
166
assertEqualString(path3, archive_entry_pathname(ae));
167
assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
168
assertEqualInt(4090, archive_entry_size(ae));
170
archive_read_data_block(a, &p, &size, &offset));
171
assertEqualInt(0, offset);
172
assertEqualMem(p, "hello 153\n", 10);
173
assertEqualInt(86401, archive_entry_mtime(ae));
174
assertEqualInt(86401, archive_entry_atime(ae));
175
assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
176
assertEqualInt(1, archive_entry_uid(ae));
177
assertEqualInt(2, archive_entry_gid(ae));
178
} else if (strcmp("sym1", archive_entry_pathname(ae)) == 0) {
179
/* A symlink to the regular file. */
180
assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
181
assertEqualString(path1, archive_entry_symlink(ae));
182
assertEqualInt(0, archive_entry_size(ae));
183
assertEqualInt(172802, archive_entry_mtime(ae));
184
assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
185
assertEqualInt(1, archive_entry_uid(ae));
186
assertEqualInt(2, archive_entry_gid(ae));
187
} else if (strcmp("sym2", archive_entry_pathname(ae)) == 0) {
188
/* A symlink to the regular file. */
189
assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
190
assertEqualString(path2, archive_entry_symlink(ae));
191
assertEqualInt(0, archive_entry_size(ae));
192
assertEqualInt(172802, archive_entry_mtime(ae));
193
assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
194
assertEqualInt(1, archive_entry_uid(ae));
195
assertEqualInt(2, archive_entry_gid(ae));
196
} else if (strcmp("sym3", archive_entry_pathname(ae)) == 0) {
197
/* A symlink to the regular file. */
198
assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
199
assertEqualString(path3, archive_entry_symlink(ae));
200
assertEqualInt(0, archive_entry_size(ae));
201
assertEqualInt(172802, archive_entry_mtime(ae));
202
assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
203
assertEqualInt(1, archive_entry_uid(ae));
204
assertEqualInt(2, archive_entry_gid(ae));
206
failure("Saw a file that shouldn't have been there");
207
assertEqualString(archive_entry_pathname(ae), "");
211
/* End of archive. */
212
assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
214
/* Verify archive format. */
215
assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
216
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
218
/* Close the archive. */
219
assertEqualInt(0, archive_read_close(a));
220
assertEqualInt(0, archive_read_finish(a));