1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2003-2007 Tim Kientzle 5 * All rights reserved. 6 */ 7 #include "test.h" 8 9 /* 10 * Unpack the archive in a new dir. 11 */ 12 static void 13 unpack(const char *dirname, const char *option) 14 { 15 int r; 16 17 assertMakeDir(dirname, 0755); 18 assertChdir(dirname); 19 extract_reference_file("test_option_f.cpio"); 20 r = systemf("%s -i %s < test_option_f.cpio > copy-no-a.out 2>copy-no-a.err", testprog, option); 21 assertEqualInt(0, r); 22 assertChdir(".."); 23 } 24 25 DEFINE_TEST(test_option_f) 26 { 27 /* Calibrate: No -f option, so everything should be extracted. */ 28 unpack("t0", "--no-preserve-owner"); 29 assertFileExists("t0/a123"); 30 assertFileExists("t0/a234"); 31 assertFileExists("t0/b123"); 32 assertFileExists("t0/b234"); 33 34 /* Don't extract 'a*' files. */ 35 #if defined(_WIN32) && !defined(__CYGWIN__) 36 /* Single quotes isn't used by command.exe. */ 37 unpack("t1", "--no-preserve-owner -f a*"); 38 #else 39 unpack("t1", "--no-preserve-owner -f 'a*'"); 40 #endif 41 assertFileNotExists("t1/a123"); 42 assertFileNotExists("t1/a234"); 43 assertFileExists("t1/b123"); 44 assertFileExists("t1/b234"); 45 46 /* Don't extract 'b*' files. */ 47 #if defined(_WIN32) && !defined(__CYGWIN__) 48 /* Single quotes isn't used by command.exe. */ 49 unpack("t2", "--no-preserve-owner -f b*"); 50 #else 51 unpack("t2", "--no-preserve-owner -f 'b*'"); 52 #endif 53 assertFileExists("t2/a123"); 54 assertFileExists("t2/a234"); 55 assertFileNotExists("t2/b123"); 56 assertFileNotExists("t2/b234"); 57 } 58