From 0ead3e88734ad130c3991947a7b51cd1d5c37102 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 29 Sep 2009 11:45:07 -0500 Subject: [svn-r17548] ------------------------------------------------------------------------ r17543 | acheng | 2009-09-28 23:43:22 -0500 (Mon, 28 Sep 2009) | 8 lines New test: (Bug ID 1656): Add new tests (tcheck_version, testcheck_version.sh) to verify H5check_version() does issue warnings and abort accordingly. Changed H5check_version() to suppress the warning message totally if $HDF5_DISABLE_VERSION_CHECK is 2 or higher. (Old behavior treated 3 or higher the same as 1, that is to print a warning and allows the program to continue. Tests: H5committed tested plus jam serial tested. --- MANIFEST | 2 + configure | 5 +- configure.in | 1 + release_docs/RELEASE.txt | 9 +- src/H5.c | 16 +-- test/Makefile.am | 46 ++++---- test/Makefile.in | 32 ++++-- test/tcheck_version.c | 99 +++++++++++++++++ test/testcheck_version.sh.in | 258 +++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 425 insertions(+), 43 deletions(-) create mode 100644 test/tcheck_version.c create mode 100644 test/testcheck_version.sh.in diff --git a/MANIFEST b/MANIFEST index 0ff4cec..fc6c743 100644 --- a/MANIFEST +++ b/MANIFEST @@ -856,8 +856,10 @@ ./test/tbad_msg_count.h5 ./test/tbogus.h5 ./test/tchecksum.c +./test/tcheck_version.c ./test/tconfig.c ./test/tcoords.c +./test/testcheck_version.sh.in ./test/testerror.sh.in ./test/testframe.c ./test/testhdf5.c diff --git a/configure b/configure index f7c9e92..be1eb09 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 17501 2009-09-20 21:02:59Z lrknox . +# From configure.in Id: configure.in 17540 2009-09-27 22:06:09Z lrknox . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.64 for HDF5 1.8.3-snap13. # @@ -28208,7 +28208,7 @@ if test -n "$TESTPARALLEL"; then fi fi -ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testerror.sh test/testlibinfo.sh testpar/Makefile testpar/testph5.sh perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/examples/Makefile c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/tools/Makefile hl/tools/gif2h5/Makefile hl/examples/Makefile hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile" +ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/testlibinfo.sh testpar/Makefile testpar/testph5.sh perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/examples/Makefile c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/tools/Makefile hl/tools/gif2h5/Makefile hl/examples/Makefile hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile" cat >confcache <<\_ACEOF @@ -29418,6 +29418,7 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; + "test/testcheck_version.sh") CONFIG_FILES="$CONFIG_FILES test/testcheck_version.sh" ;; "test/testerror.sh") CONFIG_FILES="$CONFIG_FILES test/testerror.sh" ;; "test/testlibinfo.sh") CONFIG_FILES="$CONFIG_FILES test/testlibinfo.sh" ;; "testpar/Makefile") CONFIG_FILES="$CONFIG_FILES testpar/Makefile" ;; diff --git a/configure.in b/configure.in index efa05b0..50a23b4 100644 --- a/configure.in +++ b/configure.in @@ -4002,6 +4002,7 @@ AC_CONFIG_FILES([src/libhdf5.settings Makefile src/Makefile test/Makefile + test/testcheck_version.sh test/testerror.sh test/testlibinfo.sh testpar/Makefile diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 3aad9db..2e03923 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -63,7 +63,14 @@ New Features Library ------- - - None + - The embedded library information is displayed by H5check_version() if a + version mismatch is detected. Also changed H5check_version() to + suppress the warning message totally if $HDF5_DISABLE_VERSION_CHECK is 2 + or higher. (Old behavior treated 3 or higher the same as 1, that is + print a warning and allows the program to continue. (AKC - 2009/9/28) + - If a user does not care for the extra library information insert + in the executables, he may turn it off by --disable-embedded-libinfo + during configure. (AKC - 2009/9/15) Parallel Library ---------------- diff --git a/src/H5.c b/src/H5.c index f11e8b7..4041483 100644 --- a/src/H5.c +++ b/src/H5.c @@ -621,7 +621,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) char lib_str[256]; char substr[] = H5_VERS_SUBRELEASE; static int checked = 0; /* If we've already checked the version info */ - static int disable_version_check = 0; /* Set if the version check should be disabled */ + static unsigned int disable_version_check = 0; /* Set if the version check should be disabled */ herr_t ret_value=SUCCEED; /* Return value */ static char *version_mismatch_warning=VERSION_MISMATCH_WARNING; @@ -638,7 +638,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) s = HDgetenv ("HDF5_DISABLE_VERSION_CHECK"); if (s && HDisdigit(*s)) - disable_version_check = (int)HDstrtol (s, NULL, 0); + disable_version_check = (unsigned int)HDstrtol (s, NULL, 0); } if (H5_VERS_MAJOR!=majnum || H5_VERS_MINOR!=minnum || @@ -648,7 +648,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) HDfprintf(stderr, "%s%s", version_mismatch_warning, "You can, at your own risk, disable this warning by setting the environment\n" "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.\n" - "Setting it to 2 will suppress the warning messages totally.\n"); + "Setting it to 2 or higher will suppress the warning messages totally.\n"); /* Mention the versions we are referring to */ HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, relnum, @@ -659,12 +659,9 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) /* Bail out now. */ HDfputs ("Bye...\n", stderr); HDabort (); - case 2: - /* continue silently */ - break; - default: + case 1: /* continue with a warning */ - /* Note that the warning message is embedded in the format string. */ + /* Note that the warning message is embedded in the format string.*/ HDfprintf (stderr, "%s'HDF5_DISABLE_VERSION_CHECK' " "environment variable is set to %d, application will\n" @@ -677,6 +674,9 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) /* Show library settings if available */ HDfprintf (stderr, "%s", H5libhdf5_settings); break; + default: + /* 2 or higer: continue silently */ + break; } /* end switch */ } /* end if */ 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 +#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]\n"); + printf("\t-h\tShow this page and version information\n"); + printf("\t-t: Test by changing (adding 1 to) the to trigger\n"); + printf("\t\t the warning. 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 -- cgit v0.12