1 /* 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2023 Adrian Vovk 5 * All rights reserved. 6 */ 7 #include "test.h" 8 9 /* Test x arg with single exclude path */ 10 DEFINE_TEST(test_x_single) 11 { 12 const char *reffile = "test_basic.zip"; 13 int r; 14 15 extract_reference_file(reffile); 16 r = systemf("%s %s -x test_basic/c >test.out 2>test.err", testprog, reffile); 17 assertEqualInt(0, r); 18 assertNonEmptyFile("test.out"); 19 assertEmptyFile("test.err"); 20 21 assertTextFileContents("contents a\n", "test_basic/a"); 22 assertTextFileContents("contents b\n", "test_basic/b"); 23 assertFileNotExists("test_basic/c"); 24 assertTextFileContents("contents CAPS\n", "test_basic/CAPS"); 25 } 26 27 /* Test x arg with multiple exclude paths */ 28 DEFINE_TEST(test_x_multiple) 29 { 30 const char *reffile = "test_basic.zip"; 31 int r; 32 33 extract_reference_file(reffile); 34 r = systemf("%s %s -x test_basic/c test_basic/b >test.out 2>test.err", testprog, reffile); 35 assertEqualInt(0, r); 36 assertNonEmptyFile("test.out"); 37 assertEmptyFile("test.err"); 38 39 assertTextFileContents("contents a\n", "test_basic/a"); 40 assertFileNotExists("test_basic/b"); 41 assertFileNotExists("test_basic/c"); 42 assertTextFileContents("contents CAPS\n", "test_basic/CAPS"); 43 } 44 45 /* Test x arg with multiple exclude paths and a d arg afterwards */ 46 DEFINE_TEST(test_x_multiple_with_d) 47 { 48 const char *reffile = "test_basic.zip"; 49 int r; 50 51 extract_reference_file(reffile); 52 r = systemf("%s %s -x test_basic/c test_basic/b -d foobar >test.out 2>test.err", testprog, reffile); 53 assertEqualInt(0, r); 54 assertNonEmptyFile("test.out"); 55 assertEmptyFile("test.err"); 56 57 assertTextFileContents("contents a\n", "foobar/test_basic/a"); 58 assertFileNotExists("foobar/test_basic/b"); 59 assertFileNotExists("foobar/test_basic/c"); 60 assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS"); 61 } 62