test_option_lzma.c revision 228761
1217044Snwhitehorn/*- 2217044Snwhitehorn * Copyright (c) 2003-2007 Tim Kientzle 3217044Snwhitehorn * All rights reserved. 4217044Snwhitehorn * 5217044Snwhitehorn * Redistribution and use in source and binary forms, with or without 6217044Snwhitehorn * modification, are permitted provided that the following conditions 7217044Snwhitehorn * are met: 8217044Snwhitehorn * 1. Redistributions of source code must retain the above copyright 9217044Snwhitehorn * notice, this list of conditions and the following disclaimer. 10217044Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright 11217044Snwhitehorn * notice, this list of conditions and the following disclaimer in the 12217044Snwhitehorn * documentation and/or other materials provided with the distribution. 13217044Snwhitehorn * 14217044Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15217044Snwhitehorn * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16217044Snwhitehorn * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17217044Snwhitehorn * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18217044Snwhitehorn * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19217044Snwhitehorn * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20217044Snwhitehorn * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21217044Snwhitehorn * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22217044Snwhitehorn * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23217044Snwhitehorn * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24217044Snwhitehorn */ 25217044Snwhitehorn#include "test.h" 26217044Snwhitehorn__FBSDID("$FreeBSD$"); 27217044Snwhitehorn 28217044SnwhitehornDEFINE_TEST(test_option_lzma) 29217044Snwhitehorn{ 30217044Snwhitehorn char *p; 31217044Snwhitehorn int r; 32217044Snwhitehorn size_t s; 33217044Snwhitehorn 34217044Snwhitehorn /* Create a file. */ 35217044Snwhitehorn assertMakeFile("f", 0644, "a"); 36217044Snwhitehorn 37217044Snwhitehorn /* Archive it with lzma compression. */ 38217044Snwhitehorn r = systemf("echo f | %s -o --lzma >archive.out 2>archive.err", 39217044Snwhitehorn testprog); 40217044Snwhitehorn p = slurpfile(&s, "archive.err"); 41217044Snwhitehorn p[s] = '\0'; 42217044Snwhitehorn if (r != 0) { 43217044Snwhitehorn if (strstr(p, "compression not available") != NULL) { 44217044Snwhitehorn skipping("This version of bsdcpio was compiled " 45217044Snwhitehorn "without lzma support"); 46217044Snwhitehorn return; 47217044Snwhitehorn } 48217044Snwhitehorn failure("--lzma option is broken"); 49217044Snwhitehorn assertEqualInt(r, 0); 50217044Snwhitehorn return; 51276680Snwhitehorn } 52276680Snwhitehorn /* Check that the archive file has an lzma signature. */ 53217044Snwhitehorn p = slurpfile(&s, "archive.out"); 54217044Snwhitehorn assert(s > 2); 55217044Snwhitehorn assertEqualMem(p, "\x5d\00\00", 3); 56217044Snwhitehorn} 57217044Snwhitehorn