1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2003-2007 Tim Kientzle 5 * All rights reserved. 6 */ 7 #include "test.h" 8 9 DEFINE_TEST(test_option_z) 10 { 11 char *p; 12 int r; 13 size_t s; 14 15 /* Create a file. */ 16 assertMakeFile("f", 0644, "a"); 17 18 /* Archive it with gzip compression. */ 19 r = systemf("echo f | %s -oz >archive.out 2>archive.err", 20 testprog); 21 p = slurpfile(&s, "archive.err"); 22 free(p); 23 if (r != 0) { 24 if (!canGzip()) { 25 skipping("gzip is not supported on this platform"); 26 return; 27 } 28 failure("-z option is broken"); 29 assertEqualInt(r, 0); 30 return; 31 } 32 /* Check that the archive file has a gzip signature. */ 33 p = slurpfile(&s, "archive.out"); 34 assert(s > 4); 35 assertEqualMem(p, "\x1f\x8b\x08\x00", 4); 36 free(p); 37 } 38