1249259Sdim/*- 2249259Sdim * Copyright (c) 2003-2007 Tim Kientzle 3249259Sdim * Copyright (c) 2012 Michihiro NAKAJIMA 4249259Sdim * All rights reserved. 5249259Sdim * 6249259Sdim * Redistribution and use in source and binary forms, with or without 7249259Sdim * modification, are permitted provided that the following conditions 8249259Sdim * are met: 9249259Sdim * 1. Redistributions of source code must retain the above copyright 10249259Sdim * notice, this list of conditions and the following disclaimer. 11249259Sdim * 2. Redistributions in binary form must reproduce the above copyright 12249259Sdim * notice, this list of conditions and the following disclaimer in the 13249259Sdim * documentation and/or other materials provided with the distribution. 14249259Sdim * 15249259Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 16249259Sdim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17249259Sdim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18249259Sdim * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 19249259Sdim * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20249259Sdim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21249259Sdim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22249259Sdim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23249259Sdim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24249259Sdim * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25249259Sdim */ 26249259Sdim#include "test.h" 27249259Sdim 28249259SdimDEFINE_TEST(test_option_grzip) 29249259Sdim{ 30249259Sdim char *p; 31249259Sdim size_t s; 32249259Sdim 33249259Sdim if (!canGrzip()) { 34249259Sdim skipping("grzip is not supported on this platform"); 35249259Sdim return; 36249259Sdim } 37249259Sdim 38249259Sdim /* Create a file. */ 39249259Sdim assertMakeFile("f", 0644, "a"); 40249259Sdim 41249259Sdim /* Archive it with grzip compression. */ 42249259Sdim assertEqualInt(0, 43249259Sdim systemf("echo f | %s -o --grzip >archive.out 2>archive.err", 44249259Sdim testprog)); 45249259Sdim p = slurpfile(&s, "archive.err"); 46249259Sdim free(p); 47249259Sdim /* Check that the archive file has an grzip signature. */ 48249259Sdim p = slurpfile(&s, "archive.out"); 49249259Sdim assert(s > 2); 50249259Sdim assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12); 51249259Sdim free(p); 52249259Sdim} 53249259Sdim