head	1.1;
branch	1.1.1;
access;
symbols
	libarchive-3-8-11:1.1.1.1
	libarchive-3-8-10:1.1.1.1
	KIENTZLE:1.1.1;
locks; strict;
comment	@ * @;


1.1
date	2026.10.19.11.50.40;	author adam;	state Exp;
branches
	1.1.1.1;
next	;
commitid	eS0MvMrTxXQX650H;

1.1.1.1
date	2026.10.19.11.50.40;	author adam;	state Exp;
branches;
next	;
commitid	eS0MvMrTxXQX650H;


desc
@@


1.1
log
@Initial revision
@
text
@/*-
 * SPDX-License-Identifier: BSD-2-Clause
 *
 * Copyright (c) 2026 lilu
 * All rights reserved.
 */
#include "test.h"

/*
 * An entry whose hardlink target reduces to the empty string after
 * stripping the leading '/' is skipped by edit_pathname().  This used to
 * happen silently: the entry vanished from the output and bsdtar exited 0,
 * so a caller could not detect the incomplete result.  The entry must now be
 * named in a diagnostic and must cause a non-zero exit status.
 */
DEFINE_TEST(test_edit_pathname_hardlink)
{
	const char *reffile = "test_edit_pathname_hardlink.tar.Z";
	char *p;
	size_t s;
	const char *expected_errmsg =
	    "Skipping ./hardlink: hardlink target becomes empty "
	    "after removing leading '/'";

	extract_reference_file(reffile);

	/* Transforming the archive must report the dropped entry and fail. */
	assert(0 != systemf("%s -cf out.tar @@%s >test.out 2>test.err",
	    testprog, reffile));

	/* out.tar must list ./a.txt and must not list the dropped ./hardlink. */
	assertEqualInt(0, systemf("%s -tf out.tar >list.out 2>list.err",
	    testprog));
	p = slurpfile(&s, "list.out");
	assert(p != NULL);
	assert(strstr(p, "a.txt") != NULL);
	assert(strstr(p, "hardlink") == NULL);
	free(p);

	/* The diagnostic must name the entry and the reason. */
	if (assertFileExists("test.err")) {
		p = slurpfile(&s, "test.err");
		assert(strstr(p, expected_errmsg) != NULL);
		free(p);
	}
}
@


1.1.1.1
log
@libarchive: import version 3.8.10
@
text
@@
