From owner-svn-src-head@FreeBSD.ORG Sat Dec 6 07:08:08 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E05DD106564A; Sat, 6 Dec 2008 07:08:08 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CCD9A8FC17; Sat, 6 Dec 2008 07:08:08 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mB67884J086436; Sat, 6 Dec 2008 07:08:08 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mB6788wR086427; Sat, 6 Dec 2008 07:08:08 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200812060708.mB6788wR086427@svn.freebsd.org> From: Tim Kientzle Date: Sat, 6 Dec 2008 07:08:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185683 - head/lib/libarchive/test X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Dec 2008 07:08:09 -0000 Author: kientzle Date: Sat Dec 6 07:08:08 2008 New Revision: 185683 URL: http://svn.freebsd.org/changeset/base/185683 Log: New tests: * support for bzip2 file with multiple concatenated bzip2 streams * support for bzip2 file with junk after bzip2 stream * support for gzip file with junk after gzip stream * "fuzz" tester randomly modifies a bunch of input files in order to try to crash libarchive (this found an amusing hang in the ISO9660 code when trying to read images that advertised a zero blocksize). This test is implemented, but commented out for now: * support for gzip file with multiple concatenated gzip streams Added: head/lib/libarchive/test/test_compat_bzip2.c (contents, props changed) head/lib/libarchive/test/test_compat_bzip2_1.tbz.uu (contents, props changed) head/lib/libarchive/test/test_compat_bzip2_2.tbz.uu (contents, props changed) head/lib/libarchive/test/test_compat_gzip.c (contents, props changed) head/lib/libarchive/test/test_compat_gzip_1.tgz.uu (contents, props changed) head/lib/libarchive/test/test_compat_gzip_2.tgz.uu (contents, props changed) head/lib/libarchive/test/test_fuzz.c (contents, props changed) head/lib/libarchive/test/test_fuzz_1.iso.uu (contents, props changed) Modified: head/lib/libarchive/test/Makefile Modified: head/lib/libarchive/test/Makefile ============================================================================== --- head/lib/libarchive/test/Makefile Sat Dec 6 06:57:45 2008 (r185682) +++ head/lib/libarchive/test/Makefile Sat Dec 6 07:08:08 2008 (r185683) @@ -13,12 +13,15 @@ TESTS= \ test_acl_pax.c \ test_archive_api_feature.c \ test_bad_fd.c \ + test_compat_bzip2.c \ test_compat_gtar.c \ + test_compat_gzip.c \ test_compat_tar_hardlink.c \ test_compat_zip.c \ test_empty_write.c \ test_entry.c \ test_entry_strmode.c \ + test_fuzz.c \ test_link_resolver.c \ test_pax_filename_encoding.c \ test_read_compress_program.c \ Added: head/lib/libarchive/test/test_compat_bzip2.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libarchive/test/test_compat_bzip2.c Sat Dec 6 07:08:08 2008 (r185683) @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 2003-2008 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" +__FBSDID("$FreeBSD$"); + +/* + * Verify our ability to read sample files compatibly with bunzip2. + * + * In particular: + * * bunzip2 will read multiple bzip2 streams, concatenating the output + * * bunzip2 will stop at the end of a stream if the following data + * doesn't start with a bzip2 signature. + */ + +/* + * All of the sample files have the same contents; they're just + * compressed in different ways. + */ +static void +compat_bzip2(const char *name) +{ + const char *n[7] = { "f1", "f2", "f3", "d1/f1", "d1/f2", "d1/f3", NULL }; + struct archive_entry *ae; + struct archive *a; + int i,r; + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + extract_reference_file(name); + assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2)); + + /* Read entries, match up names with list above. */ + for (i = 0; i < 6; ++i) { + r = archive_read_next_header(a, &ae); + failure("Could not read file %d (%s) from %s", i, n[i], name); + assertEqualIntA(a, ARCHIVE_OK, r); + if (r != ARCHIVE_OK) { + archive_read_finish(a); + return; + } + assertEqualString(n[i], archive_entry_pathname(ae)); + } + + /* Verify the end-of-archive. */ + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + /* Verify that the format detection worked. */ + assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2); + assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); + + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); +#if ARCHIVE_VERSION_NUMBER < 2000000 + archive_read_finish(a); +#else + assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); +#endif +} + + +DEFINE_TEST(test_compat_bzip2) +{ + compat_bzip2("test_compat_bzip2_1.tbz"); + compat_bzip2("test_compat_bzip2_2.tbz"); +} + + Added: head/lib/libarchive/test/test_compat_bzip2_1.tbz.uu ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libarchive/test/test_compat_bzip2_1.tbz.uu Sat Dec 6 07:08:08 2008 (r185683) @@ -0,0 +1,24 @@ +$FreeBSD$ + +begin 644 test_compat_bzip2_1.tbz +M0EIH.3%!62936;12^)(``#-;D=$00`!_@``!8RT>$`0`$```""``5#5/*'J> +MD#(&30_5!H4_5-ZH`T``327U4@&L('"(9-%8<7&$I,`:7FXH+*\GV#JF<`PK29-8'OPDG36S\7HR&C(T:/U0:$U'I +MJ!ZC0`#VECO\[$10H'-Z@F*:6A1$H$V("2G0Q(U0(8=(7AK$S04#!)RXOAP% +MP:D%#Q;NO)\4UL23'2[\7````6YC1 +M$$`$?X```6,M'A`$`!````@@`'4-4S*,U!HT!HT?J@T)E-I--!H`![60EIH.3%!629364RNM^,```#?L-$00`#_@`0```AG +M+1X0`!`$```((`!U#5-,:1IH`TT,1^J#)&H]3U`T``!CX[_.[`F40.64EC"D +M()+?KX6,VP?6Y;F%5$XR[Y/D#*9),K3^+N2*<*$@9@ +MX6(`0EIH.3%!62936>ZM4*4```);D-$00`#O@``(9ST>$`0```@@`'0:IFC2 +M&F@!B:/U0:$R&H:&@`"KS^U=Y`BC`#FY2*9-8%%&13E$@%8ZF(&J!##]!#E` +MKVL'2LUW2.*C08`$)::#DQ05DF +?4UDI/)=P````0!!```0`(``A`(*#%W)%.%"0*3R7<``` +` +end Added: head/lib/libarchive/test/test_compat_bzip2_2.tbz.uu ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libarchive/test/test_compat_bzip2_2.tbz.uu Sat Dec 6 07:08:08 2008 (r185683) @@ -0,0 +1,11 @@ +$FreeBSD$ + +begin 644 test_compat_bzip2_2.tbz +M0EIH.3%!629361HI1P<``4#;D-$00`#_@``)9RT>$`0``!@P`/@#&$Q,F`F` +M`,83$R8"8``1133"1/2-J-#$/U3@;XVF9V'`Y3882XA$*KO6\WTL`]QU&J"8 +M$-=*Q$\@=`=QJ,TQ;3UH,NPT$-(!"HV&!ZO5D&@P-1D&1@'L<8&209QV9'G` +MW&PRZ0Q(-BT%&DG*DE.!U*#J.P]*#%-P9G`W9+34:#S&M`;@^1R^![C]:Y)U +MDF9/(\AR/@?P@^@I_B[DBG"A(#12C@X!3;VUE(&UOV=QL!06ER26`1T2G9F:EY)54XJ +MN>9`/*(`IX<(2#/D&F@GC`(Z``#S57',@'E&`TT,$I!EQ +M#;031@$5`0`Q!<\4Z`,``!^+"`B8OB))``-T97-T+7-P;&ET+G1A$0!3@\1D&;,-=!.&`5D``#7L]HO +MZ`,``!^+"`B8OB))``-T97-T+7-P;&ET+G1A57',@'E&`TT,$I!ER#;031@$>``"Y*#OBZ`,``!^+"`B8 +MOB))``-T97-T+7-P;&ET+G1A@ALXPP`]CXF=Q&A<:-UX>EN)C5M,AL;P +MO@V[0A=_.E39F2.B'*.?5QX2?Z\?XGE&27)F]L0)V>E_'7YY07\>OZ)Y1W6Q\!-J3!?H^Z_J7TG]%_"QK0?\]4[/>HZS^_^T\! +M_;>@@OY[=N2]6E\!JOH/P])_2OC^-X'YOV]+_]97@*K^A4K_C/Y;P/S?MZ5_ +MZRM`7?]<^L?_OR8P_P,`].D%,XR2*0`<``!4:&ES(&ES('5N