1228753Smm/*-
2228753Smm * Copyright (c) 2003-2009 Tim Kientzle
3228753Smm * All rights reserved.
4228753Smm *
5228753Smm * Redistribution and use in source and binary forms, with or without
6228753Smm * modification, are permitted provided that the following conditions
7228753Smm * are met:
8228753Smm * 1. Redistributions of source code must retain the above copyright
9228753Smm *    notice, this list of conditions and the following disclaimer.
10228753Smm * 2. Redistributions in binary form must reproduce the above copyright
11228753Smm *    notice, this list of conditions and the following disclaimer in the
12228753Smm *    documentation and/or other materials provided with the distribution.
13228753Smm *
14228753Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15228753Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16228753Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17228753Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18228753Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19228753Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20228753Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21228753Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22228753Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23228753Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24228753Smm */
25228753Smm#include "test.h"
26228753Smm__FBSDID("$FreeBSD: releng/10.3/contrib/libarchive/cpio/test/test_option_J_upper.c 228763 2011-12-21 11:13:29Z mm $");
27228753Smm
28228753SmmDEFINE_TEST(test_option_J_upper)
29228753Smm{
30228753Smm	char *p;
31228753Smm	int r;
32228753Smm	size_t s;
33228753Smm
34228753Smm	/* Create a file. */
35228753Smm	assertMakeFile("f", 0644, "a");
36228753Smm
37228753Smm	/* Archive it with xz compression. */
38228753Smm	r = systemf("echo f | %s -o -J >archive.out 2>archive.err",
39228753Smm	    testprog);
40228753Smm	p = slurpfile(&s, "archive.err");
41228753Smm	p[s] = '\0';
42228753Smm	if (r != 0) {
43228753Smm		if (strstr(p, "compression not available") != NULL) {
44228753Smm			skipping("This version of bsdcpio was compiled "
45228753Smm			    "without xz support");
46228753Smm			return;
47228753Smm		}
48228753Smm		failure("-J option is broken");
49228753Smm		assertEqualInt(r, 0);
50228753Smm		return;
51228753Smm	}
52228753Smm	/* Check that the archive file has an xz signature. */
53228753Smm	p = slurpfile(&s, "archive.out");
54228753Smm	assert(s > 2);
55228753Smm	assertEqualMem(p, "\3757zXZ", 5);
56228753Smm}
57