test_read_format_cpio_bin_gz.c revision 302001
197403Sobrien/*- 297403Sobrien * Copyright (c) 2003-2007 Tim Kientzle 3169691Skan * All rights reserved. 4169691Skan * 597403Sobrien * Redistribution and use in source and binary forms, with or without 697403Sobrien * modification, are permitted provided that the following conditions 797403Sobrien * are met: 897403Sobrien * 1. Redistributions of source code must retain the above copyright 997403Sobrien * notice, this list of conditions and the following disclaimer. 1097403Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1197403Sobrien * notice, this list of conditions and the following disclaimer in the 1297403Sobrien * documentation and/or other materials provided with the distribution. 1397403Sobrien * 1497403Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 1597403Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1697403Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1797403Sobrien * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 1897403Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19169691Skan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2097403Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2197403Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2297403Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2397403Sobrien * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2497403Sobrien */ 2597403Sobrien#include "test.h" 2697403Sobrien__FBSDID("$FreeBSD: stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_gz.c 302001 2016-06-17 22:40:10Z mm $"); 2797403Sobrien 2897403Sobrienstatic unsigned char archive[] = { 2997403Sobrien31,139,8,0,244,'M','p','C',0,3,';','^','(',202,178,177,242,173,227,11,230, 3097403Sobrien23,204,'L',12,12,12,5,206,'_','|','A','4',3,131,30,195,241,'B',6,'8','`', 3197403Sobrien132,210,220,'`','2','$',200,209,211,199,'5','H','Q','Q',145,'a',20,12,'i', 3297403Sobrien0,0,170,199,228,195,0,2,0,0}; 3397403Sobrien 3497403SobrienDEFINE_TEST(test_read_format_cpio_bin_gz) 3597403Sobrien{ 3697403Sobrien struct archive_entry *ae; 3797403Sobrien struct archive *a; 3897403Sobrien int r; 3997403Sobrien 4097403Sobrien assert((a = archive_read_new()) != NULL); 4197403Sobrien assertEqualInt(ARCHIVE_OK, archive_read_support_filter_all(a)); 4297403Sobrien r = archive_read_support_filter_gzip(a); 4397403Sobrien if (r == ARCHIVE_WARN) { 4497403Sobrien skipping("gzip reading not fully supported on this platform"); 4597403Sobrien assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 4697403Sobrien return; 4797403Sobrien } 4897403Sobrien failure("archive_read_support_filter_gzip"); 4997403Sobrien assertEqualInt(ARCHIVE_OK, r); 5097403Sobrien assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a)); 5197403Sobrien assertEqualInt(ARCHIVE_OK, 5297403Sobrien archive_read_open_memory(a, archive, sizeof(archive))); 5397403Sobrien assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae)); 5497403Sobrien assertEqualInt(archive_filter_code(a, 0), 5597403Sobrien ARCHIVE_FILTER_GZIP); 5697403Sobrien assertEqualInt(archive_entry_is_encrypted(ae), 0); 5797403Sobrien assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED); 5897403Sobrien assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE); 5997403Sobrien assertEqualInt(ARCHIVE_OK, archive_read_close(a)); 6097403Sobrien assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 6197403Sobrien} 62132720Skan 63132720Skan 6497403Sobrien