Skip to content

run_reclaim_tests.sh fails when utilities are disabled - it requires utils and should not be run with --disable-utilities #3283

@edhartnett

Description

@edhartnett

Bug Report: run_reclaim_tests.sh fails when utilities are disabled

Summary

unit_test/run_reclaim_tests.sh fails with a non-zero exit code when netCDF-C is
configured with --disable-utilities. The test unconditionally invokes ${NCGEN}
and ${NCDUMP}, which are not built when utilities are disabled, causing the test
to fail immediately.

Affected file

unit_test/run_reclaim_tests.sh

Steps to reproduce

autoreconf -if
./configure --enable-hdf5 --disable-utilities
make -j4
make check

The test suite will report:

FAIL: run_reclaim_tests.sh

Root cause

run_reclaim_tests.sh requires both ncgen and ncdump:

${NCGEN} -4 ${srcdir}/reclaim_tests.cdl        # line 9
${execdir}/tst_reclaim > reclaim_tests.txt      # line 10
...
${NCDUMP} reclaim_tests.nc > reclaim_tests.dmp  # line 15
diff -b reclaim_tests.dmp ${srcdir}/reclaim_tests.baseline  # line 16

When --disable-utilities is passed to configure, ncgen and ncdump are not
built. The ${NCGEN} and ${NCDUMP} variables resolve to empty or missing paths,
and the script fails immediately.

The test is registered unconditionally under USE_HDF5 in unit_test/Makefile.am:

if USE_HDF5
check_PROGRAMS += tst_nc4internal tst_reclaim
TESTS += tst_nc4internal
TESTS += run_reclaim_tests.sh
endif # USE_HDF5

There is no guard for ENABLE_UTILITIES or equivalent.

Expected behavior

run_reclaim_tests.sh should be skipped (reported as SKIP, not FAIL) when
--disable-utilities is in effect, since the test cannot run without ncgen
and ncdump.

Proposed fix

In unit_test/Makefile.am, guard the test registration behind both USE_HDF5
and BUILD_UTILITIES (or equivalent automake conditional):

if USE_HDF5
check_PROGRAMS += tst_nc4internal tst_reclaim
TESTS += tst_nc4internal
if BUILD_UTILITIES
TESTS += run_reclaim_tests.sh
endif # BUILD_UTILITIES
endif # USE_HDF5

Alternatively, add a guard at the top of run_reclaim_tests.sh that checks
whether ncgen and ncdump are available and exits with code 77 (automake
SKIP) if they are not:

if ! command -v "${NCGEN}" > /dev/null 2>&1; then
    echo "ncgen not available, skipping test"
    exit 77
fi
if ! command -v "${NCDUMP}" > /dev/null 2>&1; then
    echo "ncdump not available, skipping test"
    exit 77
fi

Exit code 77 is the automake convention for a skipped test.

Context

This bug was discovered while running the netCDF-C test suite on a big-endian
s390x platform via QEMU emulation in GitHub Actions CI. The CI workflow uses
--disable-utilities to avoid building utility binaries that trigger GCC
internal compiler errors under QEMU emulation. The run_reclaim_tests.sh
failure is the only remaining test failure in that environment once utilities
are disabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions