mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-26 04:09:39 +03:00
- H5TB: strcmp replaces strncmp in H5TBfind_field so that field names that are a prefix of a requested name (or vice-versa) are no longer matched. HLTB_MAX_FIELD_LEN (255) is now public in H5TBpublic.h and exposed to Fortran as HLTB_MAX_FIELD_LEN_F in H5TBff.F90. H5TBget_field_info documents the buffer-size requirement and truncation behaviour. H5TBget_field_info guards against overflow on long names. - H5IM: H5IMis_image and H5IMis_palette refactored into a shared helper (H5IM__class_attr_equals). The helper now reads both fixed-length and variable-length CLASS string attributes, using H5Treclaim for VL memory. strcmp replaces strncmp for exact-match semantics. - H5DS: H5DSis_scale and H5DS_is_reserved both support variable-length CLASS string attributes via H5Aget_space/H5Aread/H5Treclaim. The fixed-length path retains the 16-byte size guard. strcmp is used throughout for exact comparison. - Tests: new test functions test_is_scale_class_prefix, test_is_reserved_class_prefix, and test_class_prefix cover fixed-length prefix/exact/wrong-value cases and variable-length string cases. test_table.c adds write and read field-name prefix rejection cases and boundary-length truncation verification. All malloc calls are NULL-checked. - CHANGELOG updated with a summary of all fixes.
158 lines
4.9 KiB
CMake
158 lines
4.9 KiB
CMake
#
|
|
# Copyright by The HDF Group.
|
|
# 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 LICENSE file, which can be found at the root of the source code
|
|
# distribution tree, or in https://www.hdfgroup.org/licenses.
|
|
# If you do not have access to either file, you may request a copy from
|
|
# help@hdfgroup.org.
|
|
#
|
|
|
|
##############################################################################
|
|
##############################################################################
|
|
### T E S T I N G ###
|
|
##############################################################################
|
|
##############################################################################
|
|
|
|
set (HL_REFERENCE_TEST_FILES
|
|
dtype_file.txt
|
|
image8.txt
|
|
sepia.pal
|
|
earth.pal
|
|
image24pixel.txt
|
|
image24plane.txt
|
|
usa.wri
|
|
test_table_be.h5
|
|
test_table_cray.h5
|
|
test_table_le.h5
|
|
dsdata.txt
|
|
dslat.txt
|
|
dslon.txt
|
|
test_ds_be.h5
|
|
test_ds_be_new_ref.h5
|
|
test_ds_le.h5
|
|
test_ds_le_new_ref.h5
|
|
test_ld.h5
|
|
test_table.h5.ddl
|
|
)
|
|
|
|
# --------------------------------------------------------------------
|
|
#-- Copy the necessary files.
|
|
# --------------------------------------------------------------------
|
|
foreach (h5_file ${HL_REFERENCE_TEST_FILES})
|
|
HDFTEST_COPY_FILE ("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${HDF5_HL_TEST_BINARY_DIR}/testfiles/${h5_file}" "hl_test_files")
|
|
endforeach ()
|
|
add_custom_target (hl_test_files ALL COMMENT "Copying files needed by hl_test tests" DEPENDS ${hl_test_files_list})
|
|
|
|
# Remove any output file left over from previous test run
|
|
set (test_hl_CLEANFILES
|
|
combine_tables1.h5
|
|
combine_tables2.h5
|
|
file_img1.h5
|
|
file_img2.h5
|
|
test_append.h5
|
|
h5do_compat.h5
|
|
test_detach.h5
|
|
test_ds1.h5
|
|
test_ds2.h5
|
|
test_ds3.h5
|
|
test_ds4.h5
|
|
test_ds5.h5
|
|
test_ds6.h5
|
|
test_ds7.h5
|
|
test_ds8.h5
|
|
test_ds9.h5
|
|
test_ds10.h5
|
|
test_ds_class_prefix.h5
|
|
test_ds_reserved_prefix.h5
|
|
test_image1.h5
|
|
test_image2.h5
|
|
test_image3.h5
|
|
test_image_class_prefix.h5
|
|
test_lite1.h5
|
|
test_lite2.h5
|
|
test_lite3.h5
|
|
test_lite4.h5
|
|
test_packet_compress.h5
|
|
test_boundary.h5
|
|
test_packet_table.h5
|
|
test_packet_table_vlen.h5
|
|
testfl_packet_table_vlen.h5
|
|
test_table.h5
|
|
)
|
|
add_test (
|
|
NAME HL_test-clear-objects
|
|
COMMAND ${CMAKE_COMMAND} -E remove ${test_hl_CLEANFILES}
|
|
)
|
|
set_tests_properties (HL_test-clear-objects PROPERTIES
|
|
FIXTURES_SETUP clear_test_hl
|
|
WORKING_DIRECTORY ${HDF5_HL_TEST_BINARY_DIR}
|
|
)
|
|
add_test (
|
|
NAME HL_test-clean-objects
|
|
COMMAND ${CMAKE_COMMAND} -E remove ${test_hl_CLEANFILES}
|
|
)
|
|
set_tests_properties (HL_test-clean-objects PROPERTIES
|
|
FIXTURES_CLEANUP clear_test_hl
|
|
WORKING_DIRECTORY ${HDF5_HL_TEST_BINARY_DIR}
|
|
)
|
|
|
|
# --------------------------------------------------------------------
|
|
# Macro used to add a unit test
|
|
# --------------------------------------------------------------------
|
|
macro (HL_ADD_TEST hl_name)
|
|
set (current_test_name "HL_${hl_name}")
|
|
if (HDF5_ENABLE_USING_MEMCHECKER)
|
|
add_test (NAME HL_${hl_name} COMMAND $<TARGET_FILE:hl_${hl_name}>)
|
|
else ()
|
|
add_test (NAME HL_${hl_name} COMMAND "${CMAKE_COMMAND}"
|
|
-D "TEST_PROGRAM=$<TARGET_FILE:hl_${hl_name}>"
|
|
-D "TEST_ARGS:STRING="
|
|
-D "TEST_EXPECT=0"
|
|
-D "TEST_SKIP_COMPARE=TRUE"
|
|
-D "TEST_OUTPUT=hl_${hl_name}.txt"
|
|
#-D "TEST_REFERENCE=hl_${hl_name}.out"
|
|
-D "TEST_FOLDER=${HDF5_HL_TEST_BINARY_DIR}"
|
|
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
|
|
)
|
|
if ("hl_name" STREQUAL "test_table")
|
|
add_test (
|
|
NAME H5DUMP-HL_${hl_name}
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
-D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
|
|
-D "TEST_ARGS:STRING=--enable-error-stack;${hl_name}.h5"
|
|
-D "TEST_FOLDER=${HDF5_HL_TEST_BINARY_DIR}"
|
|
-D "TEST_OUTPUT=h5dump-${hl_name}.out"
|
|
-D "TEST_EXPECT=${resultcode}"
|
|
-D "TEST_REFERENCE=testfiles/${hl_name}.h5.ddl"
|
|
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
|
|
)
|
|
set_tests_properties (H5DUMP-HL_${hl_name} PROPERTIES
|
|
DEPENDS HL_${hl_name}
|
|
)
|
|
set (current_test_name "H5DUMP-HL_${hl_name}")
|
|
endif ()
|
|
endif ()
|
|
set_tests_properties (${current_test_name} PROPERTIES
|
|
FIXTURES_REQUIRED clear_test_hl
|
|
ENVIRONMENT "srcdir=${HDF5_HL_TEST_BINARY_DIR}"
|
|
WORKING_DIRECTORY ${HDF5_HL_TEST_BINARY_DIR}
|
|
)
|
|
if ("HL_${hl_name}" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
|
|
set_tests_properties (HL_${hl_name} PROPERTIES DISABLED true)
|
|
endif ()
|
|
endmacro ()
|
|
|
|
HL_add_test (test_lite )
|
|
HL_add_test (test_image)
|
|
HL_add_test (test_file_image)
|
|
HL_add_test (test_table)
|
|
HL_add_test (test_ds)
|
|
HL_add_test (test_packet)
|
|
HL_add_test (test_ld)
|
|
HL_add_test (test_dset_append)
|
|
HL_add_test (test_h5do_compat)
|
|
|