Path: blob/main/contrib/libarchive/unzip/test/test_x.c
39483 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{11const char *reffile = "test_basic.zip";12int r;1314extract_reference_file(reffile);15r = systemf("%s %s -x test_basic/c >test.out 2>test.err", testprog, reffile);16assertEqualInt(0, r);17assertNonEmptyFile("test.out");18assertEmptyFile("test.err");1920assertTextFileContents("contents a\n", "test_basic/a");21assertTextFileContents("contents b\n", "test_basic/b");22assertFileNotExists("test_basic/c");23assertTextFileContents("contents CAPS\n", "test_basic/CAPS");24}2526/* Test x arg with multiple exclude paths */27DEFINE_TEST(test_x_multiple)28{29const char *reffile = "test_basic.zip";30int r;3132extract_reference_file(reffile);33r = systemf("%s %s -x test_basic/c test_basic/b >test.out 2>test.err", testprog, reffile);34assertEqualInt(0, r);35assertNonEmptyFile("test.out");36assertEmptyFile("test.err");3738assertTextFileContents("contents a\n", "test_basic/a");39assertFileNotExists("test_basic/b");40assertFileNotExists("test_basic/c");41assertTextFileContents("contents CAPS\n", "test_basic/CAPS");42}4344/* Test x arg with multiple exclude paths and a d arg afterwards */45DEFINE_TEST(test_x_multiple_with_d)46{47const char *reffile = "test_basic.zip";48int r;4950extract_reference_file(reffile);51r = systemf("%s %s -x test_basic/c test_basic/b -d foobar >test.out 2>test.err", testprog, reffile);52assertEqualInt(0, r);53assertNonEmptyFile("test.out");54assertEmptyFile("test.err");5556assertTextFileContents("contents a\n", "foobar/test_basic/a");57assertFileNotExists("foobar/test_basic/b");58assertFileNotExists("foobar/test_basic/c");59assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS");60}616263