diff options
Diffstat (limited to 'contrib/libarchive/tar/test')
35 files changed, 1371 insertions, 103 deletions
diff --git a/contrib/libarchive/tar/test/main.c b/contrib/libarchive/tar/test/main.c index 0d617e3..bce0bd6 100644 --- a/contrib/libarchive/tar/test/main.c +++ b/contrib/libarchive/tar/test/main.c @@ -24,6 +24,7 @@ */ #include "test.h" +#include "test_utils.h" #ifdef HAVE_SYS_IOCTL_H #include <sys/ioctl.h> #endif @@ -91,6 +92,7 @@ __FBSDID("$FreeBSD$"); */ #if defined(_WIN32) && !defined(__CYGWIN__) #include <io.h> +#include <direct.h> #include <windows.h> #ifndef F_OK #define F_OK (0) @@ -389,7 +391,6 @@ failure_finish(void *extra) fprintf(stderr, " *** forcing core dump so failure can be debugged ***\n"); abort(); - exit(1); } } @@ -622,8 +623,8 @@ assertion_equal_string(const char *file, int line, if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0)) return (1); failure_start(file, line, "%s != %s", e1, e2); - l1 = strlen(e1); - l2 = strlen(e2); + l1 = (int)strlen(e1); + l2 = (int)strlen(e2); if (l1 < l2) l1 = l2; strdump(e1, v1, l1, utf8); @@ -746,6 +747,8 @@ assertion_equal_mem(const char *file, int line, assertion_count(file, line); if (v1 == v2 || (v1 != NULL && v2 != NULL && memcmp(v1, v2, l) == 0)) return (1); + if (v1 == NULL || v2 == NULL) + return (0); failure_start(file, line, "%s != %s", e1, e2); logprintf(" size %s = %d\n", ld, (int)l); @@ -839,9 +842,14 @@ assertion_equal_file(const char *filename, int line, const char *fn1, const char f1 = fopen(fn1, "rb"); f2 = fopen(fn2, "rb"); + if (f1 == NULL || f2 == NULL) { + if (f1) fclose(f1); + if (f2) fclose(f2); + return (0); + } for (;;) { - n1 = fread(buff1, 1, sizeof(buff1), f1); - n2 = fread(buff2, 1, sizeof(buff2), f2); + n1 = (int)fread(buff1, 1, sizeof(buff1), f1); + n2 = (int)fread(buff2, 1, sizeof(buff2), f2); if (n1 != n2) break; if (n1 == 0 && n2 == 0) { @@ -915,7 +923,7 @@ assertion_file_contents(const char *filename, int line, const void *buff, int s, return (0); } contents = malloc(s * 2); - n = fread(contents, 1, s * 2, f); + n = (int)fread(contents, 1, s * 2, f); fclose(f); if (n == s && memcmp(buff, contents, s) == 0) { free(contents); @@ -951,9 +959,9 @@ assertion_text_file_contents(const char *filename, int line, const char *buff, c failure_finish(NULL); return (0); } - s = strlen(buff); + s = (int)strlen(buff); contents = malloc(s * 2 + 128); - n = fread(contents, 1, s * 2 + 128 - 1, f); + n = (int)fread(contents, 1, s * 2 + 128 - 1, f); if (n >= 0) contents[n] = '\0'; fclose(f); @@ -1004,8 +1012,8 @@ assertion_file_contains_lines_any_order(const char *file, int line, char *buff; size_t buff_size; size_t expected_count, actual_count, i, j; - char **expected; - char *p, **actual; + char **expected = NULL; + char *p, **actual = NULL; char c; int expected_failure = 0, actual_failure = 0; @@ -1018,14 +1026,22 @@ assertion_file_contains_lines_any_order(const char *file, int line, return (0); } - /* Make a copy of the provided lines and count up the expected file size. */ - expected_count = 0; + /* Make a copy of the provided lines and count up the expected + * file size. */ for (i = 0; lines[i] != NULL; ++i) { } expected_count = i; - expected = malloc(sizeof(char *) * expected_count); - for (i = 0; lines[i] != NULL; ++i) { - expected[i] = strdup(lines[i]); + if (expected_count) { + expected = malloc(sizeof(char *) * expected_count); + if (expected == NULL) { + failure_start(pathname, line, "Can't allocate memory"); + failure_finish(NULL); + free(expected); + return (0); + } + for (i = 0; lines[i] != NULL; ++i) { + expected[i] = strdup(lines[i]); + } } /* Break the file into lines */ @@ -1037,11 +1053,19 @@ assertion_file_contains_lines_any_order(const char *file, int line, ++actual_count; c = *p; } - actual = malloc(sizeof(char *) * actual_count); - for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) { - if (*p != '\0') { - actual[j] = p; - ++j; + if (actual_count) { + actual = calloc(sizeof(char *), actual_count); + if (actual == NULL) { + failure_start(pathname, line, "Can't allocate memory"); + failure_finish(NULL); + free(expected); + return (0); + } + for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) { + if (*p != '\0') { + actual[j] = p; + ++j; + } } } @@ -1176,11 +1200,11 @@ assertion_file_time(const char *file, int line, #if defined(_WIN32) && !defined(__CYGWIN__) #define EPOC_TIME (116444736000000000ULL) - FILETIME ftime, fbirthtime, fatime, fmtime; + FILETIME fxtime, fbirthtime, fatime, fmtime; ULARGE_INTEGER wintm; HANDLE h; - ftime.dwLowDateTime = 0; - ftime.dwHighDateTime = 0; + fxtime.dwLowDateTime = 0; + fxtime.dwHighDateTime = 0; assertion_count(file, line); /* Note: FILE_FLAG_BACKUP_SEMANTICS applies to open @@ -1195,9 +1219,9 @@ assertion_file_time(const char *file, int line, } r = GetFileTime(h, &fbirthtime, &fatime, &fmtime); switch (type) { - case 'a': ftime = fatime; break; - case 'b': ftime = fbirthtime; break; - case 'm': ftime = fmtime; break; + case 'a': fxtime = fatime; break; + case 'b': fxtime = fbirthtime; break; + case 'm': fxtime = fmtime; break; } CloseHandle(h); if (r == 0) { @@ -1205,8 +1229,8 @@ assertion_file_time(const char *file, int line, failure_finish(NULL); return (0); } - wintm.LowPart = ftime.dwLowDateTime; - wintm.HighPart = ftime.dwHighDateTime; + wintm.LowPart = fxtime.dwLowDateTime; + wintm.HighPart = fxtime.dwHighDateTime; filet = (wintm.QuadPart - EPOC_TIME) / 10000000; filet_nsec = ((wintm.QuadPart - EPOC_TIME) % 10000000) * 100; nsec = (nsec / 100) * 100; /* Round the request */ @@ -1834,15 +1858,45 @@ canSymlink(void) return (value); } -/* - * Can this platform run the gzip program? - */ /* Platform-dependent options for hiding the output of a subcommand. */ #if defined(_WIN32) && !defined(__CYGWIN__) static const char *redirectArgs = ">NUL 2>NUL"; /* Win32 cmd.exe */ #else static const char *redirectArgs = ">/dev/null 2>/dev/null"; /* POSIX 'sh' */ #endif +/* + * Can this platform run the bzip2 program? + */ +int +canBzip2(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("bzip2 -d -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + +/* + * Can this platform run the grzip program? + */ +int +canGrzip(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("grzip -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + +/* + * Can this platform run the gzip program? + */ int canGzip(void) { @@ -1856,15 +1910,75 @@ canGzip(void) } /* - * Can this platform run the gunzip program? + * Can this platform run the lrzip program? + */ +int +canLrzip(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("lrzip -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + +/* + * Can this platform run the lzip program? + */ +int +canLzip(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("lzip -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + +/* + * Can this platform run the lzma program? */ int -canGunzip(void) +canLzma(void) { static int tested = 0, value = 0; if (!tested) { tested = 1; - if (systemf("gunzip -V %s", redirectArgs) == 0) + if (systemf("lzma -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + +/* + * Can this platform run the lzop program? + */ +int +canLzop(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("lzop -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + +/* + * Can this platform run the xz program? + */ +int +canXz(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("xz -V %s", redirectArgs) == 0) value = 1; } return (value); @@ -2124,7 +2238,7 @@ is_LargeInode(const char *file) /* Use "list.h" to create a list of all tests (functions and names). */ #undef DEFINE_TEST #define DEFINE_TEST(n) { n, #n, 0 }, -struct { void (*func)(void); const char *name; int failures; } tests[] = { +struct test_list_t tests[] = { #include "list.h" }; @@ -2377,65 +2491,6 @@ success: return strdup(buff); } -static int -get_test_set(int *test_set, int limit, const char *test) -{ - int start, end; - int idx = 0; - - if (test == NULL) { - /* Default: Run all tests. */ - for (;idx < limit; idx++) - test_set[idx] = idx; - return (limit); - } - if (*test >= '0' && *test <= '9') { - const char *vp = test; - start = 0; - while (*vp >= '0' && *vp <= '9') { - start *= 10; - start += *vp - '0'; - ++vp; - } - if (*vp == '\0') { - end = start; - } else if (*vp == '-') { - ++vp; - if (*vp == '\0') { - end = limit - 1; - } else { - end = 0; - while (*vp >= '0' && *vp <= '9') { - end *= 10; - end += *vp - '0'; - ++vp; - } - } - } else - return (-1); - if (start < 0 || end >= limit || start > end) - return (-1); - while (start <= end) - test_set[idx++] = start++; - } else { - size_t len = strlen(test); - for (start = 0; start < limit; ++start) { - const char *name = tests[start].name; - const char *p; - - while ((p = strchr(name, test[0])) != NULL) { - if (strncmp(p, test, len) == 0) { - test_set[idx++] = start; - break; - } else - name = p + 1; - } - - } - } - return ((idx == 0)?-1:idx); -} - int main(int argc, char **argv) { @@ -2720,10 +2775,11 @@ main(int argc, char **argv) do { int test_num; - test_num = get_test_set(test_set, limit, *argv); + test_num = get_test_set(test_set, limit, *argv, tests); if (test_num < 0) { printf("*** INVALID Test %s\n", *argv); free(refdir_alloc); + free(testprogdir); usage(progname); return (1); } diff --git a/contrib/libarchive/tar/test/test.h b/contrib/libarchive/tar/test/test.h index 4c6e9cb..74c85f2 100644 --- a/contrib/libarchive/tar/test/test.h +++ b/contrib/libarchive/tar/test/test.h @@ -268,11 +268,29 @@ void sleepUntilAfter(time_t); /* Return true if this platform can create symlinks. */ int canSymlink(void); +/* Return true if this platform can run the "bzip2" program. */ +int canBzip2(void); + +/* Return true if this platform can run the "grzip" program. */ +int canGrzip(void); + /* Return true if this platform can run the "gzip" program. */ int canGzip(void); -/* Return true if this platform can run the "gunzip" program. */ -int canGunzip(void); +/* Return true if this platform can run the "lrzip" program. */ +int canLrzip(void); + +/* Return true if this platform can run the "lzip" program. */ +int canLzip(void); + +/* Return true if this platform can run the "lzma" program. */ +int canLzma(void); + +/* Return true if this platform can run the "lzop" program. */ +int canLzop(void); + +/* Return true if this platform can run the "xz" program. */ +int canXz(void); /* Return true if this filesystem can handle nodump flags. */ int canNodump(void); diff --git a/contrib/libarchive/tar/test/test_copy.c b/contrib/libarchive/tar/test/test_copy.c index 5a1c4d0..6890d1a 100644 --- a/contrib/libarchive/tar/test/test_copy.c +++ b/contrib/libarchive/tar/test/test_copy.c @@ -29,6 +29,9 @@ __FBSDID("$FreeBSD$"); # include <limits.h> # include <sys/cygwin.h> #endif +#if defined(_WIN32) && !defined(__CYGWIN__) +# include <direct.h> +#endif /* * Try to figure out how deep we can go in our tests. Assumes that @@ -119,7 +122,7 @@ compute_filenames(void) if (i > 9) { buff[j--] = '0' + ((i / 10) % 10); if (i > 99) - buff[j--] = '0' + (i / 100); + buff[j--] = '0' + (char)(i / 100); } buff[j] = '_'; /* Guard against obvious screwups in the above code. */ @@ -202,7 +205,7 @@ verify_tree(size_t limit) sprintf(name1, "f/%s", filenames[i]); if (i <= limit) { assertFileExists(name1); - assertFileContents(name1, strlen(name1), name1); + assertFileContents(name1, (int)strlen(name1), name1); } sprintf(name2, "l/%s", filenames[i]); diff --git a/contrib/libarchive/tar/test/test_extract.tar.Z.uu b/contrib/libarchive/tar/test/test_extract.tar.Z.uu new file mode 100644 index 0000000..92713a5 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract.tar.Z.uu @@ -0,0 +1,9 @@ +begin 664 test_extract.tar.Z +M'YV09M*P*1,#@,&#"!,J7,BPH<.'$",BA$'1A@T:(`!0C'&C!HR,&SM^U$BQ +M9$D9,T#$D`%CAHP;-&"@Q`@C1HP9-FH```%#HL^?0(,*!5!G#ITP<DB.J5-F +M:,.E39TN-$D1)-6,4K-JW<JUZ]`Q;]S0*2-V#H@W9D`$'!C#A0*O<./*G4NW +MKMV[>//JW<O7X=HR,OH*=EC2(D:2'#U:33R2JDF4*EFZA"F31@V>-F?<Z,ES +ML.>'18\FI0@5;FFOCJV:Q/JYM>NM8,62I6,6K5J!@-V^WLV[M^_?P(,+'TZ\ +0N/'CR),K7\Z\N?/GT*,K!P`` +` +end diff --git a/contrib/libarchive/tar/test/test_extract.tar.bz2.uu b/contrib/libarchive/tar/test/test_extract.tar.bz2.uu new file mode 100644 index 0000000..9a37413 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract.tar.bz2.uu @@ -0,0 +1,7 @@ +begin 664 test_extract.tar.bz2 +M0EIH.3%!629368N]6:```'U[D=(0`"!``7^```AK)9X`!```$0`(,`"X#&$Q +M,F`F``,83$R8"8``*J:")M0TCQ30-/%-3*]V3EE!&(DSM8?BJ4J)=TSJ4/"B +M,?#R_6>?9K=+H02NT0V040P3.SHF:(573*)M5&;!-%6RO=6F5":N"+,"YZ;L +AV+<]%F[GWYCR<%FRKAPR=7VY+'+1)_B[DBG"A(1=ZLT` +` +end diff --git a/contrib/libarchive/tar/test/test_extract.tar.grz.uu b/contrib/libarchive/tar/test/test_extract.tar.grz.uu new file mode 100644 index 0000000..44651e1 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract.tar.grz.uu @@ -0,0 +1,7 @@ +begin 644 test_extract.tar.grz +M1U)::7!)20`"!#HI``P``*P,``#U````SP```'<````[-=0OM"R^UP#^C?Z< +MFGU0]I:>SW7]H01)1\WY:59("M_=V4[N[R*'`H&:'E=O@5B(?T,0?@)%-:_D +M;EUP)!JVN)@V_:ABYS3+[[6/R(NU,-::]'X&;,]:,HR[*3#R!@:W)IGC`,&G +8L+IZ7]FP=8U_R?CZ2XPO)"H-ME3@P]$` +` +end diff --git a/contrib/libarchive/tar/test/test_extract.tar.gz.uu b/contrib/libarchive/tar/test/test_extract.tar.gz.uu new file mode 100644 index 0000000..19f8bc0 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract.tar.gz.uu @@ -0,0 +1,7 @@ +begin 664 test_extract.tar.gz +M'XL(""S!:U```W1E<W1?97AT<F%C="YT87(`2\O,235DH"TP,#`P,S-1`-*& +MYJ8&R#04&!DK&!H9&!N9FP"9)@H&AH;&9J8,"@8T=A<8E!:7)!8!G9)<FHI7 +M'2%YB$\4X/00`<GY>26I>27%"OEI"FF@M*#'-=!.&@5T!*`X-Z*Q'23E?Q-3 +A</XW-QC-__0`Z/G?:#3_CX)1,`I&P8@```&.A<``#``` +` +end diff --git a/contrib/libarchive/tar/test/test_extract.tar.lrz.uu b/contrib/libarchive/tar/test/test_extract.tar.lrz.uu new file mode 100644 index 0000000..a2621f4 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract.tar.lrz.uu @@ -0,0 +1,9 @@ +begin 664 test_extract.tar.lrz +M3%):20`&``P``````````%T````!`0```@$`$`,`````#@`#`````$P``S<` +M-P`````5``%/`!```#H``6,``0``6``!IP`!```%`@%/`/`#`3T```0`"0`! +M=@$`!`#P!0```(5'8Z<&<`"E"````#,:2=:X2EY$(`=+>P?_D@0*H:&)P-5? +MZX%NI60,IT@(N<,S%?7H2TLP5)FN#[-;&&[/2A#BNH4(7#C+*&ZP<>K&B)AG +M:Z(;Y=]3<5Q$)_[[5M\7=]N7A$%\ZF:H2/,Q%BK$JA4L!,K(-RZU2X[/`%69 +.9U@/B[!N",NH4]8F,M(` +` +end diff --git a/contrib/libarchive/tar/test/test_extract.tar.lz.uu b/contrib/libarchive/tar/test/test_extract.tar.lz.uu new file mode 100644 index 0000000..cb380e3 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract.tar.lz.uu @@ -0,0 +1,7 @@ +begin 664 test_extract.tar.lz +M3%I)4`$,`#,:2=:X2EY2J/TZ6]L7]]N4K?J&A)E2#"A'E"T1EP+MU&;(P1FY +MV\,8BTS,N0/O2=#67;G5)%I'C,D.U?*T!NX("FYPYI9I40F>X))?^8\?E?#> +MOP";"GD#8(9*K;XP318H<O&!L/<?HIOYPSNA8V5:E"239/Z<6[6>XZ\?_^SZ +6K-(!CH7```P```````"=```````````` +` +end diff --git a/contrib/libarchive/tar/test/test_extract.tar.lzma.uu b/contrib/libarchive/tar/test/test_extract.tar.lzma.uu new file mode 100644 index 0000000..581236a --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract.tar.lzma.uu @@ -0,0 +1,7 @@ +begin 664 test_extract.tar.lzma +M70``@`#__________P`S&DG6N$I>4JC].EO;%_?;E*WZAH294@PH1Y0M$9<" +M[=1FR,$9N=O#&(M,Q24U'H+5Z^7^*J;G!)OU]O'2D;AZ&0^IO?>-YA]$:-X_ +MD^O)YVM(4`^-MT$X`.D(6)*$]3HNB9KJ_H=1$QKYZ:`:,H_L"H[#"?#Z5A<] +%O_OZW=D` +` +end diff --git a/contrib/libarchive/tar/test/test_extract.tar.lzo.uu b/contrib/libarchive/tar/test/test_extract.tar.lzo.uu new file mode 100644 index 0000000..29dd8d8 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract.tar.lzo.uu @@ -0,0 +1,9 @@ +begin 664 test_extract.tar.lzo +MB4Q:3P`-"AH*$#`@8`E``04#```!``"!M%!R@T``````$'1E<W1?97AT<F%C +M="YT87*FJ0IM```,`````+BYG#.C`V9I;&4Q`"`]```+,#`P-C8T(``P,#$W +M-3`J'0`PH```!C(S(#$R,#,R-S0P,C,T(#`Q,3,V-0`@,"`]6`*T"PAU<W1A +M<@`P,&-U9:`"-10`/GP`I!EP&V4!(#44`2!P6``)8V]N=&5N=',@;V8@CD$N +M"B!PC`(@`#Q``FT^,B`^@`4@#/X/-#6>?S<P(`!6_0\R(`#/_`\@/N@/(``` +=`')X`0X``````````````````````!$````````` +` +end diff --git a/contrib/libarchive/tar/test/test_extract.tar.xz.uu b/contrib/libarchive/tar/test/test_extract.tar.xz.uu new file mode 100644 index 0000000..24cac6c --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract.tar.xz.uu @@ -0,0 +1,8 @@ +begin 664 test_extract.tar.xz +M_3=Z6%H```3FUK1&`@`A`18```!T+^6CX`O_`'E=`#,:2=:X2EY2J/TZ6]L7 +M]]N4K?J&A)E2#"A'E"T1EP+MU&;(P1FYV\,8BTS%)34>@M7KY?XJIN<$F_7V +M\=*1N'H9#ZF]]XWF'T1HWC^3Z\GG:TA0#XVW03@`Z0A8DH3U.BZ)FNK^AU$3 +M&OGIH!HRC^P*CL,)\/,MGP``````2IVA+$<(^YX``94!@!@``&X^\DRQQ&?[ +(`@`````$65H` +` +end diff --git a/contrib/libarchive/tar/test/test_extract_tar_Z.c b/contrib/libarchive/tar/test/test_extract_tar_Z.c new file mode 100644 index 0000000..7c994b4 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract_tar_Z.c @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_extract_tar_Z) +{ + const char *reffile = "test_extract.tar.Z"; + + extract_reference_file(reffile); + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); +} diff --git a/contrib/libarchive/tar/test/test_extract_tar_bz2.c b/contrib/libarchive/tar/test/test_extract_tar_bz2.c new file mode 100644 index 0000000..b734dd2 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract_tar_bz2.c @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_extract_tar_bz2) +{ + const char *reffile = "test_extract.tar.bz2"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canBzip2()) { + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems bzip2 is not supported on this platform"); + } +} diff --git a/contrib/libarchive/tar/test/test_extract_tar_grz.c b/contrib/libarchive/tar/test/test_extract_tar_grz.c new file mode 100644 index 0000000..9c0615e --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract_tar_grz.c @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_extract_tar_grz) +{ + const char *reffile = "test_extract.tar.grz"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canGrzip()) { + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems grzip is not supported on this platform"); + } +} diff --git a/contrib/libarchive/tar/test/test_extract_tar_gz.c b/contrib/libarchive/tar/test/test_extract_tar_gz.c new file mode 100644 index 0000000..2fdb4ba --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract_tar_gz.c @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_extract_tar_gz) +{ + const char *reffile = "test_extract.tar.gz"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canGzip()) { + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems gzip is not supported on this platform"); + } +} diff --git a/contrib/libarchive/tar/test/test_extract_tar_lrz.c b/contrib/libarchive/tar/test/test_extract_tar_lrz.c new file mode 100644 index 0000000..56a0fb8 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract_tar_lrz.c @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_extract_tar_lrz) +{ + const char *reffile = "test_extract.tar.lrz"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canLrzip()) { + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems lrzip is not supported on this platform"); + } +} diff --git a/contrib/libarchive/tar/test/test_extract_tar_lz.c b/contrib/libarchive/tar/test/test_extract_tar_lz.c new file mode 100644 index 0000000..5ec7e9a --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract_tar_lz.c @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_extract_tar_lz) +{ + const char *reffile = "test_extract.tar.lz"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canLzip()) { + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems lzip is not supported on this platform"); + } +} diff --git a/contrib/libarchive/tar/test/test_extract_tar_lzma.c b/contrib/libarchive/tar/test/test_extract_tar_lzma.c new file mode 100644 index 0000000..2fa2af0 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract_tar_lzma.c @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_extract_tar_lzma) +{ + const char *reffile = "test_extract.tar.lzma"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canLzma()) { + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems lzma is not supported on this platform"); + } +} diff --git a/contrib/libarchive/tar/test/test_extract_tar_lzo.c b/contrib/libarchive/tar/test/test_extract_tar_lzo.c new file mode 100644 index 0000000..17b4295 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract_tar_lzo.c @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_extract_tar_lzo) +{ + const char *reffile = "test_extract.tar.lzo"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canLzop()) { + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems lzop is not supported on this platform"); + } +} diff --git a/contrib/libarchive/tar/test/test_extract_tar_xz.c b/contrib/libarchive/tar/test/test_extract_tar_xz.c new file mode 100644 index 0000000..860bab7 --- /dev/null +++ b/contrib/libarchive/tar/test/test_extract_tar_xz.c @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_extract_tar_xz) +{ + const char *reffile = "test_extract.tar.xz"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canXz()) { + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems xz is not supported on this platform"); + } +} diff --git a/contrib/libarchive/tar/test/test_option_a.c b/contrib/libarchive/tar/test/test_option_a.c new file mode 100644 index 0000000..a000621 --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_a.c @@ -0,0 +1,110 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_a) +{ + size_t s; + char *p; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Test1: archive it with .tar.Z suffix. */ + assertEqualInt(0, + systemf("%s -acf test1.tar.Z f 2>test1.err", testprog)); + assertEmptyFile("test1.err"); + /* Check that the archive file has a compress signature. */ + p = slurpfile(&s, "test1.tar.Z"); + assert(s > 2); + failure("The archive should be compressed"); + assertEqualMem(p, "\x1f\x9d", 2); + + /* Test2: archive it with .taZ suffix. */ + assertEqualInt(0, + systemf("%s -acf test2.taZ f 2>test2.err", testprog)); + assertEmptyFile("test2.err"); + /* Check that the archive file has a compress signature. */ + p = slurpfile(&s, "test2.taZ"); + assert(s > 2); + failure("The archive should be compressed"); + assertEqualMem(p, "\x1f\x9d", 2); + + /* Test3: archive it with .tar.Z.uu suffix. */ + assertEqualInt(0, + systemf("%s -acf test3.tar.Z.uu f 2>test3.err", testprog)); + assertEmptyFile("test3.err"); + /* Check that the archive file has a compress signature. */ + p = slurpfile(&s, "test3.tar.Z.uu"); + assert(s > 12); + failure("The archive should be uuencoded"); + assertEqualMem(p, "begin 644 -\n", 12); + + /* Test4: archive it with .zip suffix. */ + assertEqualInt(0, + systemf("%s -acf test4.zip f 2>test4.err", testprog)); + assertEmptyFile("test4.err"); + /* Check that the archive file has a compress signature. */ + p = slurpfile(&s, "test4.zip"); + assert(s > 4); + failure("The archive should be zipped"); + assertEqualMem(p, "\x50\x4b\x03\x04", 4); + + /* Test5: archive it with .tar.Z suffix and --uuencode option. */ + assertEqualInt(0, + systemf("%s -acf test5.tar.Z --uuencode f 2>test5.err", + testprog)); + assertEmptyFile("test5.err"); + /* Check that the archive file has a compress signature. */ + p = slurpfile(&s, "test5.tar.Z"); + assert(s > 2); + failure("The archive should be compressed, ignoring --uuencode option"); + assertEqualMem(p, "\x1f\x9d", 2); + + /* Test6: archive it with .xxx suffix(unknown suffix) and + * --uuencode option. */ + assertEqualInt(0, + systemf("%s -acf test6.xxx --uuencode f 2>test6.err", + testprog)); + assertEmptyFile("test6.err"); + /* Check that the archive file has a compress signature. */ + p = slurpfile(&s, "test6.xxx"); + assert(s > 12); + failure("The archive should be uuencoded"); + assertEqualMem(p, "begin 644 -\n", 12); + + /* Test7: archive it with .tar.Z suffix using a long-name option. */ + assertEqualInt(0, + systemf("%s --auto-compress -cf test7.tar.Z f 2>test7.err", + testprog)); + assertEmptyFile("test7.err"); + /* Check that the archive file has a compress signature. */ + p = slurpfile(&s, "test7.tar.Z"); + assert(s > 2); + failure("The archive should be compressed"); + assertEqualMem(p, "\x1f\x9d", 2); +} diff --git a/contrib/libarchive/tar/test/test_option_b64encode.c b/contrib/libarchive/tar/test/test_option_b64encode.c new file mode 100644 index 0000000..1e7c571 --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_b64encode.c @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_b64encode) +{ + char *p; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with compress compression and uuencode. */ + assertEqualInt(0, + systemf("%s -cf - -Z --b64encode f >archive.out 2>archive.err", + testprog)); + /* Check that the archive file has an uuencode signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "begin-base64 644", 16); + + /* Archive it with uuencode only. */ + assertEqualInt(0, + systemf("%s -cf - --b64encode f >archive.out 2>archive.err", + testprog)); + /* Check that the archive file has an uuencode signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "begin-base64 644", 16); +} diff --git a/contrib/libarchive/tar/test/test_option_grzip.c b/contrib/libarchive/tar/test/test_option_grzip.c new file mode 100644 index 0000000..5132eee --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_grzip.c @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_grzip) +{ + char *p; + size_t s; + + if (!canGrzip()) { + skipping("grzip is not supported on this platform"); + return; + } + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with grzip compression. */ + assertEqualInt(0, + systemf("%s -cf - --grzip f >archive.out 2>archive.err", + testprog)); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + /* Check that the archive file has an grzip signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12); +} diff --git a/contrib/libarchive/tar/test/test_option_j.c b/contrib/libarchive/tar/test/test_option_j.c new file mode 100644 index 0000000..3202c3b --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_j.c @@ -0,0 +1,56 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_j) +{ + char *p; + int r; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with bzip2 compression. */ + r = systemf("%s -jcf archive.out f 2>archive.err", testprog); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + if (r != 0) { + if (!canBzip2()) { + skipping("bzip2 is not supported on this platform"); + return; + } + failure("-j option is broken"); + assertEqualInt(r, 0); + return; + } + assertEmptyFile("archive.err"); + /* Check that the archive file has a bzip2 signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "BZh9", 4); +} diff --git a/contrib/libarchive/tar/test/test_option_lrzip.c b/contrib/libarchive/tar/test/test_option_lrzip.c new file mode 100644 index 0000000..d3486a3 --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_lrzip.c @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_lrzip) +{ + char *p; + size_t s; + + if (!canLrzip()) { + skipping("lrzip is not supported on this platform"); + return; + } + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with lrzip compression. */ + assertEqualInt(0, + systemf("%s -cf - --lrzip f >archive.out 2>archive.err", + testprog)); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + /* Check that the archive file has an lzma signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "LRZI\x00", 5); +} diff --git a/contrib/libarchive/tar/test/test_option_lzma.c b/contrib/libarchive/tar/test/test_option_lzma.c new file mode 100644 index 0000000..a845666 --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_lzma.c @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_lzma) +{ + char *p; + int r; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with lzma compression. */ + r = systemf("%s -cf - --lzma f >archive.out 2>archive.err", + testprog); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + if (r != 0) { + if (strstr(p, "Unsupported compression") != NULL) { + skipping("This version of bsdtar was compiled " + "without lzma support"); + return; + } + failure("--lzma option is broken"); + assertEqualInt(r, 0); + return; + } + /* Check that the archive file has an lzma signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "\x5d\00\00", 3); +} diff --git a/contrib/libarchive/tar/test/test_option_lzop.c b/contrib/libarchive/tar/test/test_option_lzop.c new file mode 100644 index 0000000..1145499 --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_lzop.c @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_lzop) +{ + char *p; + int r; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with lzop compression. */ + r = systemf("%s -cf - --lzop f >archive.out 2>archive.err", testprog); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + if (r != 0) { + if (!canLzop()) { + skipping("lzop is not supported on this platform"); + return; + } + failure("--lzop option is broken"); + assertEqualInt(r, 0); + return; + } + /* Check that the archive file has an lzma signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9); +} diff --git a/contrib/libarchive/tar/test/test_option_newer_than.c b/contrib/libarchive/tar/test/test_option_newer_than.c index c9432dc..2a5fe04 100644 --- a/contrib/libarchive/tar/test/test_option_newer_than.c +++ b/contrib/libarchive/tar/test/test_option_newer_than.c @@ -48,8 +48,11 @@ DEFINE_TEST(test_option_newer_than) assertMakeFile("a/b/new.txt", 0644, "new file in old directory"); /* Test --newer-than on create */ - assertEqualInt(0, systemf("%s -cf ../test1.tar --newer-than middle.txt *.txt a", testprog)); - assertEqualInt(0, systemf("%s -cf ../test2.tar *.txt a", testprog)); + assertEqualInt(0, + systemf("%s --format pax -cf ../test1.tar " + "--newer-than middle.txt *.txt a", testprog)); + assertEqualInt(0, + systemf("%s --format pax -cf ../test2.tar *.txt a", testprog)); assertChdir(".."); /* Extract test1.tar to a clean dir and verify what got archived. */ diff --git a/contrib/libarchive/tar/test/test_option_older_than.c b/contrib/libarchive/tar/test/test_option_older_than.c new file mode 100644 index 0000000..4bdd2ed --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_older_than.c @@ -0,0 +1,85 @@ +/*- + * Copyright (c) 2010 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_older_than) +{ + struct stat st; + + /* + * Basic test of --older-than. + * First, create three files with different mtimes. + * Create test1.tar with --older-than, test2.tar without. + */ + assertMakeDir("test1in", 0755); + assertChdir("test1in"); + assertMakeDir("a", 0755); + assertMakeDir("a/b", 0755); + assertMakeFile("old.txt", 0644, "old.txt"); + assertMakeFile("a/b/old.txt", 0644, "old file in old directory"); + assertEqualInt(0, stat("old.txt", &st)); + sleepUntilAfter(st.st_mtime); + assertMakeFile("middle.txt", 0644, "middle.txt"); + assertEqualInt(0, stat("middle.txt", &st)); + sleepUntilAfter(st.st_mtime); + assertMakeFile("new.txt", 0644, "new"); + assertMakeFile("a/b/new.txt", 0644, "new file in old directory"); + + /* Test --older-than on create */ + assertEqualInt(0, + systemf("%s --format pax -cf ../test1.tar " + "--older-than middle.txt *.txt a", + testprog)); + assertEqualInt(0, + systemf("%s --format pax -cf ../test2.tar *.txt a", + testprog)); + assertChdir(".."); + + /* Extract test1.tar to a clean dir and verify what got archived. */ + assertMakeDir("test1out", 0755); + assertChdir("test1out"); + assertEqualInt(0, systemf("%s xf ../test1.tar", testprog)); + assertFileNotExists("new.txt"); + assertFileNotExists("a/b/new.txt"); + assertFileNotExists("middle.txt"); + assertFileExists("old.txt"); + assertFileExists("a/b/old.txt"); + assertChdir(".."); + + /* Extract test2.tar to a clean dir with --older-than and verify. */ + assertMakeDir("test2out", 0755); + assertChdir("test2out"); + assertEqualInt(0, + systemf("%s xf ../test2.tar --older-than ../test1in/middle.txt", + testprog)); + assertFileNotExists("new.txt"); + assertFileNotExists("a/b/new.txt"); + assertFileNotExists("middle.txt"); + assertFileExists("old.txt"); + assertFileExists("a/b/old.txt"); + assertChdir(".."); +} diff --git a/contrib/libarchive/tar/test/test_option_r.c b/contrib/libarchive/tar/test/test_option_r.c index 70c2087..7787685 100644 --- a/contrib/libarchive/tar/test/test_option_r.c +++ b/contrib/libarchive/tar/test/test_option_r.c @@ -60,6 +60,11 @@ DEFINE_TEST(test_option_r) /* Edit that file with a lot more data and update the archive with a new copy. */ buff = malloc(buff_size); assert(buff != NULL); + if (buff == NULL) { + free(p0); + return; + } + for (i = 0; i < (int)buff_size; ++i) buff[i] = "abcdefghijklmnopqrstuvwxyz"[rand() % 26]; buff[buff_size - 1] = '\0'; @@ -126,5 +131,5 @@ DEFINE_TEST(test_option_r) assertEmptyFile("extract.err"); /* Verify that the second copy of f1 overwrote the first. */ - assertFileContents(buff, strlen(buff), "f1"); + assertFileContents(buff, (int)strlen(buff), "f1"); } diff --git a/contrib/libarchive/tar/test/test_option_uuencode.c b/contrib/libarchive/tar/test/test_option_uuencode.c new file mode 100644 index 0000000..cdc6bab --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_uuencode.c @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_uuencode) +{ + char *p; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with compress compression and uuencode. */ + assertEqualInt(0, + systemf("%s -cf - -Z --uuencode f >archive.out 2>archive.err", + testprog)); + /* Check that the archive file has an uuencode signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "begin 644", 9); + + /* Archive it with uuencode only. */ + assertEqualInt(0, + systemf("%s -cf - --uuencode f >archive.out 2>archive.err", + testprog)); + /* Check that the archive file has an uuencode signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "begin 644", 9); +} diff --git a/contrib/libarchive/tar/test/test_option_xz.c b/contrib/libarchive/tar/test/test_option_xz.c new file mode 100644 index 0000000..7387a60 --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_xz.c @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_xz) +{ + char *p; + int r; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with xz compression. */ + r = systemf("%s -cf - --xz f >archive.out 2>archive.err", + testprog); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + if (r != 0) { + if (strstr(p, "Unsupported compression") != NULL) { + skipping("This version of bsdtar was compiled " + "without xz support"); + return; + } + failure("--xz option is broken"); + assertEqualInt(r, 0); + return; + } + /* Check that the archive file has an xz signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "\xFD\x37\x7A\x58\x5A\x00", 6); +} diff --git a/contrib/libarchive/tar/test/test_option_z.c b/contrib/libarchive/tar/test/test_option_z.c new file mode 100644 index 0000000..1f952ab --- /dev/null +++ b/contrib/libarchive/tar/test/test_option_z.c @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2012 Michihiro NAKAJIMA + * 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$"); + +DEFINE_TEST(test_option_z) +{ + char *p; + int r; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with gzip compression. */ + r = systemf("%s -zcf archive.out f 2>archive.err", testprog); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + if (r != 0) { + if (!canGzip()) { + skipping("gzip is not supported on this platform"); + return; + } + failure("-z option is broken"); + assertEqualInt(r, 0); + return; + } + /* Check that the archive file has a gzip signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 4); + assertEqualMem(p, "\x1f\x8b\x08\x00", 4); +} diff --git a/contrib/libarchive/tar/test/test_stdio.c b/contrib/libarchive/tar/test/test_stdio.c index 1780d96..8d44dd6 100644 --- a/contrib/libarchive/tar/test/test_stdio.c +++ b/contrib/libarchive/tar/test/test_stdio.c @@ -113,7 +113,7 @@ DEFINE_TEST(test_stdio) assertEqualInt(r, 0); /* Verify xvOf.out is the file contents */ p = slurpfile(&s, "xvOf.out"); - assert(s = 3); + assertEqualInt((int)s, 3); assertEqualMem(p, "abc", 3); /* TODO: Verify xvf.err */ |