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$");
30 Execute the following command to rebuild the data for this program:
31 tail -n +32 test_read_format_cpio_svr4_gzip_rpm.c | /bin/sh
33 F=test_read_format_cpio_svr4_gzip_rpm.rpm
37 mkdir -p ${TMPRPM}/BUILD
38 mkdir -p ${TMPRPM}/RPMS
39 mkdir -p ${TMPRPM}/SOURCES
40 mkdir -p ${TMPRPM}/SPECS
41 mkdir -p ${TMPRPM}/SRPMS
42 echo "hello" > ${TMPRPM}/BUILD/file1
43 echo "hello" > ${TMPRPM}/BUILD/file2
44 echo "hello" > ${TMPRPM}/BUILD/file3
45 cat > ${TMPRPM}/SPECS/${NAME}.spec <<END
47 %define _topdir ${TMPRPM}
48 %define _binary_payload w9.gzdio
50 Summary: Sample data of RPM filter of libarchive
55 URL: http://code.google.com/p/libarchive
57 BuildRoot: %{_tmppath}/%{name}-%{version}-root
60 rm -rf \$RPM_BUILD_ROOT
62 mkdir -p \$RPM_BUILD_ROOT%{_sysconfdir}
63 install -m 644 file1 \$RPM_BUILD_ROOT%{_sysconfdir}/file1
64 install -m 644 file2 \$RPM_BUILD_ROOT%{_sysconfdir}/file2
65 install -m 644 file3 \$RPM_BUILD_ROOT%{_sysconfdir}/file3
66 TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file1
67 TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file2
68 TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file3
79 rpmbuild -bb ${TMPRPM}/SPECS/${NAME}.spec
80 uuencode ${F} < ${TMPRPM}/RPMS/noarch/${NAME}-1.0.0-1.noarch.rpm > ${F}.uu
86 DEFINE_TEST(test_read_format_cpio_svr4_gzip_rpm)
88 struct archive_entry *ae;
90 const char *name = "test_read_format_cpio_svr4_gzip_rpm.rpm";
93 assert((a = archive_read_new()) != NULL);
94 r = archive_read_support_compression_gzip(a);
95 if (r == ARCHIVE_WARN) {
96 skipping("gzip reading not fully supported on this platform");
97 assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
100 assertEqualIntA(a, ARCHIVE_OK, r);
101 assertEqualIntA(a, ARCHIVE_OK,
102 archive_read_support_compression_rpm(a));
103 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
104 extract_reference_file(name);
105 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
107 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
108 assertEqualString("./etc/file1", archive_entry_pathname(ae));
109 assertEqualInt(86401, archive_entry_mtime(ae));
110 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
111 assertEqualString("./etc/file2", archive_entry_pathname(ae));
112 assertEqualInt(86401, archive_entry_mtime(ae));
113 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
114 assertEqualString("./etc/file3", archive_entry_pathname(ae));
115 assertEqualInt(86401, archive_entry_mtime(ae));
117 /* Verify the end-of-archive. */
118 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
120 /* Verify that the format detection worked. */
121 assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP);
122 assertEqualString(archive_compression_name(a), "gzip");
123 assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
125 assertEqualInt(ARCHIVE_OK, archive_read_close(a));
126 assertEqualInt(ARCHIVE_OK, archive_read_finish(a));