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