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_lzma) 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 lzma compression. */ 19 r = systemf("echo f | %s -o --lzma >archive.out 2>archive.err", 20 testprog); 21 p = slurpfile(&s, "archive.err"); 22 p[s] = '\0'; 23 if (r != 0) { 24 if (strstr(p, "compression not available") != NULL) { 25 skipping("This version of bsdcpio was compiled " 26 "without lzma support"); 27 free(p); 28 return; 29 } 30 failure("--lzma option is broken"); 31 assertEqualInt(r, 0); 32 free(p); 33 return; 34 } 35 free(p); 36 /* Check that the archive file has an lzma signature. */ 37 p = slurpfile(&s, "archive.out"); 38 assert(s > 2); 39 assertEqualMem(p, "\x5d\00\00", 3); 40 free(p); 41 } 42