xref: /freebsd/contrib/libarchive/unzip/test/test_o.c (revision bd66c1b43e33540205dbc1187c2f2a15c58b57ba)
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 o arg - overwrite existing files */
DEFINE_TEST(test_o)10 DEFINE_TEST(test_o)
11 {
12 	const char *reffile = "test_basic.zip";
13 	int r;
14 
15 	assertMakeDir("test_basic", 0755);
16 	assertMakeFile("test_basic/a", 0644, "orig a\n");
17 	assertMakeFile("test_basic/b", 0644, "orig b\n");
18 
19 	extract_reference_file(reffile);
20 	r = systemf("%s -o %s >test.out 2>test.err", testprog, reffile);
21 	assertEqualInt(0, r);
22 	assertEmptyFile("test.err");
23 
24 	assertTextFileContents("contents a\n", "test_basic/a");
25 	assertTextFileContents("contents b\n", "test_basic/b");
26 	assertTextFileContents("contents c\n", "test_basic/c");
27 	assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
28 }
29