]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Add extraction tests for compressed files to bsdtar_test.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 3 Oct 2012 06:16:35 +0000 (15:16 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 3 Oct 2012 08:12:12 +0000 (17:12 +0900)
20 files changed:
Makefile.am
cpio/test/main.c
cpio/test/test.h
libarchive/test/main.c
libarchive/test/test.h
tar/test/CMakeLists.txt
tar/test/main.c
tar/test/test.h
tar/test/test_extract.tar.bz2.uu [new file with mode: 0644]
tar/test/test_extract.tar.gz.uu [new file with mode: 0644]
tar/test/test_extract.tar.lrz.uu [new file with mode: 0644]
tar/test/test_extract.tar.lz.uu [new file with mode: 0644]
tar/test/test_extract.tar.lzma.uu [new file with mode: 0644]
tar/test/test_extract.tar.xz.uu [new file with mode: 0644]
tar/test/test_extract_tar_bz2.c [new file with mode: 0644]
tar/test/test_extract_tar_gz.c [new file with mode: 0644]
tar/test/test_extract_tar_lrz.c [new file with mode: 0644]
tar/test/test_extract_tar_lz.c [new file with mode: 0644]
tar/test/test_extract_tar_lzma.c [new file with mode: 0644]
tar/test/test_extract_tar_xz.c [new file with mode: 0644]

index 70d4ec28e1a94d3c65f9a8416dcba9d98d8673bd..3e277aba530f882409fb7fdec8cae159e4855621 100644 (file)
@@ -699,6 +699,12 @@ bsdtar_test_SOURCES=                                               \
        tar/test/test_basic.c                                   \
        tar/test/test_copy.c                                    \
        tar/test/test_empty_mtree.c                             \
+       tar/test/test_extract_tar_bz2.c                         \
+       tar/test/test_extract_tar_gz.c                          \
+       tar/test/test_extract_tar_lrz.c                         \
+       tar/test/test_extract_tar_lz.c                          \
+       tar/test/test_extract_tar_lzma.c                        \
+       tar/test/test_extract_tar_xz.c                          \
        tar/test/test_format_newc.c                             \
        tar/test/test_help.c                                    \
        tar/test/test_option_C_upper.c                          \
index a016bcc1b07d42ffd976bfeb697812764e2e6bbd..d4cd865c50dbf9db926608653cb5341b8941f4ae 100644 (file)
@@ -1835,15 +1835,30 @@ 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 bunzip2 program?
+ */
+int
+canBunzip2(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("bunzip2 -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the gzip program?
+ */
 int
 canGzip(void)
 {
@@ -1871,6 +1886,81 @@ canGunzip(void)
        return (value);
 }
 
+/*
+ * 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 lrunzip program?
+ */
+int
+canLrunzip(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("lrunzip -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the lunzip program?
+ */
+int
+canLunzip(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("lunzip -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the unlzma program?
+ */
+int
+canUnlzma(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("unlzma -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the unxz program?
+ */
+int
+canUnxz(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("unxz -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
 /*
  * Can this filesystem handle nodump flags.
  */
index d57a861dcb0bea196d85ac45f0ddfc1131ff8699..88c7c243811efed8c044f3730e5d726b6af5a88b 100644 (file)
@@ -266,12 +266,30 @@ void sleepUntilAfter(time_t);
 /* Return true if this platform can create symlinks. */
 int canSymlink(void);
 
+/* Return true if this platform can run the "bunzip2" program. */
+int canBunzip2(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 "lrunzip" program. */
+int canLrunzip(void);
+
+/* Return true if this platform can run the "lunzip" program. */
+int canLunzip(void);
+
+/* Return true if this platform can run the "unlzma" program. */
+int canUnlzma(void);
+
+/* Return true if this platform can run the "unxz" program. */
+int canUnxz(void);
+
 /* Return true if this filesystem can handle nodump flags. */
 int canNodump(void);
 
index db160ddb19c0767cbb9fec8772c902cc0eb75c76..fd2e5dd9340db041cc8cfc1af00e4cb56cbbfa6a 100644 (file)
@@ -1833,15 +1833,30 @@ 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 bunzip2 program?
+ */
+int
+canBunzip2(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("bunzip2 -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the gzip program?
+ */
 int
 canGzip(void)
 {
@@ -1869,6 +1884,9 @@ canGunzip(void)
        return (value);
 }
 
+/*
+ * Can this platform run the lrzip program?
+ */
 int
 canLrzip(void)
 {
@@ -1881,6 +1899,66 @@ canLrzip(void)
        return (value);
 }
 
+/*
+ * Can this platform run the lrunzip program?
+ */
+int
+canLrunzip(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("lrunzip -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the lunzip program?
+ */
+int
+canLunzip(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("lunzip -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the unlzma program?
+ */
+int
+canUnlzma(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("unlzma -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the unxz program?
+ */
+int
+canUnxz(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("unxz -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
 /*
  * Can this filesystem handle nodump flags.
  */
index 6c5de6a716318491979d6b6467ea8f95ef622e79..eee985df4c1b408d041e74126344add766812099 100644 (file)
@@ -266,6 +266,9 @@ void sleepUntilAfter(time_t);
 /* Return true if this platform can create symlinks. */
 int canSymlink(void);
 
+/* Return true if this platform can run the "bunzip2" program. */
+int canBunzip2(void);
+
 /* Return true if this platform can run the "gzip" program. */
 int canGzip(void);
 
@@ -275,6 +278,18 @@ int canGunzip(void);
 /* Return true if this platform can run the "lrzip" program. */
 int canLrzip(void);
 
+/* Return true if this platform can run the "lrunzip" program. */
+int canLrunzip(void);
+
+/* Return true if this platform can run the "lunzip" program. */
+int canLunzip(void);
+
+/* Return true if this platform can run the "unlzma" program. */
+int canUnlzma(void);
+
+/* Return true if this platform can run the "unxz" program. */
+int canUnxz(void);
+
 /* Return true if this filesystem can handle nodump flags. */
 int canNodump(void);
 
index 6d74530da52243f6bb7effe702a5ab73e9660977..ffa8dcd11c34b2dd7d9e6dd7680142d79186c024 100644 (file)
@@ -12,6 +12,12 @@ IF(ENABLE_TAR AND ENABLE_TEST)
     test_basic.c
     test_copy.c
     test_empty_mtree.c
+    test_extract_tar_bz2.c
+    test_extract_tar_gz.c
+    test_extract_tar_lrz.c
+    test_extract_tar_lz.c
+    test_extract_tar_lzma.c
+    test_extract_tar_xz.c
     test_format_newc.c
     test_help.c
     test_option_C_upper.c
index d9f12c1ebb9e2a1485f33fab2fcfc1a262eda773..26bab757c6b6490bd054b8e1f48065edfdf75f06 100644 (file)
@@ -1835,15 +1835,30 @@ 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 bunzip2 program?
+ */
+int
+canBunzip2(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("bunzip2 -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the gzip program?
+ */
 int
 canGzip(void)
 {
@@ -1871,6 +1886,81 @@ canGunzip(void)
        return (value);
 }
 
+/*
+ * 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 lrunzip program?
+ */
+int
+canLrunzip(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("lrunzip -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the lunzip program?
+ */
+int
+canLunzip(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("lunzip -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the unlzma program?
+ */
+int
+canUnlzma(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("unlzma -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
+/*
+ * Can this platform run the unxz program?
+ */
+int
+canUnxz(void)
+{
+       static int tested = 0, value = 0;
+       if (!tested) {
+               tested = 1;
+               if (systemf("unxz -V %s", redirectArgs) == 0)
+                       value = 1;
+       }
+       return (value);
+}
+
 /*
  * Can this filesystem handle nodump flags.
  */
index 46abb59eceee18a07408545406e7a1431bf77e85..05d99c2a248bb68a23a43abf892a71899b20ee12 100644 (file)
@@ -268,12 +268,30 @@ void sleepUntilAfter(time_t);
 /* Return true if this platform can create symlinks. */
 int canSymlink(void);
 
+/* Return true if this platform can run the "bunzip2" program. */
+int canBunzip2(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 "lrunzip" program. */
+int canLrunzip(void);
+
+/* Return true if this platform can run the "lunzip" program. */
+int canLunzip(void);
+
+/* Return true if this platform can run the "unlzma" program. */
+int canUnlzma(void);
+
+/* Return true if this platform can run the "unxz" program. */
+int canUnxz(void);
+
 /* Return true if this filesystem can handle nodump flags. */
 int canNodump(void);
 
diff --git a/tar/test/test_extract.tar.bz2.uu b/tar/test/test_extract.tar.bz2.uu
new file mode 100644 (file)
index 0000000..9a37413
--- /dev/null
@@ -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/tar/test/test_extract.tar.gz.uu b/tar/test/test_extract.tar.gz.uu
new file mode 100644 (file)
index 0000000..19f8bc0
--- /dev/null
@@ -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/tar/test/test_extract.tar.lrz.uu b/tar/test/test_extract.tar.lrz.uu
new file mode 100644 (file)
index 0000000..a2621f4
--- /dev/null
@@ -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/tar/test/test_extract.tar.lz.uu b/tar/test/test_extract.tar.lz.uu
new file mode 100644 (file)
index 0000000..cb380e3
--- /dev/null
@@ -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/tar/test/test_extract.tar.lzma.uu b/tar/test/test_extract.tar.lzma.uu
new file mode 100644 (file)
index 0000000..581236a
--- /dev/null
@@ -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/tar/test/test_extract.tar.xz.uu b/tar/test/test_extract.tar.xz.uu
new file mode 100644 (file)
index 0000000..24cac6c
--- /dev/null
@@ -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/tar/test/test_extract_tar_bz2.c b/tar/test/test_extract_tar_bz2.c
new file mode 100644 (file)
index 0000000..e146d50
--- /dev/null
@@ -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 || canBunzip2()) {
+               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/tar/test/test_extract_tar_gz.c b/tar/test/test_extract_tar_gz.c
new file mode 100644 (file)
index 0000000..ba5fdec
--- /dev/null
@@ -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 || canGunzip()) {
+               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/tar/test/test_extract_tar_lrz.c b/tar/test/test_extract_tar_lrz.c
new file mode 100644 (file)
index 0000000..e08845f
--- /dev/null
@@ -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 || canLrunzip()) {
+               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/tar/test/test_extract_tar_lz.c b/tar/test/test_extract_tar_lz.c
new file mode 100644 (file)
index 0000000..f7ac3c3
--- /dev/null
@@ -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 || canLunzip()) {
+               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/tar/test/test_extract_tar_lzma.c b/tar/test/test_extract_tar_lzma.c
new file mode 100644 (file)
index 0000000..977f6d6
--- /dev/null
@@ -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 || canUnlzma()) {
+               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/tar/test/test_extract_tar_xz.c b/tar/test/test_extract_tar_xz.c
new file mode 100644 (file)
index 0000000..2edaf34
--- /dev/null
@@ -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 || canUnxz()) {
+               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");
+       }
+}