Skip to content

Commit 3171122

Browse files
committed
ncmpidiff/ncdiff - add xfail test when 2 input file names are identical
1 parent 11db7f4 commit 3171122

5 files changed

Lines changed: 61 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Makefile
8383
*.nc1
8484
*.nc2
8585
*.nc5
86+
!/src/utils/ncmpidiff/tst_file.nc
8687
!/src/utils/ncvalidator/bad_*.nc
8788
!/src/utils/ncvalidator/bad_*.nc?
8889
!/test/cdf_format/bad_*.nc?

src/utils/ncmpidiff/Makefile.am

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ AM_CPPFLAGS += -I$(top_builddir)/src/include
1111

1212
bin_PROGRAMS = ncmpidiff cdfdiff
1313

14+
check_PROGRAMS = $(bin_PROGRAMS)
15+
1416
noinst_LTLIBRARIES = libncmpidiff_core.la
1517
libncmpidiff_core_la_SOURCES = ncmpidiff_core.c
1618

@@ -28,7 +30,20 @@ $(top_builddir)/src/libs/libpnetcdf.la:
2830

2931
dist_man_MANS = ncmpidiff.1 cdfdiff.1
3032

31-
EXTRA_DIST = ncmpidiff_core.h
33+
AM_TESTS_ENVIRONMENT = export check_PROGRAMS="$(check_PROGRAMS)";
34+
AM_TESTS_ENVIRONMENT += export SED="$(SED)";
35+
AM_TESTS_ENVIRONMENT += export srcdir="$(srcdir)";
36+
AM_TESTS_ENVIRONMENT += export TESTOUTDIR="$(FSTYPE_PREFIX)$(TESTOUTDIR)";
37+
AM_TESTS_ENVIRONMENT += export TESTSEQRUN="$(TESTSEQRUN)";
38+
AM_TESTS_ENVIRONMENT += export TESTMPIRUN="$(TESTMPIRUN)";
39+
40+
TESTS = $(check_PROGRAMS)
41+
XFAIL_TESTS = $(check_PROGRAMS)
42+
EST_EXTENSIONS = .sh
43+
LOG_COMPILER = $(srcdir)/xfail_runs.sh
44+
SH_LOG_COMPILER =
45+
46+
EXTRA_DIST = ncmpidiff_core.h tst_file.nc
3247

3348
CLEANFILES = core core.* *.gcda *.gcno *.gcov gmon.out
3449

src/utils/ncmpidiff/cdfdiff.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ int main(int argc, char **argv)
309309

310310
if (argc - optind != 2) usage(argv[0]);
311311

312+
if (strcmp(argv[optind], argv[optind+1]) == 0) {
313+
printf("Error: two input file names are identical (%s) ... exit\n",
314+
argv[optind]);
315+
exit(1);
316+
}
317+
312318
if (verbose && check_tolerance) {
313319
printf("Tolerance absolute difference = %e\n", tolerance_difference);
314320
printf("Tolerance ratio difference = %e\n", tolerance_ratio);

src/utils/ncmpidiff/tst_file.nc

800 Bytes
Binary file not shown.

src/utils/ncmpidiff/xfail_runs.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (C) 2026, Northwestern University and Argonne National Laboratory
4+
# See COPYRIGHT notice in top-level directory.
5+
#
6+
7+
# Exit immediately if a command exits with a non-zero status.
8+
set -e
9+
10+
DRY_RUN=no
11+
VERBOSE=yes
12+
13+
if test "x$1" = "x./ncmpidiff" ; then
14+
RUN_CMD=`echo ${TESTMPIRUN} | ${SED} -e "s/NP/4/g"`
15+
else
16+
RUN_CMD=$TESTSEQRUN
17+
fi
18+
19+
run_cmd() {
20+
local lineno=${BASH_LINENO[$((${#BASH_LINENO[@]} - 2))]}
21+
if test "x$VERBOSE" = xyes || test "x$DRY_RUN" = xyes ; then
22+
echo "Line $lineno CMD: $RUN_CMD $@"
23+
fi
24+
if test "x$DRY_RUN" = xno ; then
25+
$RUN_CMD $@
26+
fi
27+
}
28+
29+
exe_name=`basename $1`
30+
31+
# prevent user environment setting of PNETCDF_HINTS to interfere
32+
unset PNETCDF_HINTS
33+
34+
# ncmpidiff/ncdiff should error out when two input file names are identical.
35+
IDENT_FILE=${srcdir}/tst_file.nc
36+
37+
run_cmd $1 ${IDENT_FILE} ${IDENT_FILE}
38+

0 commit comments

Comments
 (0)