Blame libarchive/test/test_read_format_tar_empty_pax.c

Packit 08bd4c
/*-
Packit 08bd4c
 * Copyright (c) 2013 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
/*
Packit 08bd4c
 * A "usual" empty tar archive contains only zero bytes
Packit 08bd4c
 * and gets handled by the 'empty' format, not by the 'tar'
Packit 08bd4c
 * format.  But there are other kinds of empty tar archives
Packit 08bd4c
 * that are true tar archives and handled as such.
Packit 08bd4c
 */
Packit 08bd4c
DEFINE_TEST(test_read_format_tar_empty_pax)
Packit 08bd4c
{
Packit 08bd4c
	/*
Packit 08bd4c
	 * An archive that only contains a PAX 'g' record
Packit 08bd4c
	 * and no real files.  (Git will generate these when
Packit 08bd4c
	 * archiving an empty project.)
Packit 08bd4c
	 */
Packit 08bd4c
	struct archive_entry *ae;
Packit 08bd4c
	struct archive *a;
Packit 08bd4c
	const char *refname = "test_read_format_tar_empty_pax.tar.Z";
Packit 08bd4c
Packit 08bd4c
	extract_reference_file(refname);
Packit 08bd4c
	assert((a = archive_read_new()) != NULL);
Packit 08bd4c
	assertEqualInt(ARCHIVE_OK, archive_read_support_filter_all(a));
Packit 08bd4c
	assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
Packit 08bd4c
	assertEqualIntA(a, ARCHIVE_OK,
Packit 08bd4c
	    archive_read_open_filename(a, refname, 10240));
Packit 08bd4c
	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae);;
Packit 08bd4c
	assertEqualInt(archive_entry_is_encrypted(ae), 0);
Packit 08bd4c
	assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
Packit 08bd4c
	assertEqualInt(ARCHIVE_FILTER_COMPRESS, archive_filter_code(a, 0));
Packit 08bd4c
	assertEqualInt(ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE, archive_format(a));
Packit 08bd4c
	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
Packit 08bd4c
	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
Packit 08bd4c
}