2 * Copyright (c) 2003-2007 Tim Kientzle
5 * Based on libarchive/test/test_read_format_isorr_bz2.c with
6 * bugs introduced by Andreas Henriksson <andreas@fatal.se> for
7 * testing ISO9660 image with Joliet extension.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 __FBSDID("$FreeBSD$");
33 Execute the following to rebuild the data for this program:
34 tail -n +35 test_read_format_isojoliet_bz2.c | /bin/sh
39 echo "hello" >/tmp/iso/long-joliet-file-name.textfile
40 ln /tmp/iso/long-joliet-file-name.textfile /tmp/iso/hardlink
41 (cd /tmp/iso; ln -s long-joliet-file-name.textfile symlink)
42 if [ "$(uname -s)" = "Linux" ]; then # gnu coreutils touch doesn't have -h
43 TZ=utc touch -afm -t 197001020000.01 /tmp/iso /tmp/iso/long-joliet-file-name.textfile /tmp/iso/dir
44 TZ=utc touch -afm -t 197001030000.02 /tmp/iso/symlink
46 TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/long-joliet-file-name.textfile /tmp/iso/dir
47 TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink
49 mkhybrid -J -uid 1 -gid 2 /tmp/iso | bzip2 > test_read_format_isojoliet_bz2.iso.bz2
50 F=test_read_format_isojoliet_bz2.iso.bz2
51 uuencode $F $F > $F.uu
56 joliettest(int withrr)
58 const char *refname = "test_read_format_isojoliet_bz2.iso.bz2";
59 struct archive_entry *ae;
67 refname = "test_read_format_isojolietrr_bz2.iso.bz2";
70 extract_reference_file(refname);
71 assert((a = archive_read_new()) != NULL);
72 r = archive_read_support_compression_bzip2(a);
73 if (r == ARCHIVE_WARN) {
74 skipping("bzip2 reading not fully supported on this platform");
75 assertEqualInt(0, archive_read_finish(a));
79 assertEqualInt(0, archive_read_support_format_all(a));
80 assertEqualInt(ARCHIVE_OK,
81 archive_read_open_filename(a, refname, 10240));
83 /* First entry is '.' root directory. */
84 assertEqualInt(0, archive_read_next_header(a, &ae));
85 assertEqualString(".", archive_entry_pathname(ae));
86 assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
87 assertEqualInt(2048, archive_entry_size(ae));
88 assertEqualInt(86401, archive_entry_mtime(ae));
89 assertEqualInt(0, archive_entry_mtime_nsec(ae));
90 assertEqualInt(86401, archive_entry_ctime(ae));
91 assertEqualInt(0, archive_entry_stat(ae)->st_nlink);
92 assertEqualInt(0, archive_entry_uid(ae));
93 assertEqualIntA(a, ARCHIVE_EOF,
94 archive_read_data_block(a, &p, &size, &offset));
95 assertEqualInt((int)size, 0);
98 assertEqualInt(0, archive_read_next_header(a, &ae));
99 assertEqualString("dir", archive_entry_pathname(ae));
100 assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
101 assertEqualInt(2048, archive_entry_size(ae));
102 assertEqualInt(86401, archive_entry_mtime(ae));
103 assertEqualInt(86401, archive_entry_atime(ae));
105 assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
106 assertEqualInt(1, archive_entry_uid(ae));
107 assertEqualInt(2, archive_entry_gid(ae));
110 /* A hardlink to the regular file. */
111 assertEqualInt(0, archive_read_next_header(a, &ae));
112 assertEqualString("hardlink", archive_entry_pathname(ae));
113 assert(S_ISREG(archive_entry_stat(ae)->st_mode));
115 assertEqualString("long-joliet-file-name.textfile",
116 archive_entry_hardlink(ae));
118 assertEqualInt(6, archive_entry_size(ae));
119 assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
120 assertEqualInt(6, (int)size);
121 assertEqualInt(0, offset);
122 assertEqualInt(0, memcmp(p, "hello\n", 6));
124 assertEqualInt(86401, archive_entry_mtime(ae));
125 assertEqualInt(86401, archive_entry_atime(ae));
126 assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
127 assertEqualInt(1, archive_entry_uid(ae));
128 assertEqualInt(2, archive_entry_gid(ae));
131 /* A regular file. */
132 assertEqualInt(0, archive_read_next_header(a, &ae));
133 assertEqualString("long-joliet-file-name.textfile", archive_entry_pathname(ae));
134 assert(S_ISREG(archive_entry_stat(ae)->st_mode));
135 assertEqualInt(6, archive_entry_size(ae));
137 assertEqualInt(86401, archive_entry_mtime(ae));
138 assertEqualInt(86401, archive_entry_atime(ae));
139 assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
140 assertEqualInt(1, archive_entry_uid(ae));
141 assertEqualInt(2, archive_entry_gid(ae));
144 /* A symlink to the regular file. */
145 assertEqualInt(0, archive_read_next_header(a, &ae));
146 assertEqualString("symlink", archive_entry_pathname(ae));
148 assert(S_ISLNK(archive_entry_stat(ae)->st_mode));
149 assertEqualString("long-joliet-file-name.textfile",
150 archive_entry_symlink(ae));
152 assertEqualInt(0, archive_entry_size(ae));
153 assertEqualInt(172802, archive_entry_mtime(ae));
154 assertEqualInt(172802, archive_entry_atime(ae));
156 assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
157 assertEqualInt(1, archive_entry_uid(ae));
158 assertEqualInt(2, archive_entry_gid(ae));
161 /* End of archive. */
162 assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
164 /* Verify archive format. */
165 assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
167 assertEqualInt(archive_format(a),
168 ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
171 /* Close the archive. */
172 assertEqualInt(0, archive_read_close(a));
173 assertEqualInt(0, archive_read_finish(a));
177 DEFINE_TEST(test_read_format_isojoliet_bz2)
181 /* XXXX This doesn't work today; can it be made to work? */
185 skipping("Mixed Joliet/RR not fully supported yet.");