Blame cpio/test/test_option_J_upper.c

Packit 08bd4c
/*-
Packit 08bd4c
 * Copyright (c) 2003-2009 Tim Kientzle
Packit 08bd4c
 * All rights reserved.
Packit 08bd4c
 *
Packit 08bd4c
 * Redistribution and use in source and binary forms, with or without
Packit 08bd4c
 * modification, are permitted provided that the following conditions
Packit 08bd4c
 * are met:
Packit 08bd4c
 * 1. Redistributions of source code must retain the above copyright
Packit 08bd4c
 *    notice, this list of conditions and the following disclaimer.
Packit 08bd4c
 * 2. Redistributions in binary form must reproduce the above copyright
Packit 08bd4c
 *    notice, this list of conditions and the following disclaimer in the
Packit 08bd4c
 *    documentation and/or other materials provided with the distribution.
Packit 08bd4c
 *
Packit 08bd4c
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
Packit 08bd4c
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Packit 08bd4c
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Packit 08bd4c
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit 08bd4c
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
Packit 08bd4c
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 08bd4c
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 08bd4c
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 08bd4c
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
Packit 08bd4c
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 08bd4c
 */
Packit 08bd4c
#include "test.h"
Packit 08bd4c
__FBSDID("$FreeBSD$");
Packit 08bd4c
Packit 08bd4c
DEFINE_TEST(test_option_J_upper)
Packit 08bd4c
{
Packit 08bd4c
	char *p;
Packit 08bd4c
	int r;
Packit 08bd4c
	size_t s;
Packit 08bd4c
Packit 08bd4c
	/* Create a file. */
Packit 08bd4c
	assertMakeFile("f", 0644, "a");
Packit 08bd4c
Packit 08bd4c
	/* Archive it with xz compression. */
Packit 08bd4c
	r = systemf("echo f | %s -o -J >archive.out 2>archive.err",
Packit 08bd4c
	    testprog);
Packit 08bd4c
	p = slurpfile(&s, "archive.err");
Packit 08bd4c
	p[s] = '\0';
Packit 08bd4c
	if (r != 0) {
Packit 08bd4c
		if (strstr(p, "compression not available") != NULL) {
Packit 08bd4c
			skipping("This version of bsdcpio was compiled "
Packit 08bd4c
			    "without xz support");
Packit 08bd4c
			return;
Packit 08bd4c
		}
Packit 08bd4c
		failure("-J option is broken");
Packit 08bd4c
		assertEqualInt(r, 0);
Packit 08bd4c
		goto done;
Packit 08bd4c
	}
Packit 08bd4c
	free(p);
Packit 08bd4c
	/* Check that the archive file has an xz signature. */
Packit 08bd4c
	p = slurpfile(&s, "archive.out");
Packit 08bd4c
	assert(s > 2);
Packit 08bd4c
	assertEqualMem(p, "\3757zXZ", 5);
Packit 08bd4c
done:
Packit 08bd4c
	free(p);
Packit 08bd4c
}