xref: /freebsd/contrib/libarchive/tar/test/test_option_lzop.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_lzop)10acc60b03SMartin Matuska DEFINE_TEST(test_option_lzop)
11acc60b03SMartin Matuska {
12acc60b03SMartin Matuska 	char *p;
13acc60b03SMartin Matuska 	int r;
14acc60b03SMartin Matuska 	size_t s;
15acc60b03SMartin Matuska 
16acc60b03SMartin Matuska 	/* Create a file. */
17acc60b03SMartin Matuska 	assertMakeFile("f", 0644, "a");
18acc60b03SMartin Matuska 
19acc60b03SMartin Matuska 	/* Archive it with lzop compression. */
20acc60b03SMartin Matuska 	r = systemf("%s -cf - --lzop f >archive.out 2>archive.err", testprog);
21acc60b03SMartin Matuska 	p = slurpfile(&s, "archive.err");
22acc60b03SMartin Matuska 	p[s] = '\0';
23acc60b03SMartin Matuska 	if (r != 0) {
24acc60b03SMartin Matuska 		if (!canLzop()) {
25acc60b03SMartin Matuska 			skipping("lzop is not supported on this platform");
2663ecfce8SEnji Cooper 			goto done;
27acc60b03SMartin Matuska 		}
28acc60b03SMartin Matuska 		failure("--lzop option is broken");
29acc60b03SMartin Matuska 		assertEqualInt(r, 0);
3063ecfce8SEnji Cooper 		goto done;
31acc60b03SMartin Matuska 	}
3263ecfce8SEnji Cooper 	free(p);
33acc60b03SMartin Matuska 	/* Check that the archive file has an lzma signature. */
34acc60b03SMartin Matuska 	p = slurpfile(&s, "archive.out");
35acc60b03SMartin Matuska 	assert(s > 2);
36acc60b03SMartin Matuska 	assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9);
3763ecfce8SEnji Cooper done:
3863ecfce8SEnji Cooper 	free(p);
39acc60b03SMartin Matuska }
40