Skip to content

Split tool test generators into core/header files #5515

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

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions tools/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,90 @@
cmake_minimum_required (VERSION 3.18)
project (HDF5_TOOLS_TEST C)

set (HDF5_TOOLS
h5copy
h5diff
h5dump
h5format_convert
h5jam
h5repack
h5stat
)

set (HDF5_TOOLS_MISC
h5repart
# h5clear gentest requires special exit to leave IDs open, excluded here
# h5perf does not use gentest like other tools, excluded here
)

if (HDF5_BUILD_GENERATORS)
# Build main gentest
add_executable(h5gentest ${HDF5_TOOLS_TEST_SOURCE_DIR}/h5gentest.c)
target_include_directories (h5gentest PRIVATE
"${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};"
"$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")

if (HDF5_BUILD_STATIC_TOOLS)
TARGET_C_PROPERTIES (h5gentest STATIC)
target_link_libraries (h5gentest PRIVATE ${HDF5_LIB_TARGET})
else ()
TARGET_C_PROPERTIES (h5gentest SHARED)
target_link_libraries (h5gentest PRIVATE ${HDF5_LIBSH_TARGET})
endif ()

target_include_directories(h5gentest PRIVATE
"${HDF5_TOOLS_TEST_SOURCE_DIR}/misc"
)

# Build object libraries for gentest
foreach(tool ${HDF5_TOOLS};${HDF5_TOOLS_MISC})
if (${tool} IN_LIST HDF5_TOOLS_MISC)
add_library(${tool}gentest OBJECT ${HDF5_TOOLS_TEST_SOURCE_DIR}/misc/${tool}gentest.c)
target_include_directories (${tool}gentest PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_TEST_SRC_DIR};${HDF5_TOOLS_TST_DIR};${HDF5_TOOLS_ROOT_DIR}/misc;${HDF5_TOOLS_ROOT_DIR}/lib;${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
else()
add_library(${tool}gentest OBJECT ${HDF5_TOOLS_TEST_SOURCE_DIR}/${tool}/${tool}gentest.c)
target_include_directories (${tool}gentest PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_TEST_SRC_DIR};${HDF5_TOOLS_TST_DIR};${HDF5_TOOLS_ROOT_DIR}/lib;${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
endif()

if (HDF5_BUILD_STATIC_TOOLS)
TARGET_C_PROPERTIES(${tool}gentest STATIC)
target_link_libraries (${tool}gentest PRIVATE
${HDF5_LIB_TARGET}
${HDF5_TOOLS_LIB_TARGET}
${HDF5_REQUIRED_LIBRARIES} # For math lib
)
else ()
TARGET_C_PROPERTIES(${tool}gentest SHARED)
target_link_libraries (${tool}gentest PRIVATE
${HDF5_LIBSH_TARGET}
${HDF5_TOOLS_LIBSH_TARGET}
${HDF5_REQUIRED_LIBRARIES}
)
endif ()

target_include_directories(h5gentest PRIVATE
"${HDF5_TOOLS_TEST_SOURCE_DIR}/${tool}"
)

target_link_libraries(h5gentest PRIVATE ${tool}gentest)
endforeach()

set_target_properties (h5gentest PROPERTIES FOLDER generator/tools)

#-----------------------------------------------------------------------------
# Add Targets to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_TOOLS_TEST_H5COPY_FORMAT h5gentest)
foreach(tool ${HDF5_TOOLS})
string(TOUPPER ${tool} tool_upper)
clang_format (HDF5_TOOLS_TEST_${tool_upper}_FORMAT ${tool}gentest)
endforeach()
endif ()

#add_test (NAME h5gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5gentest>)
endif ()

#-- Add the h5diff tests
add_subdirectory (h5diff)

Expand Down
25 changes: 0 additions & 25 deletions tools/test/h5copy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
cmake_minimum_required (VERSION 3.18)
project (HDF5_TOOLS_TEST_H5COPY C)

# --------------------------------------------------------------------
# Add the h5copy test executables
# --------------------------------------------------------------------
if (HDF5_BUILD_GENERATORS)
add_executable (h5copygentest ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/h5copygentest.c)
target_include_directories (h5copygentest PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (HDF5_BUILD_STATIC_TOOLS)
TARGET_C_PROPERTIES (h5copygentest STATIC)
target_link_libraries (h5copygentest PRIVATE ${HDF5_LIB_TARGET})
else ()
TARGET_C_PROPERTIES (h5copygentest SHARED)
target_link_libraries (h5copygentest PRIVATE ${HDF5_LIBSH_TARGET})
endif ()
set_target_properties (h5copygentest PROPERTIES FOLDER generator/tools)

#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_TOOLS_TEST_H5COPY_FORMAT h5copygentest)
endif ()

#add_test (NAME h5copygentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copygentest>)
endif ()

#-----------------------------------------------------------------------------
# If plugin library tests can be tested
#-----------------------------------------------------------------------------
Expand Down
53 changes: 18 additions & 35 deletions tools/test/h5copy/h5copygentest.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
* [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
* Generate the binary hdf5 file for the h5copy tests
*/
#include "hdf5.h"
#include "H5private.h"
#include "h5copygentest.h"

/* HDF file names */
#define HDF_FILE1 "h5copytst.h5"
Expand All @@ -41,6 +39,7 @@
/* Obj reference */
#define OBJ_REF_DS "Dset1"
#define OBJ_REF_GRP "Group"

/* Region reference */
#define REG_REF_DS1 "Dset_REGREF"
#define REG_REF_DS2 "Dset2"
Expand All @@ -52,7 +51,7 @@
*
*-------------------------------------------------------------------------
*/
static void
void
gent_simple(hid_t loc_id)
{
hid_t sid, did;
Expand Down Expand Up @@ -80,7 +79,7 @@ gent_simple(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_chunked(hid_t loc_id)
{
hid_t sid, did, pid;
Expand Down Expand Up @@ -114,7 +113,7 @@ gent_chunked(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_compact(hid_t loc_id)
{
hid_t sid, did, pid;
Expand Down Expand Up @@ -147,7 +146,7 @@ gent_compact(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_compound(hid_t loc_id)
{
typedef struct s_t {
Expand Down Expand Up @@ -189,7 +188,7 @@ gent_compound(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_compressed(hid_t loc_id)
{
hid_t sid, did, pid;
Expand Down Expand Up @@ -229,7 +228,7 @@ gent_compressed(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_named_vl(hid_t loc_id)
{
hid_t sid, did, tid;
Expand Down Expand Up @@ -274,7 +273,7 @@ gent_named_vl(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_nested_vl(hid_t loc_id)
{
hid_t sid, did, tid1, tid2;
Expand Down Expand Up @@ -330,7 +329,7 @@ gent_nested_vl(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_att_compound_vlstr(hid_t loc_id)
{
typedef struct { /* Compound structure for the attribute */
Expand Down Expand Up @@ -409,7 +408,7 @@ gent_att_compound_vlstr(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_datasets(hid_t loc_id)
{
gent_simple(loc_id);
Expand All @@ -428,7 +427,7 @@ gent_datasets(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_empty_group(hid_t loc_id)
{
hid_t gid;
Expand All @@ -448,7 +447,7 @@ gent_empty_group(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_nested_datasets(hid_t loc_id)
{
hid_t gid;
Expand All @@ -471,7 +470,7 @@ gent_nested_datasets(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
static void
void
gent_nested_group(hid_t loc_id)
{
hid_t gid;
Expand Down Expand Up @@ -706,7 +705,7 @@ gen_region_ref(hid_t loc_id)
* Purpose: Testing with various objects
*
*------------------------------------------------------------------------*/
static void
void
Test_Obj_Copy(void)
{
hid_t fid = H5I_INVALID_HID; /* File id */
Expand Down Expand Up @@ -762,7 +761,7 @@ Test_Obj_Copy(void)
* Purpose: Testing with various references
*
*------------------------------------------------------------------------*/
static void
void
Test_Ref_Copy(void)
{
hid_t fid = 0;
Expand Down Expand Up @@ -921,7 +920,7 @@ gen_extlink_src(hid_t loc_id)
* Purpose: generate external link files
*
*------------------------------------------------------------------------*/
static void
void
Test_Extlink_Copy(void)
{
hid_t fid1 = 0;
Expand Down Expand Up @@ -958,20 +957,4 @@ Test_Extlink_Copy(void)
H5Fclose(fid1);
if (fid2 > 0)
H5Fclose(fid2);
}

/*-------------------------------------------------------------------------
* Function: main
*
*-------------------------------------------------------------------------
*/

int
main(void)
{
Test_Obj_Copy();
Test_Ref_Copy();
Test_Extlink_Copy();

return 0;
}
}
38 changes: 38 additions & 0 deletions tools/test/h5copy/h5copygentest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 *
* [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef H5COPY_GENTEST_H
#define H5COPY_GENTEST_H

#include "hdf5.h"

#define H5COPY_UDFILTER_FILE "tudfilter.h5"
#define H5COPY_UDFILTER_FILE2 "tudfilter2.h5"

void gent_simple(hid_t loc_id);
void gent_chunked(hid_t loc_id);
void gent_compact(hid_t loc_id);
void gent_compound(hid_t loc_id);
void gent_compressed(hid_t loc_id);
void gent_named_vl(hid_t loc_id);
void gent_nested_vl(hid_t loc_id);
void gent_att_compound_vlstr(hid_t loc_id);
void gent_datasets(hid_t loc_id);
void gent_empty_group(hid_t loc_id);
void gent_nested_datasets(hid_t loc_id);
void gent_nested_group(hid_t loc_id);

void Test_Obj_Copy(void);
void Test_Ref_Copy(void);
void Test_Extlink_Copy(void);

#endif /* H5COPY_GENTEST_H */
26 changes: 0 additions & 26 deletions tools/test/h5diff/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
cmake_minimum_required (VERSION 3.18)
project (HDF5_TOOLS_TEST_H5DIFF C)

# --------------------------------------------------------------------
# Add the h5diff and test executables
# --------------------------------------------------------------------
if (HDF5_BUILD_GENERATORS)
add_executable (h5diffgentest ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/h5diffgentest.c)
target_include_directories (h5diffgentest PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (HDF5_BUILD_STATIC_TOOLS)
TARGET_C_PROPERTIES (h5diffgentest STATIC)
target_link_libraries (h5diffgentest PRIVATE ${HDF5_LIB_TARGET})
else ()
TARGET_C_PROPERTIES (h5diffgentest SHARED)
# Link to HDF5_REQUIRED_LIBRARIES to include the math lib if necessary
target_link_libraries (h5diffgentest PRIVATE ${HDF5_LIBSH_TARGET} ${HDF5_REQUIRED_LIBRARIES})
endif ()
set_target_properties (h5diffgentest PROPERTIES FOLDER generator/tools)

#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_TOOLS_TEST_H5DIFF_FORMAT h5diffgentest)
endif ()

#add_test (NAME h5diffgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diffgentest>)
endif ()

#-----------------------------------------------------------------------------
# If plugin library tests can be tested
#-----------------------------------------------------------------------------
Expand Down
Loading
Loading