1228753Smm/*- 2228753Smm * Copyright (c) 2009 Michihiro NAKAJIMA 3228753Smm * Copyright (c) 2003-2007 Tim Kientzle 4228753Smm * All rights reserved. 5228753Smm * 6228753Smm * Redistribution and use in source and binary forms, with or without 7228753Smm * modification, are permitted provided that the following conditions 8228753Smm * are met: 9228753Smm * 1. Redistributions of source code must retain the above copyright 10228753Smm * notice, this list of conditions and the following disclaimer. 11228753Smm * 2. Redistributions in binary form must reproduce the above copyright 12228753Smm * notice, this list of conditions and the following disclaimer in the 13228753Smm * documentation and/or other materials provided with the distribution. 14228753Smm * 15228753Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 16228753Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17228753Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18228753Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 19228753Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20228753Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21228753Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22228753Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23228753Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24228753Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25228753Smm */ 26228753Smm#include "test.h" 27229592Smm__FBSDID("$FreeBSD$"); 28228753Smm 29228753Smmstatic unsigned char archive[] = { 30228753Smm 93, 0, 0,128, 0,255,255,255,255,255,255,255,255, 0, 99,156, 31228753Smm 62,160, 67,124,230, 93,220,235,118, 29, 75, 27,226,158, 67,149, 32228753Smm151, 96, 22, 54,198,209, 63,104,209,148,249,238, 71,187,201,243, 33228753Smm162, 1, 42, 47, 43,178, 35, 90, 6,156,208, 74,107, 91,229,126, 34228753Smm 5, 85,255,136,255, 64, 0 35228753Smm}; 36228753Smm 37228753SmmDEFINE_TEST(test_read_format_cpio_bin_lzma) 38228753Smm{ 39228753Smm struct archive_entry *ae; 40228753Smm struct archive *a; 41228753Smm int r; 42228753Smm 43228753Smm assert((a = archive_read_new()) != NULL); 44228753Smm assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); 45228753Smm r = archive_read_support_compression_lzma(a); 46228753Smm if (r == ARCHIVE_WARN) { 47228753Smm skipping("lzma reading not fully supported on this platform"); 48228753Smm assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); 49228753Smm return; 50228753Smm } 51228753Smm assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); 52228753Smm assertEqualIntA(a, ARCHIVE_OK, 53228753Smm archive_read_open_memory(a, archive, sizeof(archive))); 54228753Smm assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 55228753Smm assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_LZMA); 56228753Smm assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE); 57228753Smm assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 58228753Smm assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); 59228753Smm} 60228753Smm 61