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