xref: /freebsd/contrib/libarchive/unzip/test/test_basic.c (revision e64fe029e9d3ce476e77a478318e0c3cd201ff08)
1*e64fe029SMartin Matuska /*
2*e64fe029SMartin Matuska  * Copyright (c) 2023 Adrian Vovk
3*e64fe029SMartin Matuska  * All rights reserved.
4*e64fe029SMartin Matuska  *
5*e64fe029SMartin Matuska  * Redistribution and use in source and binary forms, with or without
6*e64fe029SMartin Matuska  * modification, are permitted provided that the following conditions
7*e64fe029SMartin Matuska  * are met:
8*e64fe029SMartin Matuska  * 1. Redistributions of source code must retain the above copyright
9*e64fe029SMartin Matuska  *    notice, this list of conditions and the following disclaimer
10*e64fe029SMartin Matuska  *    in this position and unchanged.
11*e64fe029SMartin Matuska  * 2. Redistributions in binary form must reproduce the above copyright
12*e64fe029SMartin Matuska  *    notice, this list of conditions and the following disclaimer in the
13*e64fe029SMartin Matuska  *    documentation and/or other materials provided with the distribution.
14*e64fe029SMartin Matuska  *
15*e64fe029SMartin Matuska  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16*e64fe029SMartin Matuska  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*e64fe029SMartin Matuska  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*e64fe029SMartin Matuska  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19*e64fe029SMartin Matuska  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*e64fe029SMartin Matuska  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*e64fe029SMartin Matuska  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*e64fe029SMartin Matuska  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*e64fe029SMartin Matuska  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*e64fe029SMartin Matuska  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*e64fe029SMartin Matuska  */
26*e64fe029SMartin Matuska #include "test.h"
27*e64fe029SMartin Matuska 
28*e64fe029SMartin Matuska /* This test just does a basic zip decompression */
29*e64fe029SMartin Matuska DEFINE_TEST(test_basic)
30*e64fe029SMartin Matuska {
31*e64fe029SMartin Matuska 	const char *reffile = "test_basic.zip";
32*e64fe029SMartin Matuska 	int r;
33*e64fe029SMartin Matuska 
34*e64fe029SMartin Matuska 	extract_reference_file(reffile);
35*e64fe029SMartin Matuska 	r = systemf("%s %s >test.out 2>test.err", testprog, reffile);
36*e64fe029SMartin Matuska 	assertEqualInt(0, r);
37*e64fe029SMartin Matuska 	assertNonEmptyFile("test.out");
38*e64fe029SMartin Matuska 	assertEmptyFile("test.err");
39*e64fe029SMartin Matuska 
40*e64fe029SMartin Matuska 	assertTextFileContents("contents a\n", "test_basic/a");
41*e64fe029SMartin Matuska 	assertTextFileContents("contents b\n", "test_basic/b");
42*e64fe029SMartin Matuska 	assertTextFileContents("contents c\n", "test_basic/c");
43*e64fe029SMartin Matuska 	assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
44*e64fe029SMartin Matuska }
45