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$");
29 DEFINE_TEST(test_read_format_iso_multi_extent)
31 const char *refname = "test_read_format_iso_multi_extent.iso.Z";
32 struct archive_entry *ae;
39 extract_reference_file(refname);
40 assert((a = archive_read_new()) != NULL);
41 assertEqualInt(0, archive_read_support_filter_all(a));
42 assertEqualInt(0, archive_read_support_format_all(a));
43 assertEqualInt(ARCHIVE_OK,
44 archive_read_open_filename(a, refname, 10240));
46 /* Retrieve each of the 2 files on the ISO image and
47 * verify that each one is what we expect. */
48 for (i = 0; i < 2; ++i) {
49 assertEqualInt(0, archive_read_next_header(a, &ae));
51 if (strcmp(".", archive_entry_pathname(ae)) == 0) {
52 /* '.' root directory. */
53 assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
54 assertEqualInt(2048, archive_entry_size(ae));
55 assertEqualInt(86401, archive_entry_mtime(ae));
56 assertEqualInt(0, archive_entry_mtime_nsec(ae));
57 assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
58 assertEqualInt(1, archive_entry_uid(ae));
59 assertEqualIntA(a, ARCHIVE_EOF,
60 archive_read_data_block(a, &p, &size, &offset));
61 assertEqualInt((int)size, 0);
62 } else if (strcmp("file", archive_entry_pathname(ae)) == 0) {
64 assertEqualString("file", archive_entry_pathname(ae));
65 assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
66 assertEqualInt(262280, archive_entry_size(ae));
68 archive_read_data_block(a, &p, &size, &offset));
69 assertEqualInt(0, offset);
70 assertEqualMem(p, "head--head--head", 16);
71 assertEqualInt(86401, archive_entry_mtime(ae));
72 assertEqualInt(86401, archive_entry_atime(ae));
73 assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
74 assertEqualInt(1, archive_entry_uid(ae));
75 assertEqualInt(2, archive_entry_gid(ae));
77 failure("Saw a file that shouldn't have been there");
78 assertEqualString(archive_entry_pathname(ae), "");
83 assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
85 /* Verify archive format. */
86 assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_COMPRESS);
87 assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
89 /* Close the archive. */
90 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
91 assertEqualInt(ARCHIVE_OK, archive_read_free(a));