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_isojoliet_long.c 201247 2009-12-30 05:59:21Z kientzle $");
30
Execute the following to rebuild the data for this program:
31
tail -n +35 test_read_format_isojoliet_long.c | /bin/sh
37
while [ $num -lt 100 ]
40
file="${file}1234567890"
45
echo "hello" > /tmp/iso/${file}
46
ln /tmp/iso/${file} /tmp/iso/hardlink
47
if [ "$(uname -s)" = "Linux" ]; then # gnu coreutils touch doesn't have -h
48
TZ=utc touch -afm -t 197001020000.01 /tmp/iso /tmp/iso/${file} /tmp/iso/${dir}
50
TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/${file} /tmp/iso/${dir}
52
F=test_read_format_iso_joliet_long.iso.Z
53
mkhybrid -J -joliet-long -uid 1 -gid 2 /tmp/iso | compress > $F
54
uuencode $F $F > $F.uu
59
DEFINE_TEST(test_read_format_isojoliet_long)
61
const char *refname = "test_read_format_iso_joliet_long.iso.Z";
63
struct archive_entry *ae;
70
for (i = 0; i < 100; i++)
71
pathname[i] = '0' + ((i+1) % 10);
72
extract_reference_file(refname);
73
assert((a = archive_read_new()) != NULL);
74
assertEqualInt(0, archive_read_support_compression_all(a));
75
assertEqualInt(0, archive_read_support_format_all(a));
76
assertEqualInt(ARCHIVE_OK,
77
archive_read_set_options(a, "iso9660:!rockridge"));
78
assertEqualInt(ARCHIVE_OK,
79
archive_read_open_filename(a, refname, 10240));
81
/* First entry is '.' root directory. */
82
assertEqualInt(0, archive_read_next_header(a, &ae));
83
assertEqualString(".", archive_entry_pathname(ae));
84
assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
85
assertEqualInt(2048, archive_entry_size(ae));
86
assertEqualInt(86401, archive_entry_mtime(ae));
87
assertEqualInt(0, archive_entry_mtime_nsec(ae));
88
assertEqualInt(86401, archive_entry_ctime(ae));
89
assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
90
assertEqualInt(0, archive_entry_uid(ae));
91
assertEqualIntA(a, ARCHIVE_EOF,
92
archive_read_data_block(a, &p, &size, &offset));
93
assertEqualInt((int)size, 0);
100
assertEqualInt(0, archive_read_next_header(a, &ae));
101
assertEqualString(pathname, archive_entry_pathname(ae));
102
assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
103
assertEqualInt(2048, archive_entry_size(ae));
104
assertEqualInt(86401, archive_entry_mtime(ae));
105
assertEqualInt(86401, archive_entry_atime(ae));
107
/* A regular file with two names (pathname gets returned
108
* first, so it's not marked as a hardlink). */
112
pathname[103] = '\0';
113
assertEqualInt(0, archive_read_next_header(a, &ae));
114
assertEqualString(pathname, archive_entry_pathname(ae));
115
assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
116
assert(archive_entry_hardlink(ae) == NULL);
117
assertEqualInt(6, archive_entry_size(ae));
118
assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
119
assertEqualInt(6, (int)size);
120
assertEqualInt(0, offset);
121
assertEqualInt(0, memcmp(p, "hello\n", 6));
123
/* Second name for the same regular file (this happens to be
124
* returned second, so does get marked as a hardlink). */
125
assertEqualInt(0, archive_read_next_header(a, &ae));
126
assertEqualString("hardlink", archive_entry_pathname(ae));
127
assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
128
assertEqualString(pathname, archive_entry_hardlink(ae));
129
assert(!archive_entry_size_is_set(ae));
131
/* End of archive. */
132
assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
134
/* Verify archive format. */
135
assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
137
/* Close the archive. */
138
assertEqualInt(0, archive_read_close(a));
139
assertEqualInt(0, archive_read_finish(a));