]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Add tests for --passphrase option.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sat, 4 Oct 2014 10:30:38 +0000 (19:30 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sat, 4 Oct 2014 10:33:46 +0000 (19:33 +0900)
Makefile.am
cpio/test/CMakeLists.txt
cpio/test/test_option_passphrase.c [new file with mode: 0644]
cpio/test/test_option_passphrase.zip.uu [new file with mode: 0644]
tar/test/CMakeLists.txt
tar/test/test_option_passphrase.c [new file with mode: 0644]
tar/test/test_option_passphrase.zip.uu [new file with mode: 0644]

index 76267d53043c7328ff7a9dc8761a6e38fae3d811..e7f7292ae450d05eacfba8a8d0d2a663ea6ac600 100644 (file)
@@ -913,6 +913,7 @@ bsdtar_test_SOURCES= \
        tar/test/test_option_newer_than.c \
        tar/test/test_option_nodump.c \
        tar/test/test_option_older_than.c \
+       tar/test/test_option_passphrase.c \
        tar/test/test_option_q.c \
        tar/test/test_option_r.c \
        tar/test/test_option_s.c \
@@ -958,6 +959,7 @@ bsdtar_test_EXTRA_DIST= \
        tar/test/test_extract.tar.lzo.uu \
        tar/test/test_extract.tar.xz.uu \
        tar/test/test_option_keep_newer_files.tar.Z.uu \
+       tar/test/test_option_passphrase.zip.uu \
        tar/test/test_option_s.tar.Z.uu \
        tar/test/test_patterns_2.tar.uu \
        tar/test/test_patterns_3.tar.uu \
@@ -1059,6 +1061,7 @@ bsdcpio_test_SOURCES= \
        cpio/test/test_option_lzma.c \
        cpio/test/test_option_lzop.c \
        cpio/test/test_option_m.c \
+       cpio/test/test_option_passphrase.c \
        cpio/test/test_option_t.c \
        cpio/test/test_option_u.c \
        cpio/test/test_option_uuencode.c \
@@ -1110,6 +1113,7 @@ bsdcpio_test_EXTRA_DIST= \
        cpio/test/test_gcpio_compat_ref_nosym.ustar.uu \
        cpio/test/test_option_f.cpio.uu \
        cpio/test/test_option_m.cpio.uu \
+       cpio/test/test_option_passphrase.zip.uu \
        cpio/test/test_option_t.cpio.uu \
        cpio/test/test_option_t.stdout.uu \
        cpio/test/test_option_tv.stdout.uu \
index ee900cdac33d57f2af8e3ac02068a2b2c6d51809..af502b13d226c8a019b4bb0930fd88348e71e46d 100644 (file)
@@ -44,6 +44,7 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
     test_option_lzma.c
     test_option_lzop.c
     test_option_m.c
+    test_option_passphrase.c
     test_option_t.c
     test_option_u.c
     test_option_uuencode.c
diff --git a/cpio/test/test_option_passphrase.c b/cpio/test/test_option_passphrase.c
new file mode 100644 (file)
index 0000000..ae77a23
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2014 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_passphrase)
+{
+       const char *reffile = "test_option_passphrase.zip";
+
+       extract_reference_file(reffile);
+       assertEqualInt(0,
+           systemf("%s -i --passphrase pass1 < %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");
+       assertTextFileContents("1 block\n", "test.err");
+}
diff --git a/cpio/test/test_option_passphrase.zip.uu b/cpio/test/test_option_passphrase.zip.uu
new file mode 100644 (file)
index 0000000..021ae85
--- /dev/null
@@ -0,0 +1,12 @@
+begin 644 test_option_passphrase.zip
+M4$L#!`H`"0```#B91$7D$C4,'P```!,````%`!P`9FEL93%55`D``VS'+U0"
+MQR]4=7@+``$$]0$```04````BHPD*"^*I04=XKI\_FQ*TE+#),TD7TTKSP/7
+MR6R35%!+!PCD$C4,'P```!,```!02P,$"@`)````09E$1;VL<PX?````$P``
+M``4`'`!F:6QE,E54"0`#><<O5`+'+U1U>`L``03U`0``!!0```!D#6Z\@CI8
+MV1GIJO5TISQF^I:7.;Y3<-G3$YOCL(C_4$L'"+VL<PX?````$P```%!+`0(>
+M`PH`"0```#B91$7D$C4,'P```!,````%`!@```````$```"D@0````!F:6QE
+M,554!0`#;,<O5'5X"P`!!/4!```$%````%!+`0(>`PH`"0```$&91$6]K',.
+M'P```!,````%`!@```````$```"D@6X```!F:6QE,E54!0`#><<O5'5X"P`!
+@!/4!```$%````%!+!08``````@`"`)8```#<````````
+`
+end
index 2f46727c83ca717ffa35f2d8ad6423ad209b451d..5e3e243afe95e1a316bcf26b0f77354fb7655705 100644 (file)
@@ -48,6 +48,7 @@ IF(ENABLE_TAR AND ENABLE_TEST)
     test_option_newer_than.c
     test_option_nodump.c
     test_option_older_than.c
+    test_option_passphrase.c
     test_option_q.c
     test_option_r.c
     test_option_s.c
diff --git a/tar/test/test_option_passphrase.c b/tar/test/test_option_passphrase.c
new file mode 100644 (file)
index 0000000..337292c
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2014 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_passphrase)
+{
+       const char *reffile = "test_option_passphrase.zip";
+
+       extract_reference_file(reffile);
+       failure("--passphrase option is broken");
+       assertEqualInt(0, systemf(
+           "%s --passphrase pass1 -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/tar/test/test_option_passphrase.zip.uu b/tar/test/test_option_passphrase.zip.uu
new file mode 100644 (file)
index 0000000..021ae85
--- /dev/null
@@ -0,0 +1,12 @@
+begin 644 test_option_passphrase.zip
+M4$L#!`H`"0```#B91$7D$C4,'P```!,````%`!P`9FEL93%55`D``VS'+U0"
+MQR]4=7@+``$$]0$```04````BHPD*"^*I04=XKI\_FQ*TE+#),TD7TTKSP/7
+MR6R35%!+!PCD$C4,'P```!,```!02P,$"@`)````09E$1;VL<PX?````$P``
+M``4`'`!F:6QE,E54"0`#><<O5`+'+U1U>`L``03U`0``!!0```!D#6Z\@CI8
+MV1GIJO5TISQF^I:7.;Y3<-G3$YOCL(C_4$L'"+VL<PX?````$P```%!+`0(>
+M`PH`"0```#B91$7D$C4,'P```!,````%`!@```````$```"D@0````!F:6QE
+M,554!0`#;,<O5'5X"P`!!/4!```$%````%!+`0(>`PH`"0```$&91$6]K',.
+M'P```!,````%`!@```````$```"D@6X```!F:6QE,E54!0`#><<O5'5X"P`!
+@!/4!```$%````%!+!08``````@`"`)8```#<````````
+`
+end