Skip to content
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

Refactor h5test.c, testframe.c and testpar.h testing frameworks #4891

Merged
Merged
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ set (HDF5_LIB_BASE "hdf5")

set (HDF5_LIB_CORE "")
set (HDF5_TEST_LIB_CORE "_test")
set (HDF5_TEST_PAR_LIB_CORE "_testpar")
set (HDF5_CPP_LIB_CORE "_cpp")
set (HDF5_HL_LIB_CORE "_hl")
set (HDF5_HL_CPP_LIB_CORE "_hl_cpp")
Expand All @@ -174,6 +175,7 @@ set (HDF5_JAVA_JNI_LIB_CORE "_java")

set (HDF5_LIB_CORENAME "${HDF5_LIB_BASE}")
set (HDF5_TEST_LIB_CORENAME "${HDF5_LIB_BASE}${HDF5_TEST_LIB_CORE}")
set (HDF5_TEST_PAR_LIB_CORENAME "${HDF5_LIB_BASE}${HDF5_TEST_PAR_LIB_CORE}")
set (HDF5_CPP_LIB_CORENAME "${HDF5_LIB_BASE}${HDF5_CPP_LIB_CORE}")
set (HDF5_HL_LIB_CORENAME "${HDF5_LIB_BASE}${HDF5_HL_LIB_CORE}")
set (HDF5_HL_CPP_LIB_CORENAME "${HDF5_LIB_BASE}${HDF5_HL_CPP_LIB_CORE}")
Expand All @@ -194,6 +196,7 @@ set (HDF5_JAVA_TEST_LIB_CORENAME "jartest5")
#-----------------------------------------------------------------------------
set (HDF5_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_LIB_BASE}${HDF5_LIB_INFIX}${HDF5_LIB_CORE}${HDF5_EXTERNAL_LIB_SUFFIX}")
set (HDF5_TEST_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_LIB_BASE}${HDF5_LIB_INFIX}${HDF5_TEST_LIB_CORE}${HDF5_EXTERNAL_LIB_SUFFIX}")
set (HDF5_TEST_PAR_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_LIB_BASE}${HDF5_LIB_INFIX}${HDF5_TEST_PAR_LIB_CORE}${HDF5_EXTERNAL_LIB_SUFFIX}")
set (HDF5_CPP_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_LIB_BASE}${HDF5_LIB_INFIX}${HDF5_CPP_LIB_CORE}${HDF5_EXTERNAL_LIB_SUFFIX}")
set (HDF5_HL_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_LIB_BASE}${HDF5_LIB_INFIX}${HDF5_HL_LIB_CORE}${HDF5_EXTERNAL_LIB_SUFFIX}")
set (HDF5_HL_CPP_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_LIB_BASE}${HDF5_LIB_INFIX}${HDF5_HL_CPP_LIB_CORE}${HDF5_EXTERNAL_LIB_SUFFIX}")
Expand All @@ -216,6 +219,7 @@ set (HDF5_JAVA_TEST_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_JAVA_TEST_LIB
#-----------------------------------------------------------------------------
set (HDF5_LIB_TARGET "${HDF5_LIB_CORENAME}-static")
set (HDF5_TEST_LIB_TARGET "${HDF5_TEST_LIB_CORENAME}-static")
set (HDF5_TEST_PAR_LIB_TARGET "${HDF5_TEST_PAR_LIB_CORENAME}-static")
set (HDF5_CPP_LIB_TARGET "${HDF5_CPP_LIB_CORENAME}-static")
set (HDF5_HL_LIB_TARGET "${HDF5_HL_LIB_CORENAME}-static")
set (HDF5_HL_CPP_LIB_TARGET "${HDF5_HL_CPP_LIB_CORENAME}-static")
Expand All @@ -232,6 +236,7 @@ set (HDF5_JAVA_HDF5_LIB_TARGET "${HDF5_JAVA_HDF5_LIB_CORENAME}")
set (HDF5_JAVA_TEST_LIB_TARGET "${HDF5_JAVA_TEST_LIB_CORENAME}")
set (HDF5_LIBSH_TARGET "${HDF5_LIB_CORENAME}-shared")
set (HDF5_TEST_LIBSH_TARGET "${HDF5_TEST_LIB_CORENAME}-shared")
set (HDF5_TEST_PAR_LIBSH_TARGET "${HDF5_TEST_PAR_LIB_CORENAME}-shared")
set (HDF5_CPP_LIBSH_TARGET "${HDF5_CPP_LIB_CORENAME}-shared")
set (HDF5_HL_LIBSH_TARGET "${HDF5_HL_LIB_CORENAME}-shared")
set (HDF5_HL_CPP_LIBSH_TARGET "${HDF5_HL_CPP_LIB_CORENAME}-shared")
Expand Down
13 changes: 6 additions & 7 deletions c++/test/dsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ test_read_string(H5File &file)
*-------------------------------------------------------------------------
*/
extern "C" void
test_dset()
test_dset(const void *params)
{
hid_t fapl_id;
fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template
Expand Down Expand Up @@ -1492,9 +1492,6 @@ test_dset()
catch (Exception &E) {
test_report(nerrors, H5std_string(" Dataset"));
}

// Clean up data file
cleanup_dsets();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to explicitly call this here since the testing framework will do this now

} // test_dset

/*-------------------------------------------------------------------------
Expand All @@ -1506,8 +1503,10 @@ test_dset()
*-------------------------------------------------------------------------
*/
extern "C" void
cleanup_dsets()
cleanup_dsets(void *params)
{
HDremove(FILE1.c_str());
HDremove(FILE_ACCPLIST.c_str());
if (GetTestCleanup()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a similar pattern replicated everywhere. The testing framework always calls the cleanup callback for a test now as the callback can do more than just cleanup temp. testing files. GetTestCleanup() just surrounds the part where the testing files are cleaned up.

HDremove(FILE1.c_str());
HDremove(FILE_ACCPLIST.c_str());
}
} // cleanup_dsets
61 changes: 31 additions & 30 deletions c++/test/h5cpputil.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
#define H5cpputil_H

#include "h5test.h"
#include "testframe.h"

using namespace H5;
using std::cerr;
using std::endl;

#define MESSAGE(V, A) \
do { \
if (HDGetTestVerbosity() > (V)) \
print_func A; \
if (GetTestVerbosity() > (V)) \
printf A; \
} while (0)
#define SUBTEST(TEST) \
do { \
Expand Down Expand Up @@ -142,36 +143,36 @@ verify_val(Type1 x, Type2 value, float epsilon, const char *msg, int line, const
#ifdef __cplusplus
extern "C" {
#endif
void test_array();
void test_attr();
void test_compound();
void test_dsproplist();
void test_file();
void test_filters();
void test_links();
void test_h5s();
void test_iterate();
void test_object();
void test_reference();
void test_types();
void test_vlstrings();
void test_dset();
void test_array(const void *params);
void test_attr(const void *params);
void test_compound(const void *params);
void test_dsproplist(const void *params);
void test_file(const void *params);
void test_filters(const void *params);
void test_links(const void *params);
void test_h5s(const void *params);
void test_iterate(const void *params);
void test_object(const void *params);
void test_reference(const void *params);
void test_types(const void *params);
void test_vlstrings(const void *params);
void test_dset(const void *params);

/* Prototypes for the cleanup routines */
void cleanup_array();
void cleanup_attr();
void cleanup_compound();
void cleanup_dsproplist();
void cleanup_dsets();
void cleanup_file();
void cleanup_filters();
void cleanup_h5s();
void cleanup_iterate();
void cleanup_links();
void cleanup_object();
void cleanup_reference();
void cleanup_types();
void cleanup_vlstrings();
void cleanup_array(void *params);
void cleanup_attr(void *params);
void cleanup_compound(void *params);
void cleanup_dsproplist(void *params);
void cleanup_dsets(void *params);
void cleanup_file(void *params);
void cleanup_filters(void *params);
void cleanup_h5s(void *params);
void cleanup_iterate(void *params);
void cleanup_links(void *params);
void cleanup_object(void *params);
void cleanup_reference(void *params);
void cleanup_types(void *params);
void cleanup_vlstrings(void *params);

#ifdef __cplusplus
}
Expand Down
8 changes: 5 additions & 3 deletions c++/test/tarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ test_array_info()
*-------------------------------------------------------------------------
*/
extern "C" void
test_array()
test_array(const void *params)
{
// Output message about test being performed
MESSAGE(5, ("Testing Array Datatypes\n"));
Expand All @@ -502,7 +502,9 @@ test_array()
*-------------------------------------------------------------------------
*/
extern "C" void
cleanup_array()
cleanup_array(void *params)
{
HDremove(FILENAME.c_str());
if (GetTestCleanup()) {
HDremove(FILENAME.c_str());
}
} // cleanup_array
18 changes: 10 additions & 8 deletions c++/test/tattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,7 @@ test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl)
*-------------------------------------------------------------------------
*/
extern "C" void
test_attr()
test_attr(const void *params)
{
// Output message about test being performed
MESSAGE(5, ("Testing Attributes\n"));
Expand Down Expand Up @@ -2041,12 +2041,14 @@ test_attr()
*-------------------------------------------------------------------------
*/
extern "C" void
cleanup_attr()
cleanup_attr(void *params)
{
HDremove(FILE_BASIC.c_str());
HDremove(FILE_COMPOUND.c_str());
HDremove(FILE_SCALAR.c_str());
HDremove(FILE_MULTI.c_str());
HDremove(FILE_DTYPE.c_str());
HDremove(FILE_CRTPROPS.c_str());
if (GetTestCleanup()) {
HDremove(FILE_BASIC.c_str());
HDremove(FILE_COMPOUND.c_str());
HDremove(FILE_SCALAR.c_str());
HDremove(FILE_MULTI.c_str());
HDremove(FILE_DTYPE.c_str());
HDremove(FILE_CRTPROPS.c_str());
}
}
8 changes: 5 additions & 3 deletions c++/test/tcompound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ test_compound_set_size()
*-------------------------------------------------------------------------
*/
extern "C" void
test_compound()
test_compound(const void *params)
{
// Output message about test being performed
MESSAGE(5, ("Testing Compound Data Type operations\n"));
Expand All @@ -753,7 +753,9 @@ test_compound()
*-------------------------------------------------------------------------
*/
extern "C" void
cleanup_compound()
cleanup_compound(void *params)
{
HDremove(COMPFILE.c_str());
if (GetTestCleanup()) {
HDremove(COMPFILE.c_str());
}
} // cleanup_file
8 changes: 5 additions & 3 deletions c++/test/tdspl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ test_transfplist()
*-------------------------------------------------------------------------
*/
extern "C" void
test_dsproplist()
test_dsproplist(const void *params)
{
// Output message about test being performed
MESSAGE(5, ("Testing Generic Dataset Property Lists\n"));
Expand All @@ -132,7 +132,9 @@ test_dsproplist()
*-------------------------------------------------------------------------
*/
extern "C" void
cleanup_dsproplist()
cleanup_dsproplist(void *params)
{
HDremove(FILENAME.c_str());
if (GetTestCleanup()) {
HDremove(FILENAME.c_str());
}
}
46 changes: 23 additions & 23 deletions c++/test/testhdf5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,50 +57,50 @@ main(int argc, char *argv[])
// caused deliberately and expected.
Exception::dontPrint();
/* Initialize testing framework */
TestInit(argv[0], NULL, NULL);
TestInit(argv[0], NULL, NULL, 0);

// testing file creation and opening in tfile.cpp
AddTest("tfile", test_file, cleanup_file, "File I/O Operations", NULL);
AddTest("tfile", test_file, NULL, cleanup_file, NULL, 0, "File I/O Operations");
// testing dataset functionalities in dset.cpp
AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL);
AddTest("dsets", test_dset, NULL, cleanup_dsets, NULL, 0, "Dataset I/O Operations");
// testing dataspace functionalities in th5s.cpp
AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL);
AddTest("th5s", test_h5s, NULL, cleanup_h5s, NULL, 0, "Dataspaces");
// testing attribute functionalities in tattr.cpp
AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL);
AddTest("tattr", test_attr, NULL, cleanup_attr, NULL, 0, "Attributes");
// testing object functionalities in tobject.cpp
AddTest("tobject", test_object, cleanup_object, "Objects", NULL);
AddTest("tobject", test_object, NULL, cleanup_object, NULL, 0, "Objects");
// testing reference functionalities in trefer.cpp
AddTest("trefer", test_reference, cleanup_reference, "References", NULL);
AddTest("trefer", test_reference, NULL, cleanup_reference, NULL, 0, "References");
// testing variable-length strings in tvlstr.cpp
AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL);
AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL);
AddTest("tarray", test_array, cleanup_array, "Array Datatypes", 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);
AddTest("tvlstr", test_vlstrings, NULL, cleanup_vlstrings, NULL, 0, "Variable-Length Strings");
AddTest("ttypes", test_types, NULL, cleanup_types, NULL, 0, "Generic Data Types");
AddTest("tarray", test_array, NULL, cleanup_array, NULL, 0, "Array Datatypes");
AddTest("tcompound", test_compound, NULL, cleanup_compound, NULL, 0, "Compound Data Types");
AddTest("tdspl", test_dsproplist, NULL, cleanup_dsproplist, NULL, 0, "Dataset Property List");
AddTest("tfilter", test_filters, NULL, cleanup_filters, NULL, 0, "Various Filters");
AddTest("tlinks", test_links, NULL, cleanup_links, NULL, 0, "Various Links");
/* Comment out tests that are not done yet. - BMR, Feb 2001
AddTest("select", test_select, cleanup_select, "Selections", NULL);
AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL);
AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL);
AddTest("select", test_select, NULL, cleanup_select, NULL, 0, "Selections");
AddTest("time", test_time, NULL, cleanup_time, NULL, 0, "Time Datatypes");
AddTest("vltypes", test_vltypes, NULL, cleanup_vltypes, NULL, 0, "Variable-Length Datatypes");
*/
AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL);
AddTest("iterate", test_iterate, NULL, cleanup_iterate, NULL, 0, "Group & Attribute Iteration");
/*
AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL);
AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL);
AddTest("genprop", test_genprop, NULL, cleanup_genprop, NULL, 0, "Generic Properties");
AddTest("id", test_ids, NULL, NULL, NULL, 0, "User-Created Identifiers");

Comment out tests that are not done yet */

/* Tentative - BMR 2007/1/12
AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL);
AddTest("enum", test_enum, NULL, cleanup_enum, NULL, 0, "Enum Data Types");
*/
}
catch (Exception &E) {
issue_fail_msg("Tests failed", __LINE__, __FILE__, E.getCDetailMsg());
}

/* Display testing information */
TestInfo(argv[0]);
TestInfo(stdout);

/* Parse command line arguments */
TestParseCmdLine(argc, argv);
Expand All @@ -110,7 +110,7 @@ main(int argc, char *argv[])

/* Display test summary, if requested */
if (GetTestSummary())
TestSummary();
TestSummary(stdout);

/* Clean up test files, if allowed */
if (GetTestCleanup() && !getenv(HDF5_NOCLEANUP))
Expand Down
20 changes: 11 additions & 9 deletions c++/test/tfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ test_file_info()
*-------------------------------------------------------------------------
*/
extern "C" void
test_file()
test_file(const void *params)
{
// Output message about test being performed
MESSAGE(5, ("Testing File I/O Operations\n"));
Expand Down Expand Up @@ -996,13 +996,15 @@ test_file()
extern "C"
#endif
void
cleanup_file()
cleanup_file(void *params)
{
HDremove(FILE1.c_str());
HDremove(FILE2.c_str());
HDremove(FILE3.c_str());
HDremove(FILE4.c_str());
HDremove(FILE5.c_str());
HDremove(FILE6.c_str());
HDremove(FILE7.c_str());
if (GetTestCleanup()) {
HDremove(FILE1.c_str());
HDremove(FILE2.c_str());
HDremove(FILE3.c_str());
HDremove(FILE4.c_str());
HDremove(FILE5.c_str());
HDremove(FILE6.c_str());
HDremove(FILE7.c_str());
}
} // cleanup_file
8 changes: 5 additions & 3 deletions c++/test/tfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ test_szip_filter(H5File &file1)
*/
const H5std_string FILE1("tfilters.h5");
extern "C" void
test_filters()
test_filters(const void *params)
{
// Output message about test being performed
MESSAGE(5, ("Testing Various Filters\n"));
Expand Down Expand Up @@ -259,7 +259,9 @@ test_filters()
*-------------------------------------------------------------------------
*/
extern "C" void
cleanup_filters()
cleanup_filters(void *params)
{
HDremove(FILE1.c_str());
if (GetTestCleanup()) {
HDremove(FILE1.c_str());
}
}
Loading
Loading