diff options
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/CMakeLists.txt | 25 | ||||
-rw-r--r-- | c++/test/CMakeTests.cmake | 32 | ||||
-rw-r--r-- | c++/test/Makefile.am | 4 | ||||
-rw-r--r-- | c++/test/Makefile.in | 531 | ||||
-rw-r--r-- | c++/test/dsets.cpp | 11 | ||||
-rw-r--r-- | c++/test/h5cpputil.cpp | 4 | ||||
-rw-r--r-- | c++/test/h5cpputil.h | 6 | ||||
-rw-r--r-- | c++/test/tattr.cpp | 118 | ||||
-rw-r--r-- | c++/test/tcompound.cpp | 90 | ||||
-rw-r--r-- | c++/test/tdspl.cpp | 148 | ||||
-rw-r--r-- | c++/test/testhdf5.cpp | 1 | ||||
-rw-r--r-- | c++/test/trefer.cpp | 6 | ||||
-rw-r--r-- | c++/test/ttypes.cpp | 12 |
13 files changed, 873 insertions, 115 deletions
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index e498fc5..220d4b1 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_CPP_TEST) # -------------------------------------------------------------------- # Notes: When creating unit test executables they should be prefixed @@ -11,10 +11,11 @@ PROJECT (HDF5_CPP_TEST) #----------------------------------------------------------------------------- # Define Sources #----------------------------------------------------------------------------- -SET (CPP_TEST_SRCS +set (CPP_TEST_SRCS ${HDF5_CPP_TEST_SOURCE_DIR}/testhdf5.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/tattr.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/tcompound.cpp + ${HDF5_CPP_TEST_SOURCE_DIR}/tdspl.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/tfile.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/tfilter.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/th5s.cpp @@ -29,27 +30,27 @@ SET (CPP_TEST_SRCS #----------------------------------------------------------------------------- # Generate the H5srcdir_str.h file containing user settings needed by compilation #----------------------------------------------------------------------------- -SET (srcdir ${CMAKE_CURRENT_SOURCE_DIR}) -CONFIGURE_FILE (${HDF5_CPP_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY) -INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) +set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}) +configure_file (${HDF5_CPP_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY) -INCLUDE_DIRECTORIES (${HDF5_TEST_SRC_DIR} ) - -ADD_EXECUTABLE (cpp_testhdf5 ${CPP_TEST_SRCS} ) +add_executable (cpp_testhdf5 ${CPP_TEST_SRCS} ) TARGET_NAMING (cpp_testhdf5 ${LIB_TYPE}) TARGET_C_PROPERTIES (cpp_testhdf5 " " " ") -TARGET_LINK_LIBRARIES (cpp_testhdf5 +target_link_libraries (cpp_testhdf5 ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ) -SET_TARGET_PROPERTIES (cpp_testhdf5 PROPERTIES FOLDER test/cpp) +set_target_properties (cpp_testhdf5 PROPERTIES + FOLDER test/cpp + INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" +) -ADD_CUSTOM_COMMAND ( +add_custom_command ( TARGET cpp_testhdf5 POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_CPP_TEST_SOURCE_DIR}/th5s.h5 ${PROJECT_BINARY_DIR}/th5s.h5 ) -INCLUDE (CMakeTests.cmake) +include (CMakeTests.cmake) diff --git a/c++/test/CMakeTests.cmake b/c++/test/CMakeTests.cmake index 3e4f6d9..2b05fea 100644 --- a/c++/test/CMakeTests.cmake +++ b/c++/test/CMakeTests.cmake @@ -5,7 +5,7 @@ ############################################################################## ############################################################################## # Remove any output file left over from previous test run -ADD_TEST ( +add_test ( NAME cpp_testhdf5-clear-objects COMMAND ${CMAKE_COMMAND} -E remove @@ -17,12 +17,12 @@ ADD_TEST ( tfattrs.h5 ) -ADD_TEST (NAME cpp_testhdf5 COMMAND $<TARGET_FILE:cpp_testhdf5>) -SET_TESTS_PROPERTIES (cpp_testhdf5 PROPERTIES DEPENDS cpp_testhdf5-clear-objects) +add_test (NAME cpp_testhdf5 COMMAND $<TARGET_FILE:cpp_testhdf5>) +set_tests_properties (cpp_testhdf5 PROPERTIES DEPENDS cpp_testhdf5-clear-objects) -IF (HDF5_TEST_VFD) +if (HDF5_TEST_VFD) - SET (VFD_LIST + set (VFD_LIST sec2 stdio core @@ -31,13 +31,13 @@ IF (HDF5_TEST_VFD) family ) - IF (DIRECT_VFD) - SET (VFD_LIST ${VFD_LIST} direct) - ENDIF (DIRECT_VFD) + if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) + endif (DIRECT_VFD) MACRO (ADD_VFD_TEST vfdname resultcode) - IF (NOT HDF5_ENABLE_USING_MEMCHECKER) - ADD_TEST ( + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( NAME VFD-${vfdname}-cpp_testhdf5-clear-objects COMMAND ${CMAKE_COMMAND} -E remove @@ -48,7 +48,7 @@ IF (HDF5_TEST_VFD) tattr_scalar.h5 tfattrs.h5 ) - ADD_TEST ( + add_test ( NAME VFD-${vfdname}-cpp_testhdf5 COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:cpp_testhdf5>" @@ -59,13 +59,13 @@ IF (HDF5_TEST_VFD) -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -P "${HDF5_RESOURCES_DIR}/vfdTest.cmake" ) - SET_TESTS_PROPERTIES (VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS VFD-${vfdname}-cpp_testhdf5-clear-objects) - ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) + set_tests_properties (VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS VFD-${vfdname}-cpp_testhdf5-clear-objects) + endif (NOT HDF5_ENABLE_USING_MEMCHECKER) ENDMACRO (ADD_VFD_TEST) # Run test with different Virtual File Driver - FOREACH (vfd ${VFD_LIST}) + foreach (vfd ${VFD_LIST}) ADD_VFD_TEST (${vfd} 0) - ENDFOREACH (vfd ${VFD_LIST}) + endforeach (vfd ${VFD_LIST}) -ENDIF (HDF5_TEST_VFD) +endif (HDF5_TEST_VFD) diff --git a/c++/test/Makefile.am b/c++/test/Makefile.am index 3f62bda..6cef381 100644 --- a/c++/test/Makefile.am +++ b/c++/test/Makefile.am @@ -21,7 +21,7 @@ include $(top_srcdir)/config/commence.am # Include src, test, and c++/src directories -INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/c++/src +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/c++/src # Shared C++ libraries aren't universally supported. if CXX_SHARED_CONDITIONAL @@ -38,7 +38,7 @@ check_PROGRAMS=$(TEST_PROG) LDADD=$(LIBH5TEST) $(LIBH5CPP) $(LIBHDF5) testhdf5_SOURCES=testhdf5.cpp dsets.cpp tattr.cpp tcompound.cpp \ - tfile.cpp tfilter.cpp th5s.cpp tlinks.cpp trefer.cpp \ + tdspl.cpp tfile.cpp tfilter.cpp th5s.cpp tlinks.cpp trefer.cpp \ ttypes.cpp tvlstr.cpp h5cpputil.cpp # Tell conclude.am that these are C++ tests. diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in index 0aad590..59cab8f 100644 --- a/c++/test/Makefile.in +++ b/c++/test/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2012 Free Software Foundation, Inc. +# Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -31,23 +31,51 @@ # HDF5-C++ Makefile(.in) # VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ - test $$am__dry = yes; \ - } + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -66,11 +94,11 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -DIST_COMMON = $(srcdir)/H5srcdir_str.h.in $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(top_srcdir)/bin/depcomp \ - $(top_srcdir)/bin/mkinstalldirs \ - $(top_srcdir)/config/commence.am \ - $(top_srcdir)/config/conclude.am +DIST_COMMON = $(top_srcdir)/config/commence.am \ + $(top_srcdir)/config/conclude.am $(srcdir)/Makefile.in \ + $(srcdir)/Makefile.am $(top_srcdir)/bin/mkinstalldirs \ + $(srcdir)/H5srcdir_str.h.in $(top_srcdir)/bin/depcomp \ + $(top_srcdir)/bin/test-driver # Shared C++ libraries aren't universally supported. @CXX_SHARED_CONDITIONAL_FALSE@am__append_1 = -static @@ -87,10 +115,10 @@ CONFIG_CLEAN_FILES = H5srcdir_str.h CONFIG_CLEAN_VPATH_FILES = am__EXEEXT_1 = testhdf5$(EXEEXT) am_testhdf5_OBJECTS = testhdf5.$(OBJEXT) dsets.$(OBJEXT) \ - tattr.$(OBJEXT) tcompound.$(OBJEXT) tfile.$(OBJEXT) \ - tfilter.$(OBJEXT) th5s.$(OBJEXT) tlinks.$(OBJEXT) \ - trefer.$(OBJEXT) ttypes.$(OBJEXT) tvlstr.$(OBJEXT) \ - h5cpputil.$(OBJEXT) + tattr.$(OBJEXT) tcompound.$(OBJEXT) tdspl.$(OBJEXT) \ + tfile.$(OBJEXT) tfilter.$(OBJEXT) th5s.$(OBJEXT) \ + tlinks.$(OBJEXT) trefer.$(OBJEXT) ttypes.$(OBJEXT) \ + tvlstr.$(OBJEXT) h5cpputil.$(OBJEXT) testhdf5_OBJECTS = $(am_testhdf5_OBJECTS) testhdf5_LDADD = $(LDADD) testhdf5_DEPENDENCIES = $(LIBH5TEST) $(LIBH5CPP) $(LIBHDF5) @@ -139,12 +167,227 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no -am__tty_colors = $(am__tty_colors_dummy) +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +AM_RECURSIVE_TARGETS = check recheck +TEST_SUITE_LOG = test-suite.log +LOG_DRIVER = $(SHELL) $(top_srcdir)/bin/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.sh.log=.log) +SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/bin/test-driver +SH_LOG_COMPILE = $(SH_LOG_COMPILER) $(AM_SH_LOG_FLAGS) $(SH_LOG_FLAGS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ADD_PARALLEL_FILES = @ADD_PARALLEL_FILES@ @@ -156,7 +399,10 @@ AMTAR = @AMTAR@ # instead of CFLAGS, as CFLAGS is reserved solely for the user to define. # This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well. AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ -AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ + +# Include src, test, and c++/src directories +AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src \ + -I$(top_srcdir)/test -I$(top_srcdir)/c++/src AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ @@ -216,7 +462,6 @@ FC_VERSION = @FC_VERSION@ FGREP = @FGREP@ FILTERS = @FILTERS@ FSEARCH_DIRS = @FSEARCH_DIRS@ -GPFS = @GPFS@ GREP = @GREP@ H5_CFLAGS = @H5_CFLAGS@ H5_CPPFLAGS = @H5_CPPFLAGS@ @@ -429,9 +674,6 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog tattr_multi.h5 tfattrs.h5 \ tattr_scalar.h5 tattr_compound.h5 tattr_dtype.h5 \ tattr_basic.h5 -# Include src, test, and c++/src directories -INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/c++/src - # These are our main targets. They should be listed in the order to be # executed, generally most specific tests to least specific tests. TEST_PROG = testhdf5 @@ -439,7 +681,7 @@ TEST_PROG = testhdf5 # The tests depend on the hdf5 library, test library, and the c++ library LDADD = $(LIBH5TEST) $(LIBH5CPP) $(LIBHDF5) testhdf5_SOURCES = testhdf5.cpp dsets.cpp tattr.cpp tcompound.cpp \ - tfile.cpp tfilter.cpp th5s.cpp tlinks.cpp trefer.cpp \ + tdspl.cpp tfile.cpp tfilter.cpp th5s.cpp tlinks.cpp trefer.cpp \ ttypes.cpp tvlstr.cpp h5cpputil.cpp @@ -468,7 +710,7 @@ TEST_SCRIPT_PARA_CHKSH = $(TEST_SCRIPT_PARA:=.chkexe_) all: all-am .SUFFIXES: -.SUFFIXES: .cpp .lo .o .obj +.SUFFIXES: .cpp .lo .log .o .obj .sh .sh$(EXEEXT) .trs $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -511,6 +753,7 @@ clean-checkPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list + testhdf5$(EXEEXT): $(testhdf5_OBJECTS) $(testhdf5_DEPENDENCIES) $(EXTRA_testhdf5_DEPENDENCIES) @rm -f testhdf5$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(testhdf5_OBJECTS) $(testhdf5_LDADD) $(LIBS) @@ -525,6 +768,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5cpputil.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tattr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcompound.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tdspl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testhdf5.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tfilter.Po@am__quote@ @@ -561,26 +805,15 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ + $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -592,15 +825,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $$unique; \ fi; \ fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -609,9 +838,10 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am -cscopelist: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP)'; \ +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ @@ -627,6 +857,158 @@ cscopelist: $(HEADERS) $(SOURCES) $(LISP) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + else \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 +recheck: all $(check_PROGRAMS) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +testhdf5.log: testhdf5$(EXEEXT) + @p='testhdf5$(EXEEXT)'; \ + b='testhdf5'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.sh.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(SH_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_SH_LOG_DRIVER_FLAGS) $(SH_LOG_DRIVER_FLAGS) -- $(SH_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.sh$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(SH_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_SH_LOG_DRIVER_FLAGS) $(SH_LOG_DRIVER_FLAGS) -- $(SH_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -683,6 +1065,9 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: @@ -766,19 +1151,19 @@ uninstall-am: .MAKE: check-am install-am install-strip -.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \ - clean clean-checkPROGRAMS clean-generic clean-libtool \ - cscopelist ctags distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ +.PHONY: CTAGS GTAGS TAGS all all-am all-local check check-TESTS \ + check-am clean clean-checkPROGRAMS clean-generic clean-libtool \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ - pdf-am ps ps-am tags uninstall uninstall-am + pdf-am ps ps-am recheck tags tags-am uninstall uninstall-am # List all build rules defined by HDF5 Makefiles as "PHONY" targets here. diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 811d8c7..72d7977 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -120,6 +120,11 @@ test_create( H5File& file) // way to open an existing dataset for accessing. dataset = new DataSet (file.openDataSet (DSET_DEFAULT_NAME)); + // Get and verify the comment from this dataset, using + // H5std_string getComment(const H5std_string& name, <buf_size=0, by default>) + H5std_string comment = file.getComment(DSET_DEFAULT_NAME); + verify_val(comment, "This is a dataset", "H5Location::getComment", __LINE__, __FILE__); + // Close the dataset when accessing is completed delete dataset; @@ -1067,6 +1072,12 @@ void test_dset() nerrors += test_multiopen (file)<0 ?1:0; nerrors += test_types(file)<0 ?1:0; + // Get part of the comment, random length using + // ssize_t getComment(const char* name, const size_t buf_size, char* comment) + char* comment = new char[11]; + ssize_t comment_len = file.getComment("emit diagnostics", 11, comment); + verify_val((const char*)comment, "Causes dia", "H5Location::getComment", __LINE__, __FILE__); + // Close group "emit diagnostics". grp.close(); diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp index cd85b6e..40e81cc 100644 --- a/c++/test/h5cpputil.cpp +++ b/c++/test/h5cpputil.cpp @@ -220,7 +220,7 @@ InvalidActionException::InvalidActionException(const H5std_string func_name, con //-------------------------------------------------------------------------- // Function: InvalidActionException destructor //-------------------------------------------------------------------------- -InvalidActionException::~InvalidActionException() {} +InvalidActionException::~InvalidActionException() throw() {} //-------------------------------------------------------------------------- // Function: TestFailedException default constructor @@ -242,5 +242,5 @@ TestFailedException::TestFailedException(const H5std_string func_name, const H5s //-------------------------------------------------------------------------- // Function: TestFailedException destructor //-------------------------------------------------------------------------- -TestFailedException::~TestFailedException() {} +TestFailedException::~TestFailedException() throw() {} diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h index e6aba79..cc135bd 100644 --- a/c++/test/h5cpputil.h +++ b/c++/test/h5cpputil.h @@ -49,14 +49,14 @@ class InvalidActionException : public Exception { public: InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); InvalidActionException(); - virtual ~InvalidActionException(); + virtual ~InvalidActionException() throw(); }; class TestFailedException : public Exception { public: TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); TestFailedException(); - virtual ~TestFailedException(); + virtual ~TestFailedException() throw(); }; // Overloaded/Template functions to verify values and display proper info @@ -121,6 +121,7 @@ extern "C" { #endif void test_attr(); void test_compound(); +void test_dsproplist(); void test_file(); void test_filters(); void test_links(); @@ -133,6 +134,7 @@ void test_dset(); /* Prototypes for the cleanup routines */ void cleanup_attr(); void cleanup_compound(); +void cleanup_dsproplist(); void cleanup_dsets(); void cleanup_file(); void cleanup_filters(); diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 7e77e85..e2e347b 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -244,6 +244,123 @@ static void test_attr_basic_write() /**************************************************************** ** +** test_attr_getname(): Test getting attribute name functions. +** +** Test these functions: +** A. ssize_t Attribute::getName(char* attr_name, size_t buf_size) +** 1. With arbitrary buf_size that is larger than the name size +** 2. With arbitrary buf_size that is smaller than the name's length. +** 3. With a buf_size that equals the name's length. +** +** B. ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size) +** With buffer smaller than the actual name +** +** C. H5std_string Attribute::getName() with file's and dataset's attrs. +** +** D. ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size) +** With buffer size equals the name's length, i.e., buf_size=0 +** +****************************************************************/ +static void test_attr_getname() +{ + // Output message about test being performed + SUBTEST("Testing all overloads of Attribute::getName"); + + try { + // + // Open the file FILE_BASIC and test getName with its attribute + // + + // Open file + H5File fid1(FILE_BASIC, H5F_ACC_RDWR); + + // Check for existence of attribute FATTR1_NAME + bool attr_exists = fid1.attrExists(FATTR1_NAME); + if (attr_exists == false) + throw InvalidActionException("H5File::attrExists", "Attribute should exist but does not"); + + // Open attribute + Attribute fattr1(fid1.openAttribute(FATTR1_NAME)); + + // A. Get attribute name with + // ssize_t Attribute::getName(char* attr_name, size_t buf_size) + // using different buffer sizes and verify against FATTR1_NAME (3 cases) + + // 1. With arbitrary buf_size that is larger than the name size + size_t buf_size = FATTR1_NAME.length() + 10; + char* fattr1_name = new char[buf_size+1]; + HDmemset(fattr1_name, 0, buf_size+1); + ssize_t name_size = 0; // actual length of attribute name + name_size = fattr1.getName(fattr1_name, buf_size+1); + verify_val((const char*)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); + delete []fattr1_name; + + // 2. With arbitrary buf_size that is smaller than the name's length. + // Let's try 4 first characters in the name. + buf_size = 4; + char short_name[5] = "File"; // to verify the read name + fattr1_name = new char[buf_size+1]; + HDmemset(fattr1_name, 0, buf_size+1); + name_size = fattr1.getName(fattr1_name, buf_size+1); + verify_val((const char*)fattr1_name, (const char*)short_name, "Attribute::getName", __LINE__, __FILE__); + delete []fattr1_name; + + // 3. With a buf_size that equals the name's length. + buf_size = FATTR1_NAME.length(); + fattr1_name = new char[buf_size+1]; + HDmemset(fattr1_name, 0, buf_size+1); + name_size = fattr1.getName(fattr1_name, buf_size+1); + verify_val(fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); + delete []fattr1_name; + + // B. Get attribute name with + // ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size) + // using buffer smaller than the actual name + buf_size = 4; + H5std_string fattr1_name2; + name_size = fattr1.getName(fattr1_name2, buf_size); + + // C. Get file attribute's name with + // H5std_string Attribute::getName() + H5std_string fattr1_name3 = fattr1.getName(); + verify_val(fattr1_name3, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); + + // + // Open the dataset DSET1_NAME and test getName with its attribute + // + + // Open dataset DSET1_NAME + DataSet dataset = fid1.openDataSet(DSET1_NAME); + + // Check for existence of attribute + attr_exists = dataset.attrExists(ATTR1_NAME); + if (attr_exists == false) + throw InvalidActionException("H5File::attrExists", "Attribute should exist but does not"); + + // Open attribute + Attribute attr1(dataset.openAttribute(ATTR1_NAME)); + + // Get dataset attribute's name with + // H5std_string Attribute::getName() + H5std_string dattr_name1 = attr1.getName(); + verify_val(dattr_name1, ATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); + + // D. Get attribute name with + // H5std_string Attribute::getName(H5std_string attr_name, buf_size=0) + H5std_string dattr_name2; + name_size = attr1.getName(dattr_name2); + verify_val(dattr_name2, ATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); + + PASSED(); + } // end try block + + catch (Exception E) { + issue_fail_msg("test_attr_getname()", __LINE__, __FILE__, E.getCDetailMsg()); + } +} // test_attr_getname() + +/**************************************************************** +** ** test_attr_rename(): Test renaming attribute function. ** ****************************************************************/ @@ -1433,6 +1550,7 @@ void test_attr() MESSAGE(5, ("Testing Attributes\n")); test_attr_basic_write(); // Test basic H5A writing code + test_attr_getname(); // Test overloads of Attribute::getName test_attr_rename(); // Test renaming attribute test_attr_basic_read(); // Test basic H5A reading code diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index 6ae3f82..60d44b2 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -727,7 +727,96 @@ cerr << "test_compound_7 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_7() + +/*------------------------------------------------------------------------- + * Function: test_compound_set_size + * + * Purpose: Tests member function setSize() on compound datatype + * + * Return: None + * + * Programmer: Binh-Minh Ribler (use partial C version test_ooo_order) + * March, 2014 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +#define COMPFILE "tcompound_types.h5" +static void test_compound_set_size() +{ + typedef struct { + int a, b, c[4], d, e; + } src_typ_t; + src_typ_t *s_ptr; + + // Output message about test being performed + SUBTEST("Setting Size on Compound Datatype"); + try { + // Create File + H5File file(COMPFILE, H5F_ACC_TRUNC); + + // Create a compound datatype + CompType dtype(sizeof(src_typ_t)); + dtype.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); + dtype.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_FLOAT); + dtype.insertMember("c", HOFFSET(src_typ_t, c), PredType::NATIVE_LONG); + dtype.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_DOUBLE); + + // Verify that the compound is not packed + // bool packed = dtype.packed(); // not until C library provides API + // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); + + dtype.commit(file, "dtype"); + + // Close the type and file + dtype.close(); + file.close(); + + // Open the file for read/write + file.openFile(COMPFILE, H5F_ACC_RDWR); + + // Open the data type "dtype" + CompType dtype_tmp = file.openCompType("dtype"); + + // Make a copy of the data type + dtype = dtype_tmp; + + // Verify that the compound is not packed + // packed = dtype_tmp.packed(); // not until C library provides API + // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); + + // Expand the type, and verify that it became unpacked + dtype.setSize((size_t)33); + // packed = dtype.packed(); // not until C library provides API + // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); + + // Verify setSize() actually set size + size_t new_size = dtype.getSize(); + verify_val(new_size, 33, "DataType::getSize", __LINE__, __FILE__); + + // Shrink the type, and verify that it became packed + dtype.setSize((size_t)32); + // packed = dtype.packed(); // not until C library provides API + // verify_val(packed, TRUE, "DataType::packed", __LINE__, __FILE__); + + // Verify setSize() actually set size again + new_size = dtype.getSize(); + verify_val(new_size, 32, "DataType::getSize", __LINE__, __FILE__); + + /* Close types and file */ + dtype_tmp.close(); + dtype.close(); + file.close(); + + PASSED(); + } // end of try block + + catch (Exception E) { + issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + } +} // test_compound_set_size() /*------------------------------------------------------------------------- * Function: test_compound @@ -758,6 +847,7 @@ void test_compound() test_compound_5(); // optimized struct converter test_compound_6(); // compound element growing test_compound_7(); // compound element insertion + test_compound_set_size(); // set size on compound data types } // test_compound() diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp new file mode 100644 index 0000000..5944fb1 --- /dev/null +++ b/c++/test/tdspl.cpp @@ -0,0 +1,148 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/***************************************************************************** + FILE + tdspl.cpp - HDF5 C++ testing the dataset memory and transfer property + list functionality + + ***************************************************************************/ + +#ifdef OLD_HEADER_FILENAME +#include <iostream.h> +#else +#include <iostream> +#endif +#include <string> + +#ifndef H5_NO_NAMESPACE +#ifndef H5_NO_STD + using std::cerr; + using std::endl; +#endif // H5_NO_STD +#endif + +#include "H5Cpp.h" // C++ API header file + +#ifndef H5_NO_NAMESPACE + using namespace H5; +#endif + +#include "h5cpputil.h" // C++ utilility header file + +const H5std_string FILENAME("tdatatransform.h5"); + +static void test_transfplist() +{ + const char* c_to_f = "(9/5.0)*x + 32"; + const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ + /* inverses the utrans transform in init_test to get back original array */ + const char* utrans_inv = "(x/3)*4 - 100"; + char *c_to_f_read=NULL, *simple_read=NULL, *utrans_inv_read=NULL; + + SUBTEST("DSetMemXferPropList::set/getDataTransform()"); + try { + // Create various data set prop lists and set data transform expression. + DSetMemXferPropList dxpl_c_to_f(c_to_f); + + DSetMemXferPropList dxpl_simple; + dxpl_simple.setDataTransform(simple); + + DSetMemXferPropList dxpl_utrans_inv; + dxpl_utrans_inv.setDataTransform(utrans_inv); + + // + // Make a copy of one of those prop lists then read the data transform + // expression and verify that it's the same as the original. + // + + // Copy the prop list. + DSetMemXferPropList dxpl_c_to_f_copy; + dxpl_c_to_f_copy.copy(dxpl_c_to_f); + + // Find out the length of the transform expression, allocate the buffer + // for it, then read and verify the expression from the copied plist + ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); + c_to_f_read = (char *)HDmalloc(tran_len+1); + HDmemset(c_to_f_read, 0, tran_len+1); + dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len+1); + verify_val((const char*)c_to_f_read, (const char*)c_to_f, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + HDfree(c_to_f_read); + + // + // Read the expression of each of the prop lists and verify the read + // expression + // + + // Get and verify the expression with: + // ssize_t getDataTransform(char* exp, const size_t buf_size [default=0]) + tran_len = dxpl_c_to_f.getDataTransform(NULL); + c_to_f_read = (char *)HDmalloc(tran_len+1); + HDmemset(c_to_f_read, 0, tran_len+1); + dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len+1); + verify_val((const char*)c_to_f_read, (const char*)c_to_f, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + HDfree(c_to_f_read); + + // Get and verify the expression with: + // H5std_string DSetMemXferPropList::getDataTransform() + H5std_string simple_read = dxpl_simple.getDataTransform(); + verify_val((const char*)simple_read.c_str(), (const char*)simple, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + + // Get and verify the expression with: + // ssize_t getDataTransform(char* exp, const size_t buf_size) + tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); + utrans_inv_read = (char *)HDmalloc(tran_len+1); + HDmemset(utrans_inv_read, 0, tran_len+1); + dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len+1); + verify_val((const char*)utrans_inv_read, (const char*)utrans_inv, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + HDfree(utrans_inv_read); + + PASSED(); + } + catch (Exception E) { + issue_fail_msg("test_transfplist", __LINE__, __FILE__, E.getCDetailMsg()); + } +} + + +/**************************************************************** +** +** test_dsproplist(): Main dataset property list testing routine. +** +****************************************************************/ +#ifdef __cplusplus +extern "C" +#endif +void test_dsproplist() +{ + // Output message about test being performed + MESSAGE(5, ("Testing Generic Dataset Property Lists\n")); + + test_transfplist(); // test set/getDataTransform() + +} // test_dsproplist() + + +#ifdef __cplusplus +extern "C" +#endif +void cleanup_dsproplist() +{ + HDremove(FILENAME.c_str()); +} diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index fe08d6d..57210d0 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -84,6 +84,7 @@ main(int argc, char *argv[]) AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL); AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL); + AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL); AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL); AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL); /* Comment out tests that are not done yet. - BMR, Feb 2001 diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index 36c2ee4..e7a28de 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -316,11 +316,13 @@ static void test_reference_obj(void) // Dereference group object from the location where 'dataset' is located group.dereference(dataset, &rbuf[2]); - // Get group's comment + // Get group's comment using + // H5std_string getComment(const char* name, <buf_size=0 by default>) H5std_string read_comment1 = group.getComment(".", 10); verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); - // Test that getComment handles failures gracefully + // Test that getComment handles failures gracefully, using + // H5std_string getComment(const char* name, <buf_size=0 by default>) try { H5std_string read_comment_tmp = group.getComment(NULL); } diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index c10cf6d..933181c 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -213,7 +213,7 @@ static void test_query() float b; long c; double d; - } s_type_t; + } src_typ_t; short enum_val; // Output message about test being performed @@ -224,12 +224,12 @@ static void test_query() H5File file(FILENAME[2], H5F_ACC_TRUNC); // Create a compound datatype - CompType tid1(sizeof(s_type_t)); + CompType tid1(sizeof(src_typ_t)); - tid1.insertMember("a", HOFFSET(s_type_t, a), PredType::NATIVE_INT); - tid1.insertMember("b", HOFFSET(s_type_t, b), PredType::NATIVE_FLOAT); - tid1.insertMember("c", HOFFSET(s_type_t, c), PredType::NATIVE_LONG); - tid1.insertMember("d", HOFFSET(s_type_t, d), PredType::NATIVE_DOUBLE); + tid1.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); + tid1.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_FLOAT); + tid1.insertMember("c", HOFFSET(src_typ_t, c), PredType::NATIVE_LONG); + tid1.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_DOUBLE); // Create a enumerate datatype EnumType tid2(sizeof(short)); |