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 \
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)
{
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.
*/
/* 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);
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)
{
return (value);
}
+/*
+ * Can this platform run the lrzip program?
+ */
int
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.
*/
/* 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 "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);
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
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)
{
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.
*/
/* 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);
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+/*-
+ * 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");
+ }
+}
--- /dev/null
+/*-
+ * 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");
+ }
+}
--- /dev/null
+/*-
+ * 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");
+ }
+}
--- /dev/null
+/*-
+ * 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");
+ }
+}
--- /dev/null
+/*-
+ * 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");
+ }
+}
--- /dev/null
+/*-
+ * 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");
+ }
+}