summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am46
-rw-r--r--test/Makefile.in32
-rw-r--r--test/tcheck_version.c99
-rw-r--r--test/testcheck_version.sh.in258
4 files changed, 403 insertions, 32 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 31eb462..65f134a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -24,7 +24,7 @@ include $(top_srcdir)/config/commence.am
INCLUDES=-I$(top_srcdir)/src -I$(top_builddir)/src
# Test script for error_test and err_compat
-TEST_SCRIPT = testerror.sh testlibinfo.sh
+TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh
check_SCRIPTS = $(TEST_SCRIPT)
SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
@@ -46,10 +46,11 @@ TEST_PROG=testhdf5 lheap ohdr stab gheap cache cache_api \
# List programs to be built when testing here. error_test and err_compat are
# built at the same time as the other tests, but executed by testerror.sh.
+# tcheck_version is used by testcheck_version.sh.
# 'make check' doesn't run them directly, so they are not included in TEST_PROG.
# Also build testmeta, which is used for timings test. It builds quickly,
# and this lets automake keep all its test programs in one place.
-check_PROGRAMS=$(TEST_PROG) error_test err_compat testmeta
+check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta
# These programs generate test files for the tests. They don't need to be
@@ -103,26 +104,27 @@ flush2.chkexe_: flush1.chkexe_
# prefix or low-level driver with environment variables will influence
# the temporary file name in ways that the makefile is not aware of.
CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offset.h5 \
- max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \
- huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \
- extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \
- sys_file1 tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \
- stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \
- dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \
- big.data big[0-9][0-9][0-9][0-9][0-9].h5 \
- stdio.h5 sec2.h5 dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 \
- tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \
- fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 ttime.h5 \
- trefer[1-3].h5 tvltypes.h5 tvlstr.h5 tvlstr2.h5 flush.h5 \
- enum1.h5 titerate.h5 ttsafe.h5 tarray1.h5 tgenprop.h5 \
- tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \
- getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \
- family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \
- multi_file-[rs].h5 core_file \
- new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \
- dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \
- unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \
- objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5
+ max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \
+ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \
+ extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \
+ sys_file1 tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \
+ stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \
+ dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \
+ big.data big[0-9][0-9][0-9][0-9][0-9].h5 \
+ stdio.h5 sec2.h5 dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 \
+ tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \
+ fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 ttime.h5 \
+ trefer[1-3].h5 tvltypes.h5 tvlstr.h5 tvlstr2.h5 flush.h5 \
+ enum1.h5 titerate.h5 ttsafe.h5 tarray1.h5 tgenprop.h5 \
+ tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \
+ getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \
+ family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \
+ multi_file-[rs].h5 core_file \
+ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \
+ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \
+ unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \
+ objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 tcheck_version_*.out \
+ tcheck_version_*.err
# Sources for testhdf5 executable
testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
diff --git a/test/Makefile.in b/test/Makefile.in
index 8aa0ecb..ef42e04 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -53,11 +53,11 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/testerror.sh.in $(srcdir)/testlibinfo.sh.in \
- $(top_srcdir)/config/commence.am \
+ $(srcdir)/testcheck_version.sh.in $(srcdir)/testerror.sh.in \
+ $(srcdir)/testlibinfo.sh.in $(top_srcdir)/config/commence.am \
$(top_srcdir)/config/conclude.am COPYING
check_PROGRAMS = $(am__EXEEXT_1) error_test$(EXEEXT) \
- err_compat$(EXEEXT) testmeta$(EXEEXT)
+ err_compat$(EXEEXT) tcheck_version$(EXEEXT) testmeta$(EXEEXT)
@BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_2)
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
subdir = test
@@ -67,7 +67,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/src/H5config.h
-CONFIG_CLEAN_FILES = testerror.sh testlibinfo.sh
+CONFIG_CLEAN_FILES = testcheck_version.sh testerror.sh testlibinfo.sh
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libh5test_la_LIBADD =
@@ -310,6 +310,10 @@ stab_SOURCES = stab.c
stab_OBJECTS = stab.$(OBJEXT)
stab_LDADD = $(LDADD)
stab_DEPENDENCIES = libh5test.la $(LIBHDF5)
+tcheck_version_SOURCES = tcheck_version.c
+tcheck_version_OBJECTS = tcheck_version.$(OBJEXT)
+tcheck_version_LDADD = $(LDADD)
+tcheck_version_DEPENDENCIES = libh5test.la $(LIBHDF5)
am_testhdf5_OBJECTS = testhdf5.$(OBJEXT) tarray.$(OBJEXT) \
tattr.$(OBJEXT) tchecksum.$(OBJEXT) tconfig.$(OBJEXT) \
tfile.$(OBJEXT) tgenprop.$(OBJEXT) th5o.$(OBJEXT) \
@@ -363,8 +367,9 @@ SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c btree2.c \
gen_noencoder.c gen_nullspace.c gen_udlinks.c getname.c \
gheap.c hyperslab.c istore.c lheap.c links.c mf.c mount.c \
mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \
- set_extent.c space_overflow.c stab.c $(testhdf5_SOURCES) \
- testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c
+ set_extent.c space_overflow.c stab.c tcheck_version.c \
+ $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
+ vfd.c
DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c \
btree2.c cache.c cache_api.c cmpd_dset.c cross_read.c dangle.c \
dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \
@@ -375,8 +380,9 @@ DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c \
gen_noencoder.c gen_nullspace.c gen_udlinks.c getname.c \
gheap.c hyperslab.c istore.c lheap.c links.c mf.c mount.c \
mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \
- set_extent.c space_overflow.c stab.c $(testhdf5_SOURCES) \
- testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c
+ set_extent.c space_overflow.c stab.c tcheck_version.c \
+ $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \
+ vfd.c
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
@@ -658,11 +664,11 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \
err_compat.h5 dtransform.h5 test_filters.h5 get_file_name.h5 \
tstint[1-2].h5 unlink_chunked.h5 btree2.h5 objcopy_src.h5 \
objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 \
- app_ref.h5
+ app_ref.h5 tcheck_version_*.out tcheck_version_*.err
INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src
# Test script for error_test and err_compat
-TEST_SCRIPT = testerror.sh testlibinfo.sh
+TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh
check_SCRIPTS = $(TEST_SCRIPT)
SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
@@ -767,6 +773,8 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
+testcheck_version.sh: $(top_builddir)/config.status $(srcdir)/testcheck_version.sh.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
testerror.sh: $(top_builddir)/config.status $(srcdir)/testerror.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
testlibinfo.sh: $(top_builddir)/config.status $(srcdir)/testlibinfo.sh.in
@@ -962,6 +970,9 @@ space_overflow$(EXEEXT): $(space_overflow_OBJECTS) $(space_overflow_DEPENDENCIES
stab$(EXEEXT): $(stab_OBJECTS) $(stab_DEPENDENCIES)
@rm -f stab$(EXEEXT)
$(LINK) $(stab_OBJECTS) $(stab_LDADD) $(LIBS)
+tcheck_version$(EXEEXT): $(tcheck_version_OBJECTS) $(tcheck_version_DEPENDENCIES)
+ @rm -f tcheck_version$(EXEEXT)
+ $(LINK) $(tcheck_version_OBJECTS) $(tcheck_version_LDADD) $(LIBS)
testhdf5$(EXEEXT): $(testhdf5_OBJECTS) $(testhdf5_DEPENDENCIES)
@rm -f testhdf5$(EXEEXT)
$(LINK) $(testhdf5_OBJECTS) $(testhdf5_LDADD) $(LIBS)
@@ -1042,6 +1053,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tarray.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tattr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcheck_version.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tchecksum.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tconfig.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcoords.Po@am__quote@
diff --git a/test/tcheck_version.c b/test/tcheck_version.c
new file mode 100644
index 0000000..7a34b26
--- /dev/null
+++ b/test/tcheck_version.c
@@ -0,0 +1,99 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This tests the h5check_version() function.
+ *
+ * The default is to call the h5check_version() with the version information
+ * in the header file and should incur no warnings or abort.
+ * Options provided to call it with incorrect versions to test
+ * if it will indeed issue the warning message and aborts. With environment
+ * variable $HDF5_DISABLE_VERSION_CHECK sets to 1, it should issue warnings
+ * but no abort. If it is 2, no warning or abort.
+ *
+ * Programmer: Albert Cheng
+ * September 20, 2009
+ */
+
+
+#include <stdlib.h>
+#include "hdf5.h"
+
+#define progname "tcheck_version"
+
+/* global variables */
+unsigned major = H5_VERS_MAJOR;
+unsigned minor = H5_VERS_MINOR;
+unsigned release = H5_VERS_RELEASE;
+
+void
+showhelp(void)
+{
+ printf("Usage: " progname " [-h] [-t<vers>]\n");
+ printf("\t-h\tShow this page and version information\n");
+ printf("\t-t<vers>: Test by changing (adding 1 to) the <vers> to trigger\n");
+ printf("\t\t the warning. <vers> can be:\n");
+ printf("\t\t\tM for Major version number (%d)\n", H5_VERS_MAJOR);
+ printf("\t\t\tm for Minor version number (%d)\n", H5_VERS_MINOR);
+ printf("\t\t\tr for Release number (%d)\n", H5_VERS_RELEASE);
+}
+
+
+void
+parse(int ac, char **av)
+{
+ char *pt;
+
+ while (--ac > 0){
+ pt = *(++av);
+ if (*pt != '-') {
+ fprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
+ exit(1);
+ }else{
+ switch(*(++pt)) {
+ case 't': /* option -t */
+ switch(*(++pt)) {
+ case 'M':
+ major++;
+ break;
+ case 'm':
+ minor++;
+ break;
+ case 'r':
+ release++;
+ break;
+ default:
+ fprintf(stderr, "Unknown -v parameter (%s). Aborted.\n", *av);
+ exit(1);
+ }
+ break;
+ case 'h': /* help page */
+ showhelp();
+ exit(0);
+ default:
+ fprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
+ exit(1);
+ }
+ }
+ }
+}
+
+int
+main(int ac, char **av)
+{
+ parse(ac, av);
+ H5check_version(major, minor, release);
+ return 0;
+}
diff --git a/test/testcheck_version.sh.in b/test/testcheck_version.sh.in
new file mode 100644
index 0000000..e2fa44c
--- /dev/null
+++ b/test/testcheck_version.sh.in
@@ -0,0 +1,258 @@
+#! /bin/sh
+#
+# Copyright by The HDF Group.
+# Copyright by the Board of Trustees of the University of Illinois.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the files COPYING and Copyright.html. COPYING can be found at the root
+# of the source code distribution tree; Copyright.html can be found at the
+# root level of an installed copy of the electronic HDF5 document set and
+# is linked from the top-level documents page. It can also be found at
+# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
+# access to either file, you may request a copy from help@hdfgroup.org.
+
+#
+# Tests for the H5check_version function.
+#
+# Programmer: Albert Cheng
+# Sep 28, 2009
+
+# Variables filled in by the configure process.
+# Determine the configure options of the hdf5 library and executables.
+Shared_Lib=@enable_shared@
+Static_Lib=@enable_static@
+Static_exec=@STATIC_EXEC@
+
+CMP='cmp -s'
+DIFF='diff -c'
+RM='rm -f'
+
+# Function definitions
+#
+# Show the purpose of this test script and a note about the abort messages.
+PURPOSE() {
+ echo "Tests for the H5check_version function."
+ echo "Note that abort messages may appear due to the expected termination"
+ echo "of the program when it is tested with mis-matched version numnbers."
+}
+
+# Print a line-line message left justified in a field of 70 characters.
+#
+LINEMSG() {
+ SPACES=" "
+ echo "$* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+
+# Print a "SKIP" message
+SKIP() {
+ LINEMSG $*
+ echo " -SKIP-"
+}
+
+
+# Print warning message of version mismatch.
+WarnMesg(){
+ echo "Warning! ***HDF5 library version mismatched error***"
+ echo "The HDF5 header files used to compile this application do not match"
+ echo "the version used by the HDF5 library to which this application is linked."
+ echo "Data corruption or segmentation faults may occur if the application continues."
+ echo "This can happen when an application was compiled by one version of HDF5 but"
+ echo "linked with a different version of static or shared HDF5 library."
+ echo "You should recompile the application or check your shared library related"
+ echo "settings such as 'LD_LIBRARY_PATH'."
+ echo "You can, at your own risk, disable this warning by setting the environment"
+ echo "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'."
+ echo "Setting it to 2 or higher will suppress the warning messages totally."
+ echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease"
+ test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings
+ echo "Bye..."
+}
+
+
+# Print warning message2 of version mismatch.
+WarnMesg2(){
+ echo "Warning! ***HDF5 library version mismatched error***"
+ echo "The HDF5 header files used to compile this application do not match"
+ echo "the version used by the HDF5 library to which this application is linked."
+ echo "Data corruption or segmentation faults may occur if the application continues."
+ echo "This can happen when an application was compiled by one version of HDF5 but"
+ echo "linked with a different version of static or shared HDF5 library."
+ echo "You should recompile the application or check your shared library related"
+ echo "settings such as 'LD_LIBRARY_PATH'."
+ echo "'HDF5_DISABLE_VERSION_CHECK' environment variable is set to 1, application will"
+ echo "continue at your own risk."
+ echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease"
+ test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings
+}
+
+
+# Run a test and print PASS or *FAIL*. If a test fails then increment
+# the `nerrors' global variable and (if $verbose is set) display the
+# difference between the actual output and the expected output. The
+# expected output generated according to the parameter values and compared
+# against actual output.
+# The expected and actual output files are removed unless $HDF5_NOCLEANUP
+# has a non-zero value.
+# $1: the set value of $HDF5_DISABLE_VERSION_CHECK. (unset means not to set
+# it at all.
+# $2: Change the version number(s) to cause a mismatch. (none means no
+# mismatch).
+#
+# Expected results:
+# Value of $HDF5_DISABLE_VERSION_CHECK
+# unset "" -1 0 1 2 3
+# Matched OK OK OK OK OK OK OK
+# Mismatched W/A W/A W/A W/A W2/OK OK W2/OK
+# Result codes:
+# OK: No warning, exit 0.
+# W/A: Warning, abort and exit non-0.
+# W2/OK: Different Warning, exit 0.
+#
+# Implemented only exit code matching. Still need to match output.
+TESTING() {
+ DEBUGPRINT command is $0 $*
+ TEST_NAME=tcheck_version # The test name
+ TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary
+
+ expect=${TEST_NAME}_expect.out
+ actual=${TEST_NAME}_actual.out
+ actual_err=${TEST_NAME}_actual.err
+ arguments=
+
+ h5DisableVersion="$1"
+ wrongversionnumbers="$2"
+ xxh5versmajor=$h5versmajor
+ xxh5versminor=$h5versminor
+ xxh5versrelease=$h5versrelease
+
+ if [ "$h5DisableVersion" = unset ]; then
+ envcmd="" # noop
+ else
+ envcmd="env HDF5_DISABLE_VERSION_CHECK=$h5DisableVersion"
+ fi
+
+ if [ "$wrongversionnumbers" = none ]; then
+ # OK: No warning, exit 0
+ cp /dev/null $expect
+ expect_code=0
+ else
+ arguments=-t"$wrongversionnumbers"
+ # calculate mismatched version numbers by listing.
+ case $wrongversionnumbers in
+ "M") xxh5versmajor=`expr $h5versmajor + 1`
+ ;;
+ "m") xxh5versminor=`expr $h5versminor + 1`
+ ;;
+ "r") xxh5versrelease=`expr $h5versrelease + 1`
+ ;;
+ esac
+ case "$h5DisableVersion" in
+ 1)
+ # W2/OK: Different Warning, exit 0.
+ WarnMesg2 > $expect
+ expect_code=0
+ ;;
+ [2-9]|[1-9][0-9]*)
+ # OK: No warning, exit 0
+ cp /dev/null $expect
+ expect_code=0
+ ;;
+ *) # W/A: Warning, abort and exit non-0.
+ WarnMesg > $expect
+ expect_code=134 # Signal Abort exit code (128+6)
+ ;;
+ esac
+ fi
+
+ # Run test.
+ LINEMSG $envcmd $TEST_NAME $arguments
+ (
+ $envcmd $RUNSERIAL $TEST_BIN $arguments
+ ) >$actual 2>$actual_err
+ ret_code=$?
+ cat $actual_err >> $actual
+
+ if [ \( $expect_code -ne $ret_code \) ]; then
+ echo "*FAILED*"
+ echo " Expected exit code ($expect_code) differs from actual code ($ret_code)"
+ nerrors="`expr $nerrors + 1`"
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result differs from actual result"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ fi
+
+ # Clean up output file.
+ # Also clean the core file generated by H5check_version's abort.
+ if test -z "$HDF5_NOCLEANUP"; then
+ $RM $expect $actual $actual_err
+ $RM core
+ fi
+}
+
+
+# Echo parameters for debugging if verbose mode is on.
+DEBUGPRINT() {
+ if [ -n "$debugmode" ]; then
+ echo $*
+ fi
+}
+
+
+# MAIN Body
+nerrors=0
+verbose=yes # default on
+debugmode= # default off
+H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h`
+h5libsettings=../src/libhdf5.settings
+
+PURPOSE
+
+# The build (current) directory might be different than the source directory.
+if test -z "$srcdir"; then
+ srcdir=.
+fi
+
+# Figure out library version numbers from the header file.
+h5versmajor=`grep '#define H5_VERS_MAJOR' $srcdir/../src/H5public.h | cut -f2`
+h5versminor=`grep '#define H5_VERS_MINOR' $srcdir/../src/H5public.h | cut -f2`
+h5versrelease=`grep '#define H5_VERS_RELEASE' $srcdir/../src/H5public.h | cut -f2`
+DEBUGPRINT $h5versmajor.$h5versminor.$h5versrelease
+case "$h5versmajor$h5versminor$h5versrelease" in
+ [0-9]*) # good. noop.
+ ;;
+ *)
+ echo "Illegal library version numbers($h5versmajor.$h5versminor.$h5versrelease)"
+ echo "Test aborted"
+ exit 1
+ ;;
+esac
+
+# Three Categories of tests:
+# Normal: where the version numbers all matched (wrong_version == none).
+# Mismatched version numbers (could be Major or minor version
+# or release numbers or a combination of all three.)
+# Test all the above with different values of the environment variable,
+# HDF5_DISABLE_VERSION_CHECK, as unset, "", -1, 0, 1, 2, 3
+
+for val_disable_version_check in unset "" -1 0 1 2 3; do
+ for wrong_version in none M m r; do
+ TESTING "$val_disable_version_check" "$wrong_version"
+ done
+done
+
+
+# Check and report results.
+if [ $nerrors -gt 0 ]; then
+ echo "***$nerrors errors encountered***"
+ exit 1
+else
+ echo "No error encountered"
+ exit 0
+fi