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