1219820Sjeff/*-
2219820Sjeff * Copyright (c) 2012 Michihiro NAKAJIMA
3219820Sjeff * All rights reserved.
4219820Sjeff *
5219820Sjeff * Redistribution and use in source and binary forms, with or without
6219820Sjeff * modification, are permitted provided that the following conditions
7219820Sjeff * are met:
8219820Sjeff * 1. Redistributions of source code must retain the above copyright
9219820Sjeff *    notice, this list of conditions and the following disclaimer.
10219820Sjeff * 2. Redistributions in binary form must reproduce the above copyright
11219820Sjeff *    notice, this list of conditions and the following disclaimer in the
12219820Sjeff *    documentation and/or other materials provided with the distribution.
13219820Sjeff *
14219820Sjeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15219820Sjeff * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16219820Sjeff * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17219820Sjeff * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18219820Sjeff * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19219820Sjeff * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20219820Sjeff * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21219820Sjeff * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22219820Sjeff * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23219820Sjeff * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24219820Sjeff */
25219820Sjeff#include "test.h"
26219820Sjeff__FBSDID("$FreeBSD$");
27219820Sjeff
28219820SjeffDEFINE_TEST(test_extract_cpio_gz)
29219820Sjeff{
30219820Sjeff	const char *reffile = "test_extract.cpio.gz";
31219820Sjeff	int f;
32219820Sjeff
33219820Sjeff	extract_reference_file(reffile);
34219820Sjeff	f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
35219820Sjeff	if (f == 0 || canGzip()) {
36219820Sjeff		assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
37219820Sjeff		    testprog, reffile));
38219820Sjeff
39219820Sjeff		assertFileExists("file1");
40219820Sjeff		assertTextFileContents("contents of file1.\n", "file1");
41219820Sjeff		assertFileExists("file2");
42219820Sjeff		assertTextFileContents("contents of file2.\n", "file2");
43219820Sjeff		assertEmptyFile("test.out");
44219820Sjeff		assertTextFileContents("1 block\n", "test.err");
45219820Sjeff	} else {
46219820Sjeff		skipping("It seems gzip is not supported on this platform");
47219820Sjeff	}
48219820Sjeff}
49219820Sjeff