1acc60b03SMartin Matuska /*- 2acc60b03SMartin Matuska * Copyright (c) 2003-2007 Tim Kientzle 3acc60b03SMartin Matuska * Copyright (c) 2012 Michihiro NAKAJIMA 4acc60b03SMartin Matuska * All rights reserved. 5acc60b03SMartin Matuska * 6acc60b03SMartin Matuska * Redistribution and use in source and binary forms, with or without 7acc60b03SMartin Matuska * modification, are permitted provided that the following conditions 8acc60b03SMartin Matuska * are met: 9acc60b03SMartin Matuska * 1. Redistributions of source code must retain the above copyright 10acc60b03SMartin Matuska * notice, this list of conditions and the following disclaimer. 11acc60b03SMartin Matuska * 2. Redistributions in binary form must reproduce the above copyright 12acc60b03SMartin Matuska * notice, this list of conditions and the following disclaimer in the 13acc60b03SMartin Matuska * documentation and/or other materials provided with the distribution. 14acc60b03SMartin Matuska * 15acc60b03SMartin Matuska * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 16acc60b03SMartin Matuska * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17acc60b03SMartin Matuska * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18acc60b03SMartin Matuska * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 19acc60b03SMartin Matuska * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20acc60b03SMartin Matuska * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21acc60b03SMartin Matuska * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22acc60b03SMartin Matuska * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23acc60b03SMartin Matuska * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24acc60b03SMartin Matuska * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25acc60b03SMartin Matuska */ 26acc60b03SMartin Matuska #include "test.h" 27acc60b03SMartin Matuska __FBSDID("$FreeBSD$"); 28acc60b03SMartin Matuska 29acc60b03SMartin Matuska DEFINE_TEST(test_option_lzop) 30acc60b03SMartin Matuska { 31acc60b03SMartin Matuska char *p; 32acc60b03SMartin Matuska int r; 33acc60b03SMartin Matuska size_t s; 34acc60b03SMartin Matuska 35acc60b03SMartin Matuska /* Create a file. */ 36acc60b03SMartin Matuska assertMakeFile("f", 0644, "a"); 37acc60b03SMartin Matuska 38acc60b03SMartin Matuska /* Archive it with lzop compression. */ 39acc60b03SMartin Matuska r = systemf("%s -cf - --lzop f >archive.out 2>archive.err", testprog); 40acc60b03SMartin Matuska p = slurpfile(&s, "archive.err"); 41acc60b03SMartin Matuska p[s] = '\0'; 42acc60b03SMartin Matuska if (r != 0) { 43acc60b03SMartin Matuska if (!canLzop()) { 44acc60b03SMartin Matuska skipping("lzop is not supported on this platform"); 45*63ecfce8SEnji Cooper goto done; 46acc60b03SMartin Matuska } 47acc60b03SMartin Matuska failure("--lzop option is broken"); 48acc60b03SMartin Matuska assertEqualInt(r, 0); 49*63ecfce8SEnji Cooper goto done; 50acc60b03SMartin Matuska } 51*63ecfce8SEnji Cooper free(p); 52acc60b03SMartin Matuska /* Check that the archive file has an lzma signature. */ 53acc60b03SMartin Matuska p = slurpfile(&s, "archive.out"); 54acc60b03SMartin Matuska assert(s > 2); 55acc60b03SMartin Matuska assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9); 56*63ecfce8SEnji Cooper done: 57*63ecfce8SEnji Cooper free(p); 58acc60b03SMartin Matuska } 59