Path: blob/main/contrib/libarchive/cpio/test/test_option_f.c
39507 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2003-2007 Tim Kientzle4* All rights reserved.5*/6#include "test.h"78/*9* Unpack the archive in a new dir.10*/11static void12unpack(const char *dirname, const char *option)13{14int r;1516assertMakeDir(dirname, 0755);17assertChdir(dirname);18extract_reference_file("test_option_f.cpio");19r = systemf("%s -i %s < test_option_f.cpio > copy-no-a.out 2>copy-no-a.err", testprog, option);20assertEqualInt(0, r);21assertChdir("..");22}2324DEFINE_TEST(test_option_f)25{26/* Calibrate: No -f option, so everything should be extracted. */27unpack("t0", "--no-preserve-owner");28assertFileExists("t0/a123");29assertFileExists("t0/a234");30assertFileExists("t0/b123");31assertFileExists("t0/b234");3233/* Don't extract 'a*' files. */34#if defined(_WIN32) && !defined(__CYGWIN__)35/* Single quotes isn't used by command.exe. */36unpack("t1", "--no-preserve-owner -f a*");37#else38unpack("t1", "--no-preserve-owner -f 'a*'");39#endif40assertFileNotExists("t1/a123");41assertFileNotExists("t1/a234");42assertFileExists("t1/b123");43assertFileExists("t1/b234");4445/* Don't extract 'b*' files. */46#if defined(_WIN32) && !defined(__CYGWIN__)47/* Single quotes isn't used by command.exe. */48unpack("t2", "--no-preserve-owner -f b*");49#else50unpack("t2", "--no-preserve-owner -f 'b*'");51#endif52assertFileExists("t2/a123");53assertFileExists("t2/a234");54assertFileNotExists("t2/b123");55assertFileNotExists("t2/b234");56}575859