Blame libarchive/test/test_read_format_cpio_bin_xz.c

Packit 08bd4c
/*-
Packit 08bd4c
 * Copyright (c) 2009 Michihiro NAKAJIMA
Packit 08bd4c
 * Copyright (c) 2003-2007 Tim Kientzle
Packit 08bd4c
 * All rights reserved.
Packit 08bd4c
 *
Packit 08bd4c
 * Redistribution and use in source and binary forms, with or without
Packit 08bd4c
 * modification, are permitted provided that the following conditions
Packit 08bd4c
 * are met:
Packit 08bd4c
 * 1. Redistributions of source code must retain the above copyright
Packit 08bd4c
 *    notice, this list of conditions and the following disclaimer.
Packit 08bd4c
 * 2. Redistributions in binary form must reproduce the above copyright
Packit 08bd4c
 *    notice, this list of conditions and the following disclaimer in the
Packit 08bd4c
 *    documentation and/or other materials provided with the distribution.
Packit 08bd4c
 *
Packit 08bd4c
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
Packit 08bd4c
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Packit 08bd4c
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Packit 08bd4c
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit 08bd4c
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
Packit 08bd4c
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 08bd4c
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 08bd4c
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 08bd4c
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
Packit 08bd4c
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 08bd4c
 */
Packit 08bd4c
#include "test.h"
Packit 08bd4c
__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_xz.c 191183 2009-04-17 01:06:31Z kientzle $");
Packit 08bd4c
Packit 08bd4c
static unsigned char archive[] = {
Packit 08bd4c
 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04,
Packit 08bd4c
 0xe6, 0xd6, 0xb4, 0x46, 0x02, 0x00, 0x21, 0x01,
Packit 08bd4c
 0x16, 0x00, 0x00, 0x00, 0x74, 0x2f, 0xe5, 0xa3,
Packit 08bd4c
 0xe0, 0x01, 0xff, 0x00, 0x33, 0x5d, 0x00, 0x63,
Packit 08bd4c
 0x9c, 0x3e, 0xa0, 0x43, 0x7c, 0xe6, 0x5d, 0xdc,
Packit 08bd4c
 0xeb, 0x76, 0x1d, 0x4b, 0x1b, 0xe2, 0x9e, 0x43,
Packit 08bd4c
 0x95, 0x97, 0x60, 0x16, 0x36, 0xc6, 0xd1, 0x3f,
Packit 08bd4c
 0x68, 0xd1, 0x94, 0xf9, 0xee, 0x47, 0xbb, 0xc9,
Packit 08bd4c
 0xf3, 0xa2, 0x01, 0x2a, 0x2f, 0x2b, 0xb2, 0x23,
Packit 08bd4c
 0x5a, 0x06, 0x9c, 0xd0, 0x4a, 0x6b, 0x5b, 0x14,
Packit 08bd4c
 0xb4, 0x00, 0x00, 0x00, 0x91, 0x62, 0x1e, 0x15,
Packit 08bd4c
 0x04, 0x46, 0x6b, 0x4d, 0x00, 0x01, 0x4f, 0x80,
Packit 08bd4c
 0x04, 0x00, 0x00, 0x00, 0xa1, 0x4b, 0xdf, 0x03,
Packit 08bd4c
 0xb1, 0xc4, 0x67, 0xfb, 0x02, 0x00, 0x00, 0x00,
Packit 08bd4c
 0x00, 0x04, 0x59, 0x5a      
Packit 08bd4c
};
Packit 08bd4c
Packit 08bd4c
DEFINE_TEST(test_read_format_cpio_bin_xz)
Packit 08bd4c
{
Packit 08bd4c
	struct archive_entry *ae;
Packit 08bd4c
	struct archive *a;
Packit 08bd4c
	int r;
Packit 08bd4c
Packit 08bd4c
	assert((a = archive_read_new()) != NULL);
Packit 08bd4c
	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
Packit 08bd4c
	r = archive_read_support_filter_xz(a);
Packit 08bd4c
	if (r == ARCHIVE_WARN) {
Packit 08bd4c
		skipping("xz reading not fully supported on this platform");
Packit 08bd4c
		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
Packit 08bd4c
		return;
Packit 08bd4c
	}
Packit 08bd4c
	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
Packit 08bd4c
	assertEqualIntA(a, ARCHIVE_OK,
Packit 08bd4c
	    archive_read_open_memory(a, archive, sizeof(archive)));
Packit 08bd4c
	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae);;
Packit 08bd4c
	assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_XZ);
Packit 08bd4c
	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
Packit 08bd4c
	assertEqualInt(archive_entry_is_encrypted(ae), 0);
Packit 08bd4c
	assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
Packit 08bd4c
	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
Packit 08bd4c
	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
Packit 08bd4c
}
Packit 08bd4c