1228753Smm/*-
2228753Smm * Copyright (c) 2008 Miklos Vajna
3228753Smm * All rights reserved.
4228753Smm *
5228753Smm * Redistribution and use in source and binary forms, with or without
6228753Smm * modification, are permitted provided that the following conditions
7228753Smm * are met:
8228753Smm * 1. Redistributions of source code must retain the above copyright
9228753Smm *    notice, this list of conditions and the following disclaimer.
10228753Smm * 2. Redistributions in binary form must reproduce the above copyright
11228753Smm *    notice, this list of conditions and the following disclaimer in the
12228753Smm *    documentation and/or other materials provided with the distribution.
13228753Smm *
14228753Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15228753Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16228753Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17228753Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18228753Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19228753Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20228753Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21228753Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22228753Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23228753Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24228753Smm */
25228753Smm#include "test.h"
26228763Smm__FBSDID("$FreeBSD$");
27228753Smm
28228753Smmstatic unsigned char archive[] = {
29228753Smm0x5d, 0x0, 0x0, 0x80, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
30228753Smm0x17, 0xb, 0xbc, 0x1c, 0x7d, 0x1, 0x95, 0xc0, 0x1d, 0x4a, 0x46, 0x9c,
31228753Smm0x1c, 0xc5, 0x8, 0x82, 0x10, 0xed, 0x84, 0xf6, 0xea, 0x7a, 0xfe, 0x63,
32228753Smm0x5a, 0x34, 0x5e, 0xf7, 0xc, 0x60, 0xd6, 0x8b, 0xc1, 0x47, 0xaf, 0x11,
33228753Smm0x6f, 0x18, 0x94, 0x81, 0x74, 0x8a, 0xf8, 0x47, 0xcc, 0xdd, 0xc0, 0xd9,
34228753Smm0x40, 0xa, 0xc3, 0xac, 0x43, 0x47, 0xb5, 0xac, 0x2b, 0x31, 0xd3, 0x6,
35228753Smm0xa4, 0x2c, 0x44, 0x80, 0x24, 0x4b, 0xfe, 0x43, 0x22, 0x4e, 0x14, 0x30,
36228753Smm0x7a, 0xef, 0x99, 0x6e, 0xf, 0x8b, 0xc1, 0x79, 0x93, 0x88, 0x54, 0x73,
37228753Smm0x59, 0x3f, 0xc, 0xfb, 0xee, 0x9c, 0x83, 0x49, 0x93, 0x33, 0xad, 0x44,
38228753Smm0xbe, 0x0};
39228753Smm
40228753SmmDEFINE_TEST(test_read_format_gtar_lzma)
41228753Smm{
42228753Smm	int r;
43228753Smm
44228753Smm	struct archive_entry *ae;
45228753Smm	struct archive *a;
46228753Smm	assert((a = archive_read_new()) != NULL);
47228753Smm	assertEqualIntA(a, ARCHIVE_OK,
48232153Smm	    archive_read_support_filter_all(a));
49232153Smm	r = archive_read_support_filter_lzma(a);
50228753Smm	if (r == ARCHIVE_WARN) {
51228753Smm		skipping("lzma reading not fully supported on this platform");
52232153Smm		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
53228753Smm		return;
54228753Smm	}
55228753Smm
56228753Smm	assertEqualIntA(a, ARCHIVE_OK, r);
57228753Smm	assertEqualIntA(a, ARCHIVE_OK,
58228753Smm	    archive_read_support_format_all(a));
59228753Smm	r = archive_read_open_memory2(a, archive, sizeof(archive), 3);
60228753Smm	if (r != ARCHIVE_OK) {
61228753Smm		skipping("Skipping LZMA compression check: %s",
62228753Smm		    archive_error_string(a));
63228753Smm		goto finish;
64228753Smm	}
65228753Smm	assertEqualIntA(a, ARCHIVE_OK,
66228753Smm	    archive_read_next_header(a, &ae));
67248616Smm	assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZMA);
68228753Smm	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
69228753Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
70228753Smmfinish:
71232153Smm	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
72228753Smm}
73228753Smm
74228753Smm
75