From: Michihiro NAKAJIMA Date: Sat, 4 Oct 2014 10:30:38 +0000 (+0900) Subject: Add tests for --passphrase option. X-Git-Tag: v3.1.900a~198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9dc6b814679e4432bda5f455ff26e2da1472fcf;p=thirdparty%2Flibarchive.git Add tests for --passphrase option. --- diff --git a/Makefile.am b/Makefile.am index 76267d530..e7f7292ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/cpio/test/CMakeLists.txt b/cpio/test/CMakeLists.txt index ee900cdac..af502b13d 100644 --- a/cpio/test/CMakeLists.txt +++ b/cpio/test/CMakeLists.txt @@ -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 index 000000000..ae77a23fc --- /dev/null +++ b/cpio/test/test_option_passphrase.c @@ -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 index 000000000..021ae8585 --- /dev/null +++ b/cpio/test/test_option_passphrase.zip.uu @@ -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<`L``03U`0``!!0```!D#6Z\@CI8 +MV1GIJO5TISQF^I:7.;Y3<-G3$YOCL(C_4$L'"+VL +M`PH`"0```#B91$7D$C4,'P```!,````%`!@```````$```"D@0````!F:6QE +M,554!0`#;,`PH`"0```$&91$6]K',. +M'P```!,````%`!@```````$```"D@6X```!F:6QE,E54!0`#><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 index 000000000..021ae8585 --- /dev/null +++ b/tar/test/test_option_passphrase.zip.uu @@ -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<`L``03U`0``!!0```!D#6Z\@CI8 +MV1GIJO5TISQF^I:7.;Y3<-G3$YOCL(C_4$L'"+VL +M`PH`"0```#B91$7D$C4,'P```!,````%`!@```````$```"D@0````!F:6QE +M,554!0`#;,`PH`"0```$&91$6]K',. +M'P```!,````%`!@```````$```"D@6X```!F:6QE,E54!0`#><