diff options
author | Albert Cheng <acheng@hdfgroup.org> | 2009-09-28 15:44:35 (GMT) |
---|---|---|
committer | Albert Cheng <acheng@hdfgroup.org> | 2009-09-28 15:44:35 (GMT) |
commit | 06a71c86a3079e5acaa175898728a47c6e21e53c (patch) | |
tree | 4e28001017f05a1485dd1f1a22a2060c1bd94eee /test | |
parent | 541f147c9110ca8a3692ff1253770e5fa54a1bff (diff) | |
download | hdf5-06a71c86a3079e5acaa175898728a47c6e21e53c.zip hdf5-06a71c86a3079e5acaa175898728a47c6e21e53c.tar.gz hdf5-06a71c86a3079e5acaa175898728a47c6e21e53c.tar.bz2 |
[svn-r17542] New test:
Add new tests (tcheck_version, testcheck_version.sh) to verify H5check_version()
does issue warnings and abort accordingly.
Tests:
H5committed tested plus jam serial tested.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 30 | ||||
-rw-r--r-- | test/tcheck_version.c | 99 | ||||
-rw-r--r-- | test/testcheck_version.sh.in | 188 |
4 files changed, 311 insertions, 11 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index fbd921a..7362872 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 diff --git a/test/Makefile.in b/test/Makefile.in index 5124ade..964c894 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 = @@ -314,6 +314,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) \ @@ -367,8 +371,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 earray.c enum.c \ @@ -379,8 +384,9 @@ DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c \ gen_new_super.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 = \ @@ -666,7 +672,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 +TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh check_SCRIPTS = $(TEST_SCRIPT) SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) @@ -771,6 +777,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 @@ -969,6 +977,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) @@ -1050,6 +1061,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..15949e9 --- /dev/null +++ b/test/testcheck_version.sh.in @@ -0,0 +1,188 @@ +#! /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@ + + +# Function definitions +# 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-" +} + + +# 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" + + 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" + case "$h5DisableVersion" in + 2) # OK: No warning, exit 0 + cp /dev/null $expect + expected_code=0 + ;; + [13-9]|[1-9][0-9]*) + # W2/OK: Different Warning, exit 0. + cp /dev/null $expect #NEED FIX + expected_code=0 + ;; + *) # W/A: Warning, abort and exit non-0. + cp /dev/null $expect #NEED FIX + expected_code=1 # non-zero since abort exit code maybe + ;; # machine dependent. + esac + fi + + # Run test. + LINEMSG $envcmd $TEST_NAME $arguments + ( + echo "#############################" + echo "Expected output for $TEST_ERR" + echo "#############################" + $envcmd $RUNSERIAL $TEST_BIN $arguments + ) >$actual 2>$actual_err + ret_code=$? + + if [ \( $expected_code -eq 0 -a $expected_code -eq $ret_code \) -o \ + \( $expected_code -ne 0 -a $ret_code -ne 0 \) ]; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected exit code ($expected_code) differs from actual code ($ret_code)" + nerrors="`expr $nerrors + 1`" + 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 "$verbose" ]; then + echo $* + fi +} + + +# MAIN Body +nerrors=0 +H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h` + +# The build (current) directory might be different than the source directory. +if test -z "$srcdir"; then + srcdir=. +fi + +# Skip the rest if embedded-libinfo is not enabled. +if [ -z "$H5_HAVE_EMBEDDED_LIBINFO" ]; then + echo "embedded-libinfo is not enabled. Test skipped." + exit 0 +fi +h5libsettings=../src/libhdf5.settings + +# 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 Mm Mr mr; 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 |