Hi Frank,

On Wed, Oct 09, 2024 at 01:47:29PM -0400, Frank Ch. Eigler wrote:
> I find the following patch makes make checks bearable again.

I like the idea of this change. Some nitpicks below.

> From 0acce289fbb9c4da6a6ec1868eed5ede5a62e63d Mon Sep 17 00:00:00 2001
> From: "Frank Ch. Eigler" <f...@redhat.com>
> Date: Wed, 9 Oct 2024 13:41:14 -0400
> Subject: [PATCH] tests/test-subr.sh: Put test_dir under /var/tmp.
> 
> Every individual test in elfutils involves a temporary directory.
> Previous version of this script put that directory under the build
> tree.  That's OK if it's a local disk, but if it's on NFS, then some
> tests - run-large-elf-file.sh, several run-debuginfod-*.sh - take long
> enough to run to fail tests intermittently.
> 
> This patch moves the temp_dir under ${TMPDIR-/var/tmp/}, so it
> operates at local disk speed rather than whatever-build-filesystem
> speed.  Individual test scripts are all unaffected.  (One could
> consider /tmp instead, which is a RAM disk on modern systems, except
> that some of the elfutils tests produce GB-sized temporary files.
> That's probably too big for RAM.)

I think ${TMPDIR-/var/tmp/} is the correct choice. /tmp is indeed
supposed to only have small files.

> Signed-off-by: Frank Ch. Eigler <f...@redhat.com>
> ---
>  tests/test-subr.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/test-subr.sh b/tests/test-subr.sh
> index 411e5f288acd..68ef541f8632 100644
> --- a/tests/test-subr.sh
> +++ b/tests/test-subr.sh
> @@ -23,7 +23,7 @@
>  set -e
>  
>  # Each test runs in its own directory to make sure they can run in parallel.
> -test_dir="test-$$"
> +test_dir="${TMPDIR-/var/tmp}/test-$$"

I would make this /test-elfutils-$$ then in case some files are left
around someone can more easily see where they came from.

>  mkdir -p "$test_dir"
>  cd "$test_dir"

There is one "tricky" cleanup issue slightly below this:

# Tests that trap EXIT (0) themselves should call this explicitly.
exit_cleanup()
{
  rm -f $remove_files; cd ..; rmdir $test_dir
}
trap exit_cleanup 0

On clean exit we remove all (tempfiles) and then try to remove the
$test_dir. Note that this fails (the test) if any non-tmp-file is left
behind.

I think this works, but the cd .. doesn't end up where it originally
did. Maybe save the orig_dir="${PWD}" before creating the test_dir and
cd $orig_dir here?

Cheers,

Mark

Reply via email to