1231200Smm/*-
2231200Smm * Copyright (c) 2003-2007 Tim Kientzle
3231200Smm * All rights reserved.
4231200Smm *
5231200Smm * Based on libarchive/test/test_read_format_isojoliet_bz2.c with
6231200Smm * bugs introduced by Andreas Henriksson <andreas@fatal.se> for
7231200Smm * testing ISO9660 image with Joliet extension and versioned files.
8231200Smm *
9231200Smm * Redistribution and use in source and binary forms, with or without
10231200Smm * modification, are permitted provided that the following conditions
11231200Smm * are met:
12231200Smm * 1. Redistributions of source code must retain the above copyright
13231200Smm *    notice, this list of conditions and the following disclaimer.
14231200Smm * 2. Redistributions in binary form must reproduce the above copyright
15231200Smm *    notice, this list of conditions and the following disclaimer in the
16231200Smm *    documentation and/or other materials provided with the distribution.
17231200Smm *
18231200Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
19231200Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20231200Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21231200Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
22231200Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23231200Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24231200Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25231200Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26231200Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27231200Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28231200Smm */
29231200Smm#include "test.h"
30231200Smm__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_isojoliet_bz2.c 201247 2009-12-30 05:59:21Z kientzle $");
31231200Smm
32231200Smm/*
33231200Smm * The data for this testcase was provided by Mike Qin <mikeandmore@gmail.com>
34231200Smm * and created with Nero.
35231200Smm */
36231200Smm
37231200SmmDEFINE_TEST(test_read_format_isojoliet_versioned)
38231200Smm{
39231200Smm	const char *refname = "test_read_format_iso_joliet_by_nero.iso.Z";
40231200Smm	struct archive_entry *ae;
41231200Smm	struct archive *a;
42231200Smm
43231200Smm	extract_reference_file(refname);
44231200Smm	assert((a = archive_read_new()) != NULL);
45231200Smm	assertEqualInt(0, archive_read_support_filter_all(a));
46231200Smm	assertEqualInt(0, archive_read_support_format_all(a));
47231200Smm	assertEqualInt(ARCHIVE_OK,
48231200Smm	    archive_read_set_option(a, "iso9660", "rockridge", NULL));
49231200Smm	assertEqualInt(ARCHIVE_OK,
50231200Smm	    archive_read_open_filename(a, refname, 10240));
51231200Smm
52231200Smm	/* First entry is '.' root directory. */
53231200Smm	assertEqualInt(0, archive_read_next_header(a, &ae));
54231200Smm	assertEqualString(".", archive_entry_pathname(ae));
55231200Smm	assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
56231200Smm
57231200Smm	/* A directory. */
58231200Smm	assertEqualInt(0, archive_read_next_header(a, &ae));
59231200Smm	assertEqualString("test", archive_entry_pathname(ae));
60231200Smm	assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
61231200Smm
62231200Smm	/* A regular file which is called test.txt and has
63231200Smm	 * ;1 appended to it because apparently Nero always
64231200Smm	 * appends versions to all files in the joliet extension.
65231200Smm	 *
66231200Smm	 * We test to make sure the version has been stripped.
67231200Smm	 */
68231200Smm	assertEqualInt(0, archive_read_next_header(a, &ae));
69231200Smm	assertEqualString("test/test.txt",
70231200Smm	    archive_entry_pathname(ae));
71231200Smm	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
72231200Smm
73231200Smm	/* End of archive. */
74231200Smm	assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
75231200Smm
76231200Smm	/* Verify archive format. */
77248616Smm	assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_COMPRESS);
78231200Smm
79231200Smm	/* Close the archive. */
80231200Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
81231200Smm	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
82231200Smm}
83231200Smm
84