test_extract_cpio_grz.c revision 248616
150476Speter/*-
229585Sjulian * Copyright (c) 2012 Michihiro NAKAJIMA
329585Sjulian * All rights reserved.
429585Sjulian *
529585Sjulian * Redistribution and use in source and binary forms, with or without
6174990Sache * modification, are permitted provided that the following conditions
7174990Sache * are met:
8199179Sume * 1. Redistributions of source code must retain the above copyright
9199179Sume *    notice, this list of conditions and the following disclaimer.
10199179Sume * 2. Redistributions in binary form must reproduce the above copyright
11199179Sume *    notice, this list of conditions and the following disclaimer in the
12199179Sume *    documentation and/or other materials provided with the distribution.
13199179Sume *
14199179Sume * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15199179Sume * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16199179Sume * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17199179Sume * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18199179Sume * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19199179Sume * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2029585Sjulian * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21174990Sache * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2229585Sjulian * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2329594Sjulian * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2429594Sjulian */
2529594Sjulian#include "test.h"
2629594Sjulian__FBSDID("$FreeBSD$");
2729594Sjulian
2829594SjulianDEFINE_TEST(test_extract_cpio_grz)
2929594Sjulian{
3029594Sjulian	const char *reffile = "test_extract.cpio.grz";
3129594Sjulian	int f;
3229594Sjulian
3329594Sjulian	extract_reference_file(reffile);
3429594Sjulian	f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
3529585Sjulian	if (f == 0 || canGrzip()) {
3629585Sjulian		assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
3729585Sjulian		    testprog, reffile));
3874606Sache
3974606Sache		assertFileExists("file1");
4074606Sache		assertTextFileContents("contents of file1.\n", "file1");
4174606Sache		assertFileExists("file2");
4274606Sache		assertTextFileContents("contents of file2.\n", "file2");
4374606Sache		assertEmptyFile("test.out");
4474606Sache		assertTextFileContents("1 block\n", "test.err");
4529585Sjulian	} else {
4629585Sjulian		skipping("It seems grzip is not supported on this platform");
4729585Sjulian	}
4829594Sjulian}
4929594Sjulian