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, 23,  0,
31228753Smm 51, 80, 24,164,204,238, 45, 77, 28,191, 13,144,  8, 10, 70,  5,
32228753Smm173,215, 47,132,237,145,162, 96,  6,131,168,152,  8,135,161,189,
33228753Smm 73,110,132, 27,195, 52,109,203, 22, 17,168,211, 18,181, 76, 93,
34228753Smm120, 88,154,155,244,141,193,206,170,224, 80,137,134, 67,  1,  9,
35228753Smm123,121,189, 74,137,197, 63,255,214, 55,119,  0
36228753Smm};
37228753Smm
38228753SmmDEFINE_TEST(test_read_format_tlz)
39228753Smm{
40228753Smm	struct archive_entry *ae;
41228753Smm	struct archive *a;
42228753Smm	int r;
43228753Smm
44228753Smm	assert((a = archive_read_new()) != NULL);
45228753Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
46228753Smm	r = archive_read_support_compression_lzma(a);
47228753Smm	if (r == ARCHIVE_WARN) {
48228753Smm		skipping("lzma reading not fully supported on this platform");
49228753Smm		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
50228753Smm		return;
51228753Smm	}
52228753Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
53228753Smm	assertEqualIntA(a, ARCHIVE_OK,
54228753Smm	    archive_read_open_memory(a, archive, sizeof(archive)));
55228753Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
56228753Smm	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_LZMA);
57228753Smm	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
58228753Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
59228753Smm	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
60228753Smm}
61