Path: blob/main/contrib/libarchive/unzip/test/test_x.c
108009 views
/*1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2023 Adrian Vovk4* All rights reserved.5*/6#include "test.h"78/* Test x arg with single exclude path */9DEFINE_TEST(test_x_single)10{11#ifdef HAVE_LIBZ12const char *reffile = "test_basic.zip";13int r;1415extract_reference_file(reffile);16r = systemf("%s %s -x test_basic/c >test.out 2>test.err", testprog, reffile);17assertEqualInt(0, r);18assertNonEmptyFile("test.out");19assertEmptyFile("test.err");2021assertTextFileContents("contents a\n", "test_basic/a");22assertTextFileContents("contents b\n", "test_basic/b");23assertFileNotExists("test_basic/c");24assertTextFileContents("contents CAPS\n", "test_basic/CAPS");25#else26skipping("zlib not available");27#endif28}2930/* Test x arg with multiple exclude paths */31DEFINE_TEST(test_x_multiple)32{33#ifdef HAVE_LIBZ34const char *reffile = "test_basic.zip";35int r;3637extract_reference_file(reffile);38r = systemf("%s %s -x test_basic/c test_basic/b >test.out 2>test.err", testprog, reffile);39assertEqualInt(0, r);40assertNonEmptyFile("test.out");41assertEmptyFile("test.err");4243assertTextFileContents("contents a\n", "test_basic/a");44assertFileNotExists("test_basic/b");45assertFileNotExists("test_basic/c");46assertTextFileContents("contents CAPS\n", "test_basic/CAPS");47#else48skipping("zlib not available");49#endif50}5152/* Test x arg with multiple exclude paths and a d arg afterwards */53DEFINE_TEST(test_x_multiple_with_d)54{55#ifdef HAVE_LIBZ56const char *reffile = "test_basic.zip";57int r;5859extract_reference_file(reffile);60r = systemf("%s %s -x test_basic/c test_basic/b -d foobar >test.out 2>test.err", testprog, reffile);61assertEqualInt(0, r);62assertNonEmptyFile("test.out");63assertEmptyFile("test.err");6465assertTextFileContents("contents a\n", "foobar/test_basic/a");66assertFileNotExists("foobar/test_basic/b");67assertFileNotExists("foobar/test_basic/c");68assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS");69#else70skipping("zlib not available");71#endif72}737475