diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-09-29 15:21:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-09-29 15:21:35 (GMT) |
commit | ee5a1e07350f0dcf3ef07d9443aa2f4c073392f4 (patch) | |
tree | c53de6e31b5071d33edf877383d943dc683ad51b /test | |
parent | feed8687714f0f7148475a31d1e815ff78ad452d (diff) | |
download | hdf5-ee5a1e07350f0dcf3ef07d9443aa2f4c073392f4.zip hdf5-ee5a1e07350f0dcf3ef07d9443aa2f4c073392f4.tar.gz hdf5-ee5a1e07350f0dcf3ef07d9443aa2f4c073392f4.tar.bz2 |
[svn-r17547] Description:
Bring r17518:17546 from trunk to revise_chunks branch
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.8 (amazon) in debug mode
Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 40 | ||||
-rw-r--r-- | test/tcheck_version.c | 99 | ||||
-rw-r--r-- | test/testcheck_version.sh.in | 247 | ||||
-rw-r--r-- | test/tfile.c | 100 | ||||
-rw-r--r-- | test/tgenprop.c | 53 |
6 files changed, 469 insertions, 75 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 7ef1ef0..48ce292 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 $(srcdir)/testswmr.sh +TEST_SCRIPT = testerror.sh testlibinfo.sh $(srcdir)/testswmr.sh testcheck_version.sh check_SCRIPTS = $(TEST_SCRIPT) SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) @@ -48,10 +48,11 @@ bin_PROGRAMS=swmr_generator swmr_reader swmr_writer # 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 diff --git a/test/Makefile.in b/test/Makefile.in index 0acc722..febdc45 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -53,13 +53,13 @@ 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 bin_PROGRAMS = swmr_generator$(EXEEXT) swmr_reader$(EXEEXT) \ swmr_writer$(EXEEXT) 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 @@ -69,7 +69,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 = @@ -89,14 +89,14 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ ttsafe$(EXEEXT) getname$(EXEEXT) vfd$(EXEEXT) ntypes$(EXEEXT) \ dangle$(EXEEXT) dtransform$(EXEEXT) reserved$(EXEEXT) \ cross_read$(EXEEXT) freespace$(EXEEXT) mf$(EXEEXT) \ - farray$(EXEEXT) earray$(EXEEXT) btree2$(EXEEXT) fheap$(EXEEXT) + farray$(EXEEXT) earray$(EXEEXT) btree2$(EXEEXT) fheap$(EXEEXT) am__EXEEXT_2 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \ gen_cross$(EXEEXT) gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \ - gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \ + gen_idx$(EXEEXT) gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \ gen_new_group$(EXEEXT) gen_new_mtime$(EXEEXT) \ gen_new_super$(EXEEXT) gen_noencoder$(EXEEXT) \ gen_nullspace$(EXEEXT) gen_udlinks$(EXEEXT) \ - space_overflow$(EXEEXT) gen_idx$(EXEEXT) + space_overflow$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) app_ref_SOURCES = app_ref.c app_ref_OBJECTS = app_ref.$(OBJEXT) @@ -334,6 +334,10 @@ swmr_writer_SOURCES = swmr_writer.c swmr_writer_OBJECTS = swmr_writer.$(OBJEXT) swmr_writer_LDADD = $(LDADD) swmr_writer_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) \ @@ -388,8 +392,9 @@ SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c btree2.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 swmr_generator.c \ - swmr_reader.c swmr_writer.c $(testhdf5_SOURCES) testmeta.c \ - $(ttsafe_SOURCES) unlink.c vfd.c + swmr_reader.c swmr_writer.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 earray.c enum.c \ @@ -401,8 +406,9 @@ DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.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 swmr_generator.c \ - swmr_reader.c swmr_writer.c $(testhdf5_SOURCES) testmeta.c \ - $(ttsafe_SOURCES) unlink.c vfd.c + swmr_reader.c swmr_writer.c tcheck_version.c \ + $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \ + vfd.c ETAGS = etags CTAGS = ctags am__tty_colors = \ @@ -689,7 +695,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \ INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src # Test script for error_test and err_compat -TEST_SCRIPT = testerror.sh testlibinfo.sh $(srcdir)/testswmr.sh +TEST_SCRIPT = testerror.sh testlibinfo.sh $(srcdir)/testswmr.sh testcheck_version.sh check_SCRIPTS = $(TEST_SCRIPT) SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) @@ -716,9 +722,9 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api \ # --enable-build-all at configure time. # The gen_old_* files can only be compiled with older versions of the library # so do not appear in this list. -BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_new_array \ +BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_idx gen_new_array \ gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \ - gen_nullspace gen_udlinks space_overflow gen_idx + gen_nullspace gen_udlinks space_overflow # The libh5test library provides common support code for the tests. @@ -794,6 +800,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 @@ -1047,6 +1055,9 @@ swmr_reader$(EXEEXT): $(swmr_reader_OBJECTS) $(swmr_reader_DEPENDENCIES) swmr_writer$(EXEEXT): $(swmr_writer_OBJECTS) $(swmr_writer_DEPENDENCIES) @rm -f swmr_writer$(EXEEXT) $(LINK) $(swmr_writer_OBJECTS) $(swmr_writer_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) @@ -1133,6 +1144,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_writer.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..593a466 --- /dev/null +++ b/test/testcheck_version.sh.in @@ -0,0 +1,247 @@ +#! /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' + +# 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=expected_out + actual=actual_out + actual_err=actual_err_out + 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 + expected_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 + expected_code=0 + ;; + [2-9]|[1-9][0-9]*) + # OK: No warning, exit 0 + cp /dev/null $expect + expected_code=0 + ;; + *) # W/A: Warning, abort and exit non-0. + WarnMesg > $expect + expected_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 [ \( $expected_code -ne $ret_code \) ]; then + echo "*FAILED*" + echo " Expected exit code ($expected_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 + if test -z "$HDF5_NOCLEANUP"; then + rm -f $expected_out $actual_out $actual_err + 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 + + +# 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 diff --git a/test/tfile.c b/test/tfile.c index b96a47e..7755e7b 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -2074,17 +2074,11 @@ test_cached_stab_info(void) ** mamcgree@hdfgroup.org ** June 29, 2009 ** -** Modification: Raymond Lu -** I added a test with the system functions to make -** sure the stat function behaves as we expected. -** 17 September 2009 *****************************************************************/ static void test_rw_noupdate(void) { - int fid; /* File ID from system-created file */ - struct stat sys_sb1, sys_sb2; /* Info from the system stat */ - hid_t file_id; /* HDF5 File ID */ + int fd; /* File Descriptor */ h5_stat_t sb1, sb2; /* Info from 'stat' call */ double diff; /* Difference in modification times */ herr_t ret; /* Generic return value */ @@ -2094,70 +2088,68 @@ test_rw_noupdate(void) /* First make sure the stat function behaves as we expect - the modification time * is the time that the file was modified last time. */ - fid = open(SFILE1, O_RDWR | O_CREAT | O_TRUNC, 0666); - CHECK(fid, FAIL, "open"); - ret = close(fid); - CHECK(ret, FAIL, "close"); + fd = HDopen(SFILE1, O_RDWR | O_CREAT | O_TRUNC, 0666); + CHECK(fd, FAIL, "HDopen"); + ret = HDclose(fd); + CHECK(ret, FAIL, "HDclose"); /* Determine File's Initial Timestamp */ - ret = stat(SFILE1, &sys_sb1); - VERIFY(ret, 0, "stat"); + ret = HDstat(SFILE1, &sb1); + VERIFY(ret, 0, "HDstat"); /* Wait for 2 seconds */ - /* This ensures a system time difference between the two file accesses */ - sleep(2); + /* (This ensures a system time difference between the two file accesses) */ + HDsleep(2); - fid = open(SFILE1, O_RDWR); - CHECK(fid, FAIL, "open"); - ret = close(fid); - CHECK(ret, FAIL, "close"); + fd = HDopen(SFILE1, O_RDWR, 0666); + CHECK(fd, FAIL, "HDopen"); + ret = HDclose(fd); + CHECK(ret, FAIL, "HDclose"); /* Determine File's New Timestamp */ - ret = stat(SFILE1, &sys_sb2); - VERIFY(ret, 0, "stat"); + ret = HDstat(SFILE1, &sb2); + VERIFY(ret, 0, "HDstat"); - /* Ensure That Timestamps Are Equal */ - diff = difftime(sys_sb2.st_mtime, sys_sb1.st_mtime); + /* Get difference between timestamps */ + diff = HDdifftime(sb2.st_mtime, sb1.st_mtime); - if(!DBL_ABS_EQUAL(diff, 0.0)) { + /* Check That Timestamps Are Equal */ + if(diff > 0.0) { /* Output message about test being performed */ MESSAGE(1, ("Testing to verify that nothing is written if nothing is changed: This test is skipped on this system because the modification time from stat is the same as the last access time (We know OpenVMS behaves in this way).\n")); + } /* end if */ + else { + hid_t file_id; /* HDF5 File ID */ - goto done; - } - - /* Then we can test with a HDF5 file */ - /* Create and Close a HDF5 File */ - file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - CHECK(file_id, FAIL, "H5Fcreate"); - ret = H5Fclose(file_id); - CHECK(ret, FAIL, "H5Fclose"); - - /* Determine File's Initial Timestamp */ - ret = HDstat(FILE1, &sb1); - VERIFY(ret, 0, "HDfstat"); + /* Create and Close a HDF5 File */ + file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file_id, FAIL, "H5Fcreate"); + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); - /* Wait for 2 seconds */ - /* This ensures a system time difference between the two file accesses */ - HDsleep(2); + /* Determine File's Initial Timestamp */ + ret = HDstat(FILE1, &sb1); + VERIFY(ret, 0, "HDfstat"); - /* Open and Close File With Read/Write Permission */ - file_id = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK(file_id, FAIL, "H5Fopen"); - ret = H5Fclose(file_id); - CHECK(ret, FAIL, "H5Fclose"); + /* Wait for 2 seconds */ + /* (This ensures a system time difference between the two file accesses) */ + HDsleep(2); - /* Determine File's New Timestamp */ - ret = HDstat(FILE1, &sb2); - VERIFY(ret, 0, "HDstat"); + /* Open and Close File With Read/Write Permission */ + file_id = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(file_id, FAIL, "H5Fopen"); + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); - /* Ensure That Timestamps Are Equal */ - diff = HDdifftime(sb2.st_mtime, sb1.st_mtime); - ret = (diff > 0.0); - VERIFY(ret, 0, "Timestamp"); + /* Determine File's New Timestamp */ + ret = HDstat(FILE1, &sb2); + VERIFY(ret, 0, "HDstat"); -done: - ; /* do nothing */ + /* Ensure That Timestamps Are Equal */ + diff = HDdifftime(sb2.st_mtime, sb1.st_mtime); + ret = (diff > 0.0); + VERIFY(ret, 0, "Timestamp"); + } /* end else */ } /* end test_rw_noupdate() */ /**************************************************************** diff --git a/test/tgenprop.c b/test/tgenprop.c index 931133e..f87d4ec 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -891,6 +891,7 @@ typedef struct { /* Global variables for Callback information */ prop_cb_info prop1_cb_info; /* Callback statistics for property #1 */ prop_cb_info prop2_cb_info; /* Callback statistics for property #2 */ +prop_cb_info prop3_cb_info; /* Callback statistics for property #3 */ /**************************************************************** ** @@ -974,12 +975,26 @@ test_genprop_prop_cop_cb1(const char *name, size_t size, void *value) ** ****************************************************************/ static int -test_genprop_prop_cmp_cb1(const void UNUSED *value1, const void UNUSED *value2, size_t UNUSED size) +test_genprop_prop_cmp_cb1(const void *value1, const void *value2, size_t size) { /* Set the information from the comparison call */ prop1_cb_info.cmp_count++; - return(0); + return(HDmemcmp(value1, value2, size)); +} + +/**************************************************************** +** +** test_genprop_prop_cmp_cb3(): Property comparison callback for test_genprop_list_callback +** +****************************************************************/ +static int +test_genprop_prop_cmp_cb3(const void *value1, const void *value2, size_t size) +{ + /* Set the information from the comparison call */ + prop3_cb_info.cmp_count++; + + return(HDmemcmp(value1, value2, size)); } /**************************************************************** @@ -1036,6 +1051,7 @@ test_genprop_list_callback(void) int prop1_new_value=20; /* Property #1 new value */ float prop2_value; /* Value for property #2 */ char prop3_value[10];/* Property #3 value */ + char prop3_new_value[10]="10 chairs"; /* Property #3 new value */ double prop4_value; /* Property #4 value */ struct { /* Struct for callbacks */ int count; @@ -1058,8 +1074,8 @@ test_genprop_list_callback(void) ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL,test_genprop_prop_del_cb2,NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); - /* Insert third property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + /* Insert third property into class (with only compare callback) */ + ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, test_genprop_prop_cmp_cb3, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert fourth property into class (with no callbacks) */ @@ -1078,11 +1094,19 @@ test_genprop_list_callback(void) /* Initialize callback information for properties tracked */ HDmemset(&prop1_cb_info,0,sizeof(prop_cb_info)); HDmemset(&prop2_cb_info,0,sizeof(prop_cb_info)); + HDmemset(&prop3_cb_info,0,sizeof(prop_cb_info)); /* Create a property list from the class */ lid1 = H5Pcreate(cid1); CHECK_I(lid1, "H5Pcreate"); + /* The compare callback should have been called once on property 1 (to check + * if the create callback modified the value) */ + VERIFY(prop1_cb_info.cmp_count, 1, "H5Pequal"); + /* The compare callback should not have been called on property 3, as there + * is no create callback */ + VERIFY(prop3_cb_info.cmp_count, 0, "H5Pequal"); + /* Verify creation callback information for properties tracked */ VERIFY(prop1_cb_info.crt_count, 1, "H5Pcreate"); if(HDstrcmp(prop1_cb_info.crt_name, PROP1_NAME)!=0) @@ -1094,6 +1118,9 @@ test_genprop_list_callback(void) ret = H5Pget(lid1, PROP1_NAME,&prop1_value); CHECK_I(ret, "H5Pget"); VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); + /* The compare callback should have been called once (to check if the get + * callback modified the value) */ + VERIFY(prop1_cb_info.cmp_count, 2, "H5Pequal"); ret = H5Pget(lid1, PROP2_NAME,&prop2_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ @@ -1106,6 +1133,9 @@ test_genprop_list_callback(void) CHECK_I(ret, "H5Pget"); if(HDmemcmp(&prop3_value, PROP3_DEF_VALUE, PROP3_SIZE)!=0) TestErrPrintf("Property #3 doesn't match!, line=%d\n",__LINE__); + /* The compare callback should not have been called, as there is no get + * callback for this property */ + VERIFY(prop3_cb_info.cmp_count, 0, "H5Pequal"); ret = H5Pget(lid1, PROP4_NAME,&prop4_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ @@ -1133,6 +1163,18 @@ test_genprop_list_callback(void) if(HDmemcmp(prop1_cb_info.set_value,&prop1_new_value, PROP1_SIZE)!=0) TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); + /* The compare callback should have been called once (to check if the new + * value needed to be copied onto the property list) */ + VERIFY(prop1_cb_info.cmp_count, 3, "H5Pequal"); + + /* Set value of property #3 to different value */ + ret = H5Pset(lid1, PROP3_NAME,prop3_new_value); + CHECK_I(ret, "H5Pset"); + + /* The compare callback should have been called once (to check if the new + * value needed to be copied onto the property list) */ + VERIFY(prop3_cb_info.cmp_count, 1, "H5Pequal"); + /* Check new value of tracked properties */ ret = H5Pget(lid1, PROP1_NAME,&prop1_value); CHECK_I(ret, "H5Pget"); @@ -1178,7 +1220,8 @@ test_genprop_list_callback(void) VERIFY(ret, 1, "H5Pequal"); /* Verify compare callback information for properties tracked */ - VERIFY(prop1_cb_info.cmp_count, 1, "H5Pequal"); + VERIFY(prop1_cb_info.cmp_count, 4, "H5Pequal"); + VERIFY(prop3_cb_info.cmp_count, 2, "H5Pequal"); /* Close first list */ ret = H5Pclose(lid1); |