1231200Smm/*-
2231200Smm * Copyright (c) 2010 Michihiro NAKAJIMA
3231200Smm * Copyright (c) 2003-2007 Tim Kientzle
4231200Smm * All rights reserved.
5231200Smm *
6231200Smm * Redistribution and use in source and binary forms, with or without
7231200Smm * modification, are permitted provided that the following conditions
8231200Smm * are met:
9231200Smm * 1. Redistributions of source code must retain the above copyright
10231200Smm *    notice, this list of conditions and the following disclaimer.
11231200Smm * 2. Redistributions in binary form must reproduce the above copyright
12231200Smm *    notice, this list of conditions and the following disclaimer in the
13231200Smm *    documentation and/or other materials provided with the distribution.
14231200Smm *
15231200Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16231200Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17231200Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18231200Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19231200Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20231200Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21231200Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22231200Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23231200Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24231200Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25231200Smm */
26231200Smm#include "test.h"
27231200Smm__FBSDID("$FreeBSD$");
28231200Smm
29231200Smmstatic unsigned char archive[] = {
30231200Smm 76, 90, 73, 80,  1, 12,  0, 99,156, 62,160, 67,124,230, 93,220,
31231200Smm235,118, 29, 75, 27,226,158, 67,149,151, 96, 22, 54,198,209, 63,
32231200Smm104,209,148,249,238, 71,187,201,243,162,  1, 42, 47, 43,178, 35,
33231200Smm 90,  6,156,208, 74,107, 91,229,126,  5, 85,255,136,255, 64,  0,
34231200Smm170,199,228,195,  0,  2,  0,  0,  0,  0,  0,  0, 84,  0,  0,  0,
35231200Smm  0,  0,  0,  0
36231200Smm};
37231200Smm
38231200SmmDEFINE_TEST(test_read_format_cpio_bin_lzip)
39231200Smm{
40231200Smm	struct archive_entry *ae;
41231200Smm	struct archive *a;
42231200Smm	int r;
43231200Smm
44231200Smm	assert((a = archive_read_new()) != NULL);
45231200Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
46231200Smm	r = archive_read_support_filter_lzip(a);
47231200Smm	if (r == ARCHIVE_WARN) {
48231200Smm		skipping("lzip reading not fully supported on this platform");
49231200Smm		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
50231200Smm		return;
51231200Smm	}
52231200Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
53231200Smm	assertEqualIntA(a, ARCHIVE_OK,
54231200Smm	    archive_read_open_memory(a, archive, sizeof(archive)));
55231200Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
56302001Smm	assertEqualInt(archive_entry_is_encrypted(ae), 0);
57302001Smm	assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
58248616Smm	assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZIP);
59231200Smm	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
60231200Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
61231200Smm	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
62231200Smm}
63231200Smm
64