xref: /freebsd/contrib/libarchive/cpio/test/test_option_lzop.c (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2003-2007 Tim Kientzle
5  * Copyright (c) 2012 Michihiro NAKAJIMA
6  * All rights reserved.
7  */
8 #include "test.h"
9 
10 DEFINE_TEST(test_option_lzop)
11 {
12 	char *p;
13 	int r;
14 	size_t s;
15 
16 	/* Create a file. */
17 	assertMakeFile("f", 0644, "a");
18 
19 	/* Archive it with lzop compression. */
20 	r = systemf("echo f | %s -o --lzop >archive.out 2>archive.err",
21 	    testprog);
22 	p = slurpfile(&s, "archive.err");
23 	free(p);
24 	if (r != 0) {
25 		if (!canLzop()) {
26 			skipping("lzop is not supported on this platform");
27 			return;
28 		}
29 		failure("--lzop option is broken");
30 		assertEqualInt(r, 0);
31 		return;
32 	}
33 	/* Check that the archive file has an lzma signature. */
34 	p = slurpfile(&s, "archive.out");
35 	assert(s > 2);
36 	assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9);
37 	free(p);
38 }
39