xref: /freebsd/contrib/libarchive/cpio/test/test_option_J_upper.c (revision b64c5a0ace59af62eff52bfe110a521dc73c937b)
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 
9 DEFINE_TEST(test_option_J_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 xz compression. */
19 	r = systemf("echo f | %s -o -J >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 xz support");
27 			free(p);
28 			return;
29 		}
30 		failure("-J option is broken");
31 		assertEqualInt(r, 0);
32 		goto done;
33 	}
34 	free(p);
35 	/* Check that the archive file has an xz signature. */
36 	p = slurpfile(&s, "archive.out");
37 	assert(s > 2);
38 	assertEqualMem(p, "\3757zXZ", 5);
39 done:
40 	free(p);
41 }
42