Skip to content

Commit cf2ca1f

Browse files
authored
Merge test file generators for tools (#5515)
* Add header files for tool gentest scripts * Correct library type for core targets * Use EXIT_SUCCESS/EXIT_FAILURE on script exit * Remove h5clear from merged script * Include gentest header * Add udfilter files to h5copy gen func * Add nerror returns to main generator functions * Move defines to tool headers * Add copyright header
1 parent 4cc7161 commit cf2ca1f

27 files changed

+1289
-1064
lines changed

tools/test/CMakeLists.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,90 @@
11
cmake_minimum_required (VERSION 3.18)
22
project (HDF5_TOOLS_TEST C)
33

4+
set (HDF5_TOOLS
5+
h5copy
6+
h5diff
7+
h5dump
8+
h5format_convert
9+
h5jam
10+
h5repack
11+
h5stat
12+
)
13+
14+
set (HDF5_TOOLS_MISC
15+
h5repart
16+
# h5clear gentest requires special exit to leave IDs open, excluded here
17+
# h5perf does not use gentest like other tools, excluded here
18+
)
19+
20+
if (HDF5_BUILD_GENERATORS)
21+
# Build main gentest
22+
add_executable(h5gentest ${HDF5_TOOLS_TEST_SOURCE_DIR}/h5gentest.c)
23+
target_include_directories (h5gentest PRIVATE
24+
"${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};"
25+
"$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
26+
27+
if (HDF5_BUILD_STATIC_TOOLS)
28+
TARGET_C_PROPERTIES (h5gentest STATIC)
29+
target_link_libraries (h5gentest PRIVATE ${HDF5_LIB_TARGET})
30+
else ()
31+
TARGET_C_PROPERTIES (h5gentest SHARED)
32+
target_link_libraries (h5gentest PRIVATE ${HDF5_LIBSH_TARGET})
33+
endif ()
34+
35+
target_include_directories(h5gentest PRIVATE
36+
"${HDF5_TOOLS_TEST_SOURCE_DIR}/misc"
37+
)
38+
39+
# Build object libraries for gentest
40+
foreach(tool ${HDF5_TOOLS};${HDF5_TOOLS_MISC})
41+
if (${tool} IN_LIST HDF5_TOOLS_MISC)
42+
add_library(${tool}gentest OBJECT ${HDF5_TOOLS_TEST_SOURCE_DIR}/misc/${tool}gentest.c)
43+
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}>")
44+
else()
45+
add_library(${tool}gentest OBJECT ${HDF5_TOOLS_TEST_SOURCE_DIR}/${tool}/${tool}gentest.c)
46+
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}>")
47+
endif()
48+
49+
if (HDF5_BUILD_STATIC_TOOLS)
50+
TARGET_C_PROPERTIES(${tool}gentest STATIC)
51+
target_link_libraries (${tool}gentest PRIVATE
52+
${HDF5_LIB_TARGET}
53+
${HDF5_TOOLS_LIB_TARGET}
54+
${HDF5_REQUIRED_LIBRARIES} # For math lib
55+
)
56+
else ()
57+
TARGET_C_PROPERTIES(${tool}gentest SHARED)
58+
target_link_libraries (${tool}gentest PRIVATE
59+
${HDF5_LIBSH_TARGET}
60+
${HDF5_TOOLS_LIBSH_TARGET}
61+
${HDF5_REQUIRED_LIBRARIES}
62+
)
63+
endif ()
64+
65+
target_include_directories(h5gentest PRIVATE
66+
"${HDF5_TOOLS_TEST_SOURCE_DIR}/${tool}"
67+
)
68+
69+
target_link_libraries(h5gentest PRIVATE ${tool}gentest)
70+
endforeach()
71+
72+
set_target_properties (h5gentest PROPERTIES FOLDER generator/tools)
73+
74+
#-----------------------------------------------------------------------------
75+
# Add Targets to clang-format
76+
#-----------------------------------------------------------------------------
77+
if (HDF5_ENABLE_FORMATTERS)
78+
clang_format (HDF5_TOOLS_TEST_H5COPY_FORMAT h5gentest)
79+
foreach(tool ${HDF5_TOOLS})
80+
string(TOUPPER ${tool} tool_upper)
81+
clang_format (HDF5_TOOLS_TEST_${tool_upper}_FORMAT ${tool}gentest)
82+
endforeach()
83+
endif ()
84+
85+
#add_test (NAME h5gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5gentest>)
86+
endif ()
87+
488
#-- Add the h5diff tests
589
add_subdirectory (h5diff)
690

tools/test/h5copy/CMakeLists.txt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
cmake_minimum_required (VERSION 3.18)
22
project (HDF5_TOOLS_TEST_H5COPY C)
33

4-
# --------------------------------------------------------------------
5-
# Add the h5copy test executables
6-
# --------------------------------------------------------------------
7-
if (HDF5_BUILD_GENERATORS)
8-
add_executable (h5copygentest ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/h5copygentest.c)
9-
target_include_directories (h5copygentest PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
10-
if (HDF5_BUILD_STATIC_TOOLS)
11-
TARGET_C_PROPERTIES (h5copygentest STATIC)
12-
target_link_libraries (h5copygentest PRIVATE ${HDF5_LIB_TARGET})
13-
else ()
14-
TARGET_C_PROPERTIES (h5copygentest SHARED)
15-
target_link_libraries (h5copygentest PRIVATE ${HDF5_LIBSH_TARGET})
16-
endif ()
17-
set_target_properties (h5copygentest PROPERTIES FOLDER generator/tools)
18-
19-
#-----------------------------------------------------------------------------
20-
# Add Target to clang-format
21-
#-----------------------------------------------------------------------------
22-
if (HDF5_ENABLE_FORMATTERS)
23-
clang_format (HDF5_TOOLS_TEST_H5COPY_FORMAT h5copygentest)
24-
endif ()
25-
26-
#add_test (NAME h5copygentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copygentest>)
27-
endif ()
28-
294
#-----------------------------------------------------------------------------
305
# If plugin library tests can be tested
316
#-----------------------------------------------------------------------------

tools/test/h5copy/h5copygentest.c

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
1111
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1212

13-
/*
14-
* Generate the binary hdf5 file for the h5copy tests
15-
*/
1613
#include "hdf5.h"
1714
#include "H5private.h"
15+
#include "h5copygentest.h"
1816

1917
/* HDF file names */
2018
#define HDF_FILE1 "h5copytst.h5"
@@ -41,6 +39,7 @@
4139
/* Obj reference */
4240
#define OBJ_REF_DS "Dset1"
4341
#define OBJ_REF_GRP "Group"
42+
4443
/* Region reference */
4544
#define REG_REF_DS1 "Dset_REGREF"
4645
#define REG_REF_DS2 "Dset2"
@@ -52,7 +51,7 @@
5251
*
5352
*-------------------------------------------------------------------------
5453
*/
55-
static void
54+
void
5655
gent_simple(hid_t loc_id)
5756
{
5857
hid_t sid, did;
@@ -80,7 +79,7 @@ gent_simple(hid_t loc_id)
8079
*
8180
*-------------------------------------------------------------------------
8281
*/
83-
static void
82+
void
8483
gent_chunked(hid_t loc_id)
8584
{
8685
hid_t sid, did, pid;
@@ -114,7 +113,7 @@ gent_chunked(hid_t loc_id)
114113
*
115114
*-------------------------------------------------------------------------
116115
*/
117-
static void
116+
void
118117
gent_compact(hid_t loc_id)
119118
{
120119
hid_t sid, did, pid;
@@ -147,7 +146,7 @@ gent_compact(hid_t loc_id)
147146
*
148147
*-------------------------------------------------------------------------
149148
*/
150-
static void
149+
void
151150
gent_compound(hid_t loc_id)
152151
{
153152
typedef struct s_t {
@@ -189,7 +188,7 @@ gent_compound(hid_t loc_id)
189188
*
190189
*-------------------------------------------------------------------------
191190
*/
192-
static void
191+
void
193192
gent_compressed(hid_t loc_id)
194193
{
195194
hid_t sid, did, pid;
@@ -229,7 +228,7 @@ gent_compressed(hid_t loc_id)
229228
*
230229
*-------------------------------------------------------------------------
231230
*/
232-
static void
231+
void
233232
gent_named_vl(hid_t loc_id)
234233
{
235234
hid_t sid, did, tid;
@@ -274,7 +273,7 @@ gent_named_vl(hid_t loc_id)
274273
*
275274
*-------------------------------------------------------------------------
276275
*/
277-
static void
276+
void
278277
gent_nested_vl(hid_t loc_id)
279278
{
280279
hid_t sid, did, tid1, tid2;
@@ -330,7 +329,7 @@ gent_nested_vl(hid_t loc_id)
330329
*
331330
*-------------------------------------------------------------------------
332331
*/
333-
static void
332+
void
334333
gent_att_compound_vlstr(hid_t loc_id)
335334
{
336335
typedef struct { /* Compound structure for the attribute */
@@ -409,7 +408,7 @@ gent_att_compound_vlstr(hid_t loc_id)
409408
*
410409
*-------------------------------------------------------------------------
411410
*/
412-
static void
411+
void
413412
gent_datasets(hid_t loc_id)
414413
{
415414
gent_simple(loc_id);
@@ -428,7 +427,7 @@ gent_datasets(hid_t loc_id)
428427
*
429428
*-------------------------------------------------------------------------
430429
*/
431-
static void
430+
void
432431
gent_empty_group(hid_t loc_id)
433432
{
434433
hid_t gid;
@@ -448,7 +447,7 @@ gent_empty_group(hid_t loc_id)
448447
*
449448
*-------------------------------------------------------------------------
450449
*/
451-
static void
450+
void
452451
gent_nested_datasets(hid_t loc_id)
453452
{
454453
hid_t gid;
@@ -471,7 +470,7 @@ gent_nested_datasets(hid_t loc_id)
471470
*
472471
*-------------------------------------------------------------------------
473472
*/
474-
static void
473+
void
475474
gent_nested_group(hid_t loc_id)
476475
{
477476
hid_t gid;
@@ -706,7 +705,7 @@ gen_region_ref(hid_t loc_id)
706705
* Purpose: Testing with various objects
707706
*
708707
*------------------------------------------------------------------------*/
709-
static void
708+
void
710709
Test_Obj_Copy(void)
711710
{
712711
hid_t fid = H5I_INVALID_HID; /* File id */
@@ -762,7 +761,7 @@ Test_Obj_Copy(void)
762761
* Purpose: Testing with various references
763762
*
764763
*------------------------------------------------------------------------*/
765-
static void
764+
void
766765
Test_Ref_Copy(void)
767766
{
768767
hid_t fid = 0;
@@ -921,7 +920,7 @@ gen_extlink_src(hid_t loc_id)
921920
* Purpose: generate external link files
922921
*
923922
*------------------------------------------------------------------------*/
924-
static void
923+
void
925924
Test_Extlink_Copy(void)
926925
{
927926
hid_t fid1 = 0;
@@ -958,20 +957,4 @@ Test_Extlink_Copy(void)
958957
H5Fclose(fid1);
959958
if (fid2 > 0)
960959
H5Fclose(fid2);
961-
}
962-
963-
/*-------------------------------------------------------------------------
964-
* Function: main
965-
*
966-
*-------------------------------------------------------------------------
967-
*/
968-
969-
int
970-
main(void)
971-
{
972-
Test_Obj_Copy();
973-
Test_Ref_Copy();
974-
Test_Extlink_Copy();
975-
976-
return 0;
977-
}
960+
}

tools/test/h5copy/h5copygentest.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2+
* Copyright by The HDF Group. *
3+
* All rights reserved. *
4+
* *
5+
* This file is part of HDF5. The full HDF5 copyright notice, including *
6+
* terms governing use, modification, and redistribution, is contained in *
7+
* the LICENSE file, which can be found at the root of the source code *
8+
* distribution tree, or in https://www.hdfgroup.org/licenses. *
9+
* If you do not have access to either file, you may request a copy from *
10+
11+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12+
13+
#ifndef H5COPY_GENTEST_H
14+
#define H5COPY_GENTEST_H
15+
16+
#include "hdf5.h"
17+
18+
#define H5COPY_UDFILTER_FILE "tudfilter.h5"
19+
#define H5COPY_UDFILTER_FILE2 "tudfilter2.h5"
20+
21+
void gent_simple(hid_t loc_id);
22+
void gent_chunked(hid_t loc_id);
23+
void gent_compact(hid_t loc_id);
24+
void gent_compound(hid_t loc_id);
25+
void gent_compressed(hid_t loc_id);
26+
void gent_named_vl(hid_t loc_id);
27+
void gent_nested_vl(hid_t loc_id);
28+
void gent_att_compound_vlstr(hid_t loc_id);
29+
void gent_datasets(hid_t loc_id);
30+
void gent_empty_group(hid_t loc_id);
31+
void gent_nested_datasets(hid_t loc_id);
32+
void gent_nested_group(hid_t loc_id);
33+
34+
void Test_Obj_Copy(void);
35+
void Test_Ref_Copy(void);
36+
void Test_Extlink_Copy(void);
37+
38+
#endif /* H5COPY_GENTEST_H */

tools/test/h5diff/CMakeLists.txt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
11
cmake_minimum_required (VERSION 3.18)
22
project (HDF5_TOOLS_TEST_H5DIFF C)
33

4-
# --------------------------------------------------------------------
5-
# Add the h5diff and test executables
6-
# --------------------------------------------------------------------
7-
if (HDF5_BUILD_GENERATORS)
8-
add_executable (h5diffgentest ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/h5diffgentest.c)
9-
target_include_directories (h5diffgentest PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
10-
if (HDF5_BUILD_STATIC_TOOLS)
11-
TARGET_C_PROPERTIES (h5diffgentest STATIC)
12-
target_link_libraries (h5diffgentest PRIVATE ${HDF5_LIB_TARGET})
13-
else ()
14-
TARGET_C_PROPERTIES (h5diffgentest SHARED)
15-
# Link to HDF5_REQUIRED_LIBRARIES to include the math lib if necessary
16-
target_link_libraries (h5diffgentest PRIVATE ${HDF5_LIBSH_TARGET} ${HDF5_REQUIRED_LIBRARIES})
17-
endif ()
18-
set_target_properties (h5diffgentest PROPERTIES FOLDER generator/tools)
19-
20-
#-----------------------------------------------------------------------------
21-
# Add Target to clang-format
22-
#-----------------------------------------------------------------------------
23-
if (HDF5_ENABLE_FORMATTERS)
24-
clang_format (HDF5_TOOLS_TEST_H5DIFF_FORMAT h5diffgentest)
25-
endif ()
26-
27-
#add_test (NAME h5diffgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diffgentest>)
28-
endif ()
29-
304
#-----------------------------------------------------------------------------
315
# If plugin library tests can be tested
326
#-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)