Skip to content

Generate VOL tests for h5copy #5497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/vol_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ jobs:
# that this should be re-enabled in the future.
if: ${{ ! matrix.async }}
run: |
ctest --build-config ${{ inputs.build_mode }} -VV -R "HDF5_VOL_vol-cache" .
ctest --build-config ${{ inputs.build_mode }} -VV -R "HDF5_VOL_vol-cache" .
3 changes: 2 additions & 1 deletion .github/workflows/vol_rest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,5 @@ jobs:
HSDS_ENDPOINT=http+unix://%2Ftmp%2Fhs%2Fsn_1.sock \
ROOT_DIR=${{github.workspace}}/hsdsdata \
BUCKET_NAME=hsdstest \
ctest --build-config ${{ inputs.build_mode }} -VV -R "h5_api" .
ctest --build-config ${{ inputs.build_mode }} -VV -R "h5_api" -E "H5COPY" .

48 changes: 4 additions & 44 deletions CMakeVOL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#

include (FetchContent)
include (${HDF_RESOURCES_DIR}/HDF5Macros.cmake)

# Function to retrieve all of the CMake targets generated
# in a directory and all its subdirectories
Expand Down Expand Up @@ -89,51 +90,10 @@ if (HDF5_VOL_ALLOW_EXTERNAL MATCHES "GIT" OR HDF5_VOL_ALLOW_EXTERNAL MATCHES "LO
set (HDF5_EXTERNAL_VOL_TARGETS "")

foreach (vol_idx RANGE 1 ${HDF5_MAX_EXTERNAL_VOLS})
# Generate fixed-width index number prepended with 0s
# so VOL sources come in order from 1 - HDF5_MAX_EXTERNAL_VOLS
set (vol_idx_num_digits 2) # Based on HDF5_MAX_EXTERNAL_VOLS
set (vol_idx_fixed "${vol_idx}")
string (LENGTH "${vol_idx_fixed}" vol_idx_len)
while (vol_idx_len LESS vol_idx_num_digits)
string (PREPEND vol_idx_fixed "0")
math (EXPR vol_idx_len "${vol_idx_len}+1")
endwhile ()

if (HDF5_VOL_ALLOW_EXTERNAL MATCHES "GIT")
set (HDF5_VOL_URL${vol_idx_fixed} "" CACHE STRING "Git repository URL of an external HDF5 VOL connector to build")
mark_as_advanced (HDF5_VOL_URL${vol_idx_fixed})
set (HDF5_VOL_SOURCE "${HDF5_VOL_URL${vol_idx_fixed}}")
elseif(HDF5_VOL_ALLOW_EXTERNAL MATCHES "LOCAL_DIR")
set (HDF5_VOL_PATH${vol_idx_fixed} "" CACHE STRING "Path to the source directory of an external HDF5 VOL connector to build")
mark_as_advanced (HDF5_VOL_PATH${vol_idx_fixed})
set (HDF5_VOL_SOURCE "${HDF5_VOL_PATH${vol_idx_fixed}}")
endif()

if (NOT "${HDF5_VOL_SOURCE}" STREQUAL "")
# Deal with trailing slash in path for LOCAL_DIR case
if (HDF5_VOL_ALLOW_EXTERNAL MATCHES "LOCAL_DIR")
# Erase trailing slash
string (REGEX REPLACE "/$" "" HDF5_VOL_SOURCE ${HDF5_VOL_SOURCE})
endif()

# Extract the name of the VOL connector
string (FIND "${HDF5_VOL_SOURCE}" "/" hdf5_vol_name_pos REVERSE)
if (hdf5_vol_name_pos EQUAL -1)
if (HDF5_VOL_ALLOW_EXTERNAL MATCHES "GIT")
message (SEND_ERROR "Invalid URL '${HDF5_VOL_SOURCE}' specified for HDF5_VOL_URL${vol_idx_fixed}")
elseif (HDF5_VOL_ALLOW_EXTERNAL MATCHES "LOCAL_DIR")
message (SEND_ERROR "Invalid source path '${HDF5_VOL_SOURCE}' specified for HDF5_VOL_PATH${vol_idx_fixed}")
endif()
endif ()

math (EXPR hdf5_vol_name_pos "${hdf5_vol_name_pos}+1")

string (SUBSTRING "${HDF5_VOL_SOURCE}" ${hdf5_vol_name_pos} -1 hdf5_vol_name)
string (REPLACE ".git" "" hdf5_vol_name "${hdf5_vol_name}")
string (STRIP "${hdf5_vol_name}" hdf5_vol_name)
string (TOUPPER "${hdf5_vol_name}" hdf5_vol_name_upper)
string (TOLOWER "${hdf5_vol_name}" hdf5_vol_name_lower)
# Retrieve name from URL/path
LOAD_VOL_NAME(${vol_idx})

if (NOT ${hdf5_vol_name} STREQUAL "")
message (VERBOSE "Building VOL connector '${hdf5_vol_name}' with FetchContent from source ${HDF5_VOL_SOURCE}")

# Set some cache variables that can be set by users when building
Expand Down
55 changes: 55 additions & 0 deletions config/cmake/HDF5Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,58 @@ macro (H5_CREATE_VFD_DIR)
file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}")
endforeach ()
endmacro ()

# Retrieve the name of the VOL specified by the
# HDF5_VOL_URLXX/HDF5_VOL_PATHXX variables.
# Output vars are hdf5_vol_name, hdf5_vol_name_upper, hdf5_vol_name_lower
macro(LOAD_VOL_NAME vol_idx)
# Generate fixed-width index number prepended with 0s
# so VOL sources come in order from 1 - HDF5_MAX_EXTERNAL_VOLS
set (vol_idx_num_digits 2) # Based on HDF5_MAX_EXTERNAL_VOLS
set (vol_idx_fixed "${vol_idx}")
string (LENGTH "${vol_idx_fixed}" vol_idx_len)
while (vol_idx_len LESS vol_idx_num_digits)
string (PREPEND vol_idx_fixed "0")
math (EXPR vol_idx_len "${vol_idx_len}+1")
endwhile ()

if (HDF5_VOL_ALLOW_EXTERNAL MATCHES "GIT")
set (HDF5_VOL_URL${vol_idx_fixed} "" CACHE STRING "Git repository URL of an external HDF5 VOL connector to build")
mark_as_advanced (HDF5_VOL_URL${vol_idx_fixed})
set (HDF5_VOL_SOURCE "${HDF5_VOL_URL${vol_idx_fixed}}")
elseif(HDF5_VOL_ALLOW_EXTERNAL MATCHES "LOCAL_DIR")
set (HDF5_VOL_PATH${vol_idx_fixed} "" CACHE STRING "Path to the source directory of an external HDF5 VOL connector to build")
mark_as_advanced (HDF5_VOL_PATH${vol_idx_fixed})
set (HDF5_VOL_SOURCE "${HDF5_VOL_PATH${vol_idx_fixed}}")
endif()

if ("${HDF5_VOL_SOURCE}" STREQUAL "")
set (hdf5_vol_name "")
set (hdf5_vol_name_upper "")
set (hdf5_vol_name_lower "")
else()
# Deal with trailing slash in path for LOCAL_DIR case
if (HDF5_VOL_ALLOW_EXTERNAL MATCHES "LOCAL_DIR")
# Erase trailing slash
string (REGEX REPLACE "/$" "" HDF5_VOL_SOURCE ${HDF5_VOL_SOURCE})
endif()

# Extract the name of the VOL connector
string (FIND "${HDF5_VOL_SOURCE}" "/" hdf5_vol_name_pos REVERSE)
if (hdf5_vol_name_pos EQUAL -1)
if (HDF5_VOL_ALLOW_EXTERNAL MATCHES "GIT")
message (SEND_ERROR "Invalid URL '${HDF5_VOL_SOURCE}' specified for HDF5_VOL_URL${vol_idx_fixed}")
elseif (HDF5_VOL_ALLOW_EXTERNAL MATCHES "LOCAL_DIR")
message (SEND_ERROR "Invalid source path '${HDF5_VOL_SOURCE}' specified for HDF5_VOL_PATH${vol_idx_fixed}")
endif()
endif ()

math (EXPR hdf5_vol_name_pos "${hdf5_vol_name_pos}+1")

string (SUBSTRING "${HDF5_VOL_SOURCE}" ${hdf5_vol_name_pos} -1 hdf5_vol_name)
string (REPLACE ".git" "" hdf5_vol_name "${hdf5_vol_name}")
string (STRIP "${hdf5_vol_name}" hdf5_vol_name)
string (TOUPPER "${hdf5_vol_name}" hdf5_vol_name_upper)
string (TOLOWER "${hdf5_vol_name}" hdf5_vol_name_lower)
endif()
endmacro()
10 changes: 10 additions & 0 deletions config/cmake/HDFMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,16 @@ macro (HDFTEST_COPY_FILE src dest target)
list (APPEND ${target}_list "${dest}")
endmacro ()

macro (HDFTEST_REPACK_FILE src dest target dest_vol dest_vol_info)
add_custom_command(
OUTPUT "${dest}"
COMMAND "${CMAKE_CROSSCOMPILING_EMULATOR}"
ARGS $<TARGET_FILE:h5repack> --src-vol-name=native --dst-vol-name=${dest_vol} $<$<NOT:$<STREQUAL:${dest_vol_info},NONE>>:--dst-vol-info=${dest_vol_info}> "${src}" "${dest}"
DEPENDS "${src}"
)
list (APPEND ${target}_list "${dest}")
endmacro ()

macro (HDF_DIR_PATHS package_prefix)
option (HDF5_USE_GNU_DIRS "ON to use GNU Coding Standard install directory variables, OFF to use historical settings" OFF)
if (HDF5_USE_GNU_DIRS)
Expand Down
Loading
Loading