test_option_grzip.c revision 318483
1251886Speter/*-
2251886Speter * Copyright (c) 2003-2007 Tim Kientzle
3251886Speter * Copyright (c) 2012 Michihiro NAKAJIMA
4251886Speter * All rights reserved.
5251886Speter *
6251886Speter * Redistribution and use in source and binary forms, with or without
7251886Speter * modification, are permitted provided that the following conditions
8251886Speter * are met:
9251886Speter * 1. Redistributions of source code must retain the above copyright
10251886Speter *    notice, this list of conditions and the following disclaimer.
11251886Speter * 2. Redistributions in binary form must reproduce the above copyright
12251886Speter *    notice, this list of conditions and the following disclaimer in the
13251886Speter *    documentation and/or other materials provided with the distribution.
14251886Speter *
15251886Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16251886Speter * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17251886Speter * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18251886Speter * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19251886Speter * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20299742Sdim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21251886Speter * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22251886Speter * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23251886Speter * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24251886Speter * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25251886Speter */
26251886Speter#include "test.h"
27251886Speter__FBSDID("$FreeBSD$");
28299742Sdim
29299742SdimDEFINE_TEST(test_option_grzip)
30299742Sdim{
31251886Speter	char *p;
32251886Speter	size_t s;
33251886Speter
34251886Speter	if (!canGrzip()) {
35251886Speter		skipping("grzip is not supported on this platform");
36251886Speter		return;
37251886Speter	}
38251886Speter
39251886Speter	/* Create a file. */
40251886Speter	assertMakeFile("f", 0644, "a");
41251886Speter
42251886Speter	/* Archive it with grzip compression. */
43251886Speter	assertEqualInt(0,
44251886Speter	    systemf("echo f | %s -o --grzip >archive.out 2>archive.err",
45251886Speter	    testprog));
46251886Speter	p = slurpfile(&s, "archive.err");
47251886Speter	free(p);
48251886Speter	/* Check that the archive file has an grzip signature. */
49251886Speter	p = slurpfile(&s, "archive.out");
50251886Speter	assert(s > 2);
51251886Speter	assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12);
52251886Speter	free(p);
53251886Speter}
54251886Speter