test_read_format_cpio_svr4_gzip_rpm.c revision 302001
1110476Strhodes/*- 266830Sobrien * Copyright (c) 2003-2007 Tim Kientzle 366830Sobrien * Copyright (c) 2009 Michihiro NAKAJIMA 466830Sobrien * All rights reserved. 566830Sobrien * 666830Sobrien * Redistribution and use in source and binary forms, with or without 766830Sobrien * modification, are permitted provided that the following conditions 866830Sobrien * are met: 966830Sobrien * 1. Redistributions of source code must retain the above copyright 1066830Sobrien * notice, this list of conditions and the following disclaimer. 1166830Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1266830Sobrien * notice, this list of conditions and the following disclaimer in the 1366830Sobrien * documentation and/or other materials provided with the distribution. 1466830Sobrien * 1566830Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 1666830Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1766830Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1866830Sobrien * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 1966830Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2066830Sobrien * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2166830Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2266830Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2366830Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2466830Sobrien * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2566830Sobrien */ 2650472Speter#include "test.h" 2766830Sobrien 2815027Sphk/* 2966830SobrienExecute the following command to rebuild the data for this program: 30168384Srwatson tail -n +32 test_read_format_cpio_svr4_gzip_rpm.c | /bin/sh 3166830Sobrien 3266830SobrienF=test_read_format_cpio_svr4_gzip_rpm.rpm 3343849SjkhNAME=rpmsample 3481618SddTMPRPM=/tmp/rpm 3581618Sddrm -rf ${TMPRPM} 3681618Sddmkdir -p ${TMPRPM}/BUILD 3781618Sddmkdir -p ${TMPRPM}/RPMS 3881618Sddmkdir -p ${TMPRPM}/SOURCES 3981618Sddmkdir -p ${TMPRPM}/SPECS 4081618Sddmkdir -p ${TMPRPM}/SRPMS 4133203Sadamecho "hello" > ${TMPRPM}/BUILD/file1 4233203Sadamecho "hello" > ${TMPRPM}/BUILD/file2 4315027Sphkecho "hello" > ${TMPRPM}/BUILD/file3 4429300Sdannycat > ${TMPRPM}/SPECS/${NAME}.spec <<END 45163749Sphk## 46163749Sphk%define _topdir ${TMPRPM} 47163749Sphk%define _binary_payload w9.gzdio 48163749Sphk 49163749SphkSummary: Sample data of RPM filter of libarchive 50163749SphkName: ${NAME} 51163749SphkVersion: 1.0.0 52163749SphkRelease: 1 5315027SphkLicense: BSD 5451231SsheldonhURL: http://libarchive.github.com/ 5529300SdannyBuildArch: noarch 5615027SphkBuildRoot: %{_tmppath}/%{name}-%{version}-root 5715027Sphk 5815027Sphk%install 5915027Sphkrm -rf \$RPM_BUILD_ROOT 6015027Sphk 6115027Sphkmkdir -p \$RPM_BUILD_ROOT%{_sysconfdir} 6273023Sdesinstall -m 644 file1 \$RPM_BUILD_ROOT%{_sysconfdir}/file1 6315210Sphkinstall -m 644 file2 \$RPM_BUILD_ROOT%{_sysconfdir}/file2 6415210Sphkinstall -m 644 file3 \$RPM_BUILD_ROOT%{_sysconfdir}/file3 6515210SphkTZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file1 6673023SdesTZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file2 6725478SjkhTZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file3 6873023Sdes 6915210Sphk%files 7015210Sphk%{_sysconfdir}/file1 7115210Sphk%{_sysconfdir}/file2 72175244Smaxim%{_sysconfdir}/file3 73175244Smaxim 7415027Sphk%description 75175244SmaximSample data. 76175244SmaximEND 77175244Smaxim# 78175244Smaximrpmbuild -bb ${TMPRPM}/SPECS/${NAME}.spec 7915027Sphkuuencode ${F} < ${TMPRPM}/RPMS/noarch/${NAME}-1.0.0-1.noarch.rpm > ${F}.uu 8015027Sphk 8191019Scjcrm -rf ${TMPRPM} 8291019Scjcexit 1 8391019Scjc*/ 8491019Scjc 8591019ScjcDEFINE_TEST(test_read_format_cpio_svr4_gzip_rpm) 8691019Scjc{ 8791019Scjc struct archive_entry *ae; 88200028Sume struct archive *a; 89200028Sume const char *name = "test_read_format_cpio_svr4_gzip_rpm.rpm"; 90200028Sume int r; 91200028Sume 9291019Scjc assert((a = archive_read_new()) != NULL); 9391019Scjc r = archive_read_support_filter_gzip(a); 94200028Sume if (r == ARCHIVE_WARN) { 95200028Sume skipping("gzip reading not fully supported on this platform"); 96200028Sume assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 97200028Sume return; 98200028Sume } 99200028Sume assertEqualIntA(a, ARCHIVE_OK, r); 100200028Sume assertEqualIntA(a, ARCHIVE_OK, 101200028Sume archive_read_support_filter_rpm(a)); 102200028Sume assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); 103200028Sume extract_reference_file(name); 104200028Sume assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2)); 105200028Sume 106200028Sume assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 107200028Sume assertEqualString("./etc/file1", archive_entry_pathname(ae)); 108200028Sume assertEqualInt(86401, archive_entry_mtime(ae)); 109200028Sume assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 110200028Sume assertEqualString("./etc/file2", archive_entry_pathname(ae)); 111200028Sume assertEqualInt(86401, archive_entry_mtime(ae)); 112200028Sume assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 113200028Sume assertEqualString("./etc/file3", archive_entry_pathname(ae)); 114200028Sume assertEqualInt(86401, archive_entry_mtime(ae)); 11551231Ssheldonh assertEqualInt(archive_entry_is_encrypted(ae), 0); 11651231Ssheldonh assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED); 11729300Sdanny 11829300Sdanny /* Verify the end-of-archive. */ 119200028Sume assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 120200028Sume 121200028Sume /* Verify that the format detection worked. */ 122200028Sume assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_GZIP); 123200028Sume assertEqualString(archive_filter_name(a, 0), "gzip"); 12415027Sphk assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC); 12529300Sdanny 12651231Ssheldonh assertEqualInt(ARCHIVE_OK, archive_read_close(a)); 12751231Ssheldonh assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 12851231Ssheldonh} 12929300Sdanny 13051231Ssheldonh