xref: /freebsd/contrib/libarchive/cpio/test/test_option_Z_upper.c (revision bd66c1b43e33540205dbc1187c2f2a15c58b57ba)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2003-2009 Tim Kientzle
5  * All rights reserved.
6  */
7 #include "test.h"
8 
DEFINE_TEST(test_option_Z_upper)9 DEFINE_TEST(test_option_Z_upper)
10 {
11 	char *p;
12 	int r;
13 	size_t s;
14 
15 	/* Create a file. */
16 	assertMakeFile("f", 0644, "a");
17 
18 	/* Archive it with compress compression. */
19 	r = systemf("echo f | %s -oZ >archive.out 2>archive.err",
20 	    testprog);
21 	p = slurpfile(&s, "archive.err");
22 	p[s] = '\0';
23 	if (r != 0) {
24 		if (strstr(p, "compression not available") != NULL) {
25 			skipping("This version of bsdcpio was compiled "
26 			    "without compress support");
27 			free(p);
28 			return;
29 		}
30 		failure("-Z option is broken");
31 		assertEqualInt(r, 0);
32 		free(p);
33 		return;
34 	}
35 	free(p);
36 	/* Check that the archive file has a compress signature. */
37 	p = slurpfile(&s, "archive.out");
38 	assert(s > 2);
39 	assertEqualMem(p, "\x1f\x9d", 2);
40 	free(p);
41 }
42