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_j)10 DEFINE_TEST(test_option_j)
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 bzip2 compression. */
20           r = systemf("%s -jcf archive.out f 2>archive.err", testprog);
21           p = slurpfile(&s, "archive.err");
22           p[s] = '\0';
23           if (r != 0) {
24                     if (!canBzip2()) {
25                               skipping("bzip2 is not supported on this platform");
26                               goto done;
27                     }
28                     failure("-j option is broken");
29                     assertEqualInt(r, 0);
30                     goto done;
31           }
32           free(p);
33           assertEmptyFile("archive.err");
34           /* Check that the archive file has a bzip2 signature. */
35           p = slurpfile(&s, "archive.out");
36           assert(s > 2);
37           assertEqualMem(p, "BZh9", 4);
38 done:
39           free(p);
40 }
41