1248590Smm/*-
2248590Smm * Copyright (c) 2003-2007 Tim Kientzle
3248590Smm * Copyright (c) 2012 Michihiro NAKAJIMA
4248590Smm * All rights reserved.
5248590Smm *
6248590Smm * Redistribution and use in source and binary forms, with or without
7248590Smm * modification, are permitted provided that the following conditions
8248590Smm * are met:
9248590Smm * 1. Redistributions of source code must retain the above copyright
10248590Smm *    notice, this list of conditions and the following disclaimer.
11248590Smm * 2. Redistributions in binary form must reproduce the above copyright
12248590Smm *    notice, this list of conditions and the following disclaimer in the
13248590Smm *    documentation and/or other materials provided with the distribution.
14248590Smm *
15248590Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16248590Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17248590Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18248590Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19248590Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20248590Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21248590Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22248590Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23248590Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24248590Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25248590Smm */
26248590Smm#include "test.h"
27248590Smm__FBSDID("$FreeBSD$");
28248590Smm
29248590Smmstatic char archive_data[] = {
30248590Smm"begin 644 test_read_uu.Z\n"
31248590Smm"M'YV0+@`('$BPH,&#\"!,J7,BP(4(8$&_4J`$\"`,08$F%4O)AQ(\\2/(#7&@#%C\n"
32248590Smm"M!@T8-##.L`$\"QL@:-F(``%'#H<V;.'/J!%!G#ITP<BS\"H).FS<Z$1(T>/1A2\n"
33248590Smm"IHU\"0%9=*G4JUJM6K6+-JW<JUJ]>O8,.*'4NVK-FS:-.J7<NVK=NW9P$`\n"
34248590Smm"`\n"
35248590Smm"end\n"
36248590Smm"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
37248590Smm"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
38248590Smm"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
39248590Smm"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
40248590Smm};
41248590Smm
42248590Smm/*
43313570Smm * Compatibility: uudecode command ignores junk data placed after the "end"
44248590Smm * marker.
45248590Smm */
46248590SmmDEFINE_TEST(test_compat_uudecode)
47248590Smm{
48248590Smm	struct archive_entry *ae;
49248590Smm	struct archive *a;
50248590Smm
51248590Smm	assert((a = archive_read_new()) != NULL);
52248590Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
53248590Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
54248590Smm	assertEqualIntA(a, ARCHIVE_OK,
55248590Smm	    read_open_memory(a, archive_data, sizeof(archive_data), 2));
56248590Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
57248590Smm	assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_COMPRESS);
58248590Smm	assertEqualInt(archive_filter_code(a, 1), ARCHIVE_FILTER_UU);
59248590Smm	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
60248590Smm	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
61248590Smm	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
62248590Smm}
63248590Smm
64