From 457f5cb202190b26ec48d543c55ac642781432c7 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 20 Sep 2023 11:25:17 +0200 Subject: [PATCH] configure,test-diff-pkg.cc: Handle symlinks presence in dist tarball Since the commit below, there are tests that require symbolic links. Unfortunately, the tar command used to construct tarballs copies the target of a symbolic link (and thus doesn't keep the symlink) for the purpose of greater portability, as some platforms don't support symbolic links. This patch uses a tar command that keeps the symlinks in place for the tests introduced by the commit below to keep working. On some platforms however, symlinks are removed from the tarball no matter what. In those case, the test that needs symlinks is disabled. Here is the commit in question: bad389f abipkgdiff: Avoid comparing binaries that are outside of the package * configure.ac: Use "tar -cf" instead of "tar -chf" to construct the tarball. Detect if the presence of the symlink in the distribution and define the WITH_SYMLINKS_KEPT_IN_DIST preprocessor macro accordingly. * tests/test-diff-pkg.cc (in_out_specs): If symlinks are not present in the tarball then the test that requires symlinks is deactivated. Also, fix the data/test-diff-pkg/symlink-dir-test1/dir1 test to make it point to the target of the symlinks directly, to avoid considering a binary twice, in cases where symlink targets are copied. Signed-off-by: Dodji Seketeli --- configure.ac | 17 +++++++++++++++++ tests/test-diff-pkg.cc | 12 ++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index b3f97ba2..a9400a45 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,16 @@ AM_MAINTAINER_MODE([enable]) AM_SILENT_RULES([yes]) +dnl By default, the tar command used by 'make dist and make distcheck' +dnl is "tar --format=ustar -chf" where the "-h" option actually +dnl follows symbolic links. So it copies the targets of the symlinks +dnl that are present in the tarball. Unfortunately, there are +dnl tests that need to keep the symlinks intact in the tarball. +dnl +dnl So let's define a tar command without the -h option. + +am__tar='tar --format=ustar -cf - "$$tardir"' + VERSION_MAJOR=version_major VERSION_MINOR=version_minor VERSION_REVISION=0 @@ -518,6 +528,13 @@ fi AM_CONDITIONAL(ENABLE_RPM, test x$ENABLE_RPM = xyes) +dnl There is a test that needs symlinks support in the distribution tarball. If symlinks are +dnl removed from the tarball, then the test should be disabled. +m4_define([symlink_file], [tests/data/test-diff-pkg/symlink-dir-test1/dir1/symlinks/foo.o]) +if test -L "$srcdir"/symlink_file; then + AC_DEFINE([WITH_SYMLINKS_KEPT_IN_DIST], 1, [symbolic links are kept in the distribution tarball]) +fi + dnl enable the debugging of self comparison when doing abidw --debug-abidiff if test x$ENABLE_DEBUG_SELF_COMPARISON = xyes; then AC_DEFINE([WITH_DEBUG_SELF_COMPARISON], 1, [compile support of debugging abidw --abidiff]) diff --git a/tests/test-diff-pkg.cc b/tests/test-diff-pkg.cc index fbfa50d3..020a1f30 100644 --- a/tests/test-diff-pkg.cc +++ b/tests/test-diff-pkg.cc @@ -150,8 +150,8 @@ static InOutSpec in_out_specs[] = "output/test-diff-pkg/dirpkg-3-report-2.txt" }, { - "data/test-diff-pkg/symlink-dir-test1/dir1", - "data/test-diff-pkg/symlink-dir-test1/dir2", + "data/test-diff-pkg/symlink-dir-test1/dir1/targets", + "data/test-diff-pkg/symlink-dir-test1/dir2/targets", "--no-default-suppression ", "", "", @@ -161,6 +161,7 @@ static InOutSpec in_out_specs[] = "data/test-diff-pkg/symlink-dir-test1-report0.txt", "output/test-diff-pkg/symlink-dir-test1-report0.txt" }, +#ifdef WITH_SYMLINKS_KEPT_IN_DIST { "data/test-diff-pkg/symlink-dir-test1/dir1/symlinks", "data/test-diff-pkg/symlink-dir-test1/dir2/symlinks", @@ -173,6 +174,7 @@ static InOutSpec in_out_specs[] = "data/test-diff-pkg/symlink-dir-test1-report1.txt", "output/test-diff-pkg/symlink-dir-test1-report1.txt" }, +#endif #if WITH_TAR { "data/test-diff-pkg/tarpkg-0-dir1.tar", @@ -877,8 +879,8 @@ static InOutSpec in_out_specs[] = "output/test-diff-pkg-ctf/dirpkg-3-report-2.txt" }, { - "data/test-diff-pkg-ctf/symlink-dir-test1/dir1", - "data/test-diff-pkg-ctf/symlink-dir-test1/dir2", + "data/test-diff-pkg-ctf/symlink-dir-test1/dir1/targets", + "data/test-diff-pkg-ctf/symlink-dir-test1/dir2/targets", "--ctf --no-default-suppression ", "", "", @@ -888,6 +890,7 @@ static InOutSpec in_out_specs[] = "data/test-diff-pkg-ctf/symlink-dir-test1-report0.txt", "output/test-diff-pkg-ctf/symlink-dir-test1-report0.txt" }, +#ifdef WITH_SYMLINKS_KEPT_IN_DIST { "data/test-diff-pkg-ctf/symlink-dir-test1/dir1/symlinks", "data/test-diff-pkg-ctf/symlink-dir-test1/dir2/symlinks", @@ -900,6 +903,7 @@ static InOutSpec in_out_specs[] = "data/test-diff-pkg-ctf/symlink-dir-test1-report1.txt", "output/test-diff-pkg-ctf/symlink-dir-test1-report1.txt" }, +#endif #if WITH_TAR { "data/test-diff-pkg-ctf/tarpkg-0-dir1.tar",