xref: /freebsd/contrib/libarchive/tar/test/test_option_lrzip.c (revision bd66c1b43e33540205dbc1187c2f2a15c58b57ba)
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 
DEFINE_TEST(test_option_lrzip)10 DEFINE_TEST(test_option_lrzip)
11 {
12 	char *p;
13 	size_t s;
14 
15 	if (!canLrzip()) {
16 		skipping("lrzip is not supported on this platform");
17 		return;
18 	}
19 
20 	/* Create a file. */
21 	assertMakeFile("f", 0644, "a");
22 
23 	/* Archive it with lrzip compression. */
24 	assertEqualInt(0,
25 	    systemf("%s -cf - --lrzip f >archive.out 2>archive.err",
26 	    testprog));
27 	p = slurpfile(&s, "archive.err");
28 	p[s] = '\0';
29 	free(p);
30 	/* Check that the archive file has an lzma signature. */
31 	p = slurpfile(&s, "archive.out");
32 	assert(s > 2);
33 	assertEqualMem(p, "LRZI\x00", 5);
34 	free(p);
35 }
36