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

Conversation

jhendersonHDF
Copy link
Collaborator

Added new testframe.h header to document testing framework functions and split them away from h5test.h and from test programs that don't integrate with the testframe.c testing framework

Added new test setup callback to testframe.c testing framework

Added parameters to AddTest() to specify size of test parameters so they can be copied for later use

Enabled HDF5 error stacks in testframe.c framework by default and added some error stack suppressions to some testhdf5 tests

Added new maxthreads option to testframe.c framework to allow specifying the maximum number of threads a multi-threaded test can use

Moved TestExpress functionality out of testframe.c and into more general h5test.c for wider use by tests through getter and setter

Updated some tests to not mix and match functionality between h5test.c/h and testframe.c/h

Moved some functionality from testphdf5.h into testpar.h for parallel tests that aren't part of testphdf5

Added new parallel test library that contains common shared functionality for parallel tests (similar to h5test library)

@jhendersonHDF jhendersonHDF added Merge - To 1.14 This needs to be merged to HDF5 1.14 Priority - 2. Medium ⏹ It would be nice to have this in the next release Component - Parallel Parallel HDF5 (NOT thread-safety) Component - Testing Code in test or testpar directories, GitHub workflows Component - Build CMake, Autotools Type - Improvement Improvements that don't add a new feature or functionality labels Sep 27, 2024
@@ -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

{
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.

@@ -861,9 +861,11 @@ verify_attribute(hid_t fid, const char *table_name, const char *attr_name)

/* Verify values read in */
for (ii = 0; ii < ATTR_DIM; ii++)
if (attr_data[ii] != read_data[ii])
TestErrPrintf("%d: attribute data different: attr_data[%d]=%d, read_data[%d]=%d\n", __LINE__, ii,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TestErrPrintf was converted to fprintf(stderr, ...) for a few test files that weren't really integrated with the testframe.c framework.

@@ -990,14 +990,16 @@ test_compact_io(hid_t fapl)

/* Verify the dataset's layout and fill message versions */
if (fp->shared->low_bound == H5F_LIBVER_EARLIEST) {
VERIFY(dsetp->shared->layout.version, H5O_LAYOUT_VERSION_DEFAULT, "layout_ver_bounds");
Copy link
Collaborator Author

@jhendersonHDF jhendersonHDF Sep 27, 2024

Choose a reason for hiding this comment

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

Replaced usages of the VERIFY macro with equivalent logic for some test files that weren't really integrated with the testframe.c framework

@@ -16165,8 +16168,7 @@ main(void)
goto error;
printf("All dataset tests passed.\n");
#ifdef H5_HAVE_FILTER_SZIP
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 test never changes the test cleanup status and wasn't really integrated with the testframe.c framework, so the call to GetTestCleanup() wasn't useful.

@@ -2302,8 +2302,6 @@ main(void)
/* Reset library */
h5_test_init();
fapl = h5_fileaccess();
if (TestExpress > 0)
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 test doesn't do anything with the value of TestExpress

@@ -191,9 +191,6 @@ main(void)
"Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, high_string);
puts(msg);

if (VERBOSE_MED)
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 test never used the testframe.c framework and never changed the test verbosity, so checking for VERBOSE_MED had no effect.

@@ -26,9 +26,6 @@ static int test_plists(const char *filename_prefix);
int
main(void)
{
if (VERBOSE_MED)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same comment here as above

@@ -1633,8 +1633,6 @@ main(void)
/* Reset library */
h5_test_init();
fapl = h5_fileaccess();
if (TestExpress > 0)
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 test doesn't do anything with the value of TestExpress

size_t n_tests_failed_g = 0;
size_t n_tests_skipped_g = 0;
uint64_t vol_cap_flags_g = H5VL_CAP_FLAG_NONE;
static int TestExpress_g = -1; /* Whether to expedite testing. -1 means not set yet. */
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TestExpress functionality was moved back out of the testframe.c framework for more widespread usage in the future, but the global variable is once again hidden behind get/set functions so that tests don't have direct access to it.

uint64_t vol_cap_flags_g = H5VL_CAP_FLAG_NONE;

/* Whether h5_cleanup should clean up temporary testing files */
static bool do_test_file_cleanup_g = true;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

While this duplicates the GetTestCleanup() functionality from testframe.c into h5test.c, it prevents conflating the two functionalities. h5test.c's usage was also less structured (the application had to call h5_fixname to influence the status), so it seemed best to leave them separate for now until a potential unified testing framework can come together in the future.

*/
H5_ATTR_FORMAT(printf, 1, 2)
int
print_func(const char *format, ...)
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 longer needed at this point

@@ -24,77 +24,6 @@
#include "H5private.h"
#include "H5Eprivate.h"

/*
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nearly all of the below code was moved into testframe.h

@@ -1466,10 +1466,9 @@ main(void)
puts("All symbol table tests passed.");

/* Cleanup */
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 test wasn't integrated with testframe.c and never changed the cleanup status; GetTestCleanup() calls weren't useful here

TestErrPrintf("*** UNEXPECTED RESULT from %s at line %4d in %s\n", where, (int)__LINE__, __FILE__); \
} while (0)

/* definitions for command strings */
#define VERBOSITY_STR "Verbosity"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These macros aren't used anywhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a new parallel testing library in testpar/testpar.c that contains shared functionality among parallel tests. Only 2 functions are in it currently, but it separates parallel tests with a main() function from testframe.c-style tests like testphdf5.

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 file had a lot of functions copied into it from testphdf5 without having made any changes to those functions and without using them in this file, so they were removed. This file also had included testphdf5.h just for some of the macros and support functions, which were mostly moved into the parallel testing library.

@@ -1348,6 +1266,22 @@ dataset_writeAll(void)
/* Dataset5: point selection in File - Hyperslab selection in Memory*/
/* create a file dataspace independently */
point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER);
if (VERBOSE_MED) {
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 previously existed in point_set(), but that function was moved into the parallel testing library where VERBOSE_MED isn't available (since some tests don't integrate with the testframe.c framework). So this output section was moved into individual tests that do have access to VERBOSE_MED.

Copy link
Contributor

Choose a reason for hiding this comment

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

All of these replicated blocks would really benefit from a refactor into a subroutine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will look into pulling that back out into a separate function that isn't tied to VERBOSE_MED

@@ -115,8 +122,6 @@ main(int argc, char **argv)
if (data_array)
free(data_array);

nerrors += GetTestNumErrs();
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 test never used testframe.c functionality, so GetTestNumErrs() isn't useful here

@@ -4319,8 +4282,6 @@ main(int argc, char **argv)
return -1;
}

mpi_rank_framework_g = mpi_rank;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Instead of relying on parallel tests to set this global variable for the testframe.c framework somewhere in main, it gets passed to TestInit() now instead


/**
* --------------------------------------------------------------------------
* \ingroup H5TEST
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to have the doxygen group for these routines be called something like H5TESTFRAME?

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 particular opinion on the group name, especially since we don't currently have any testing documentation and this documentation won't get parsed by doxygen yet anyway until we decide to start doing that. H5TEST was just a generic name to keep all testing documentation together, but having a separate group for this framework would work just as well.

#include "h5test.h"

/* Include testing framework functionality */
#include "testframe.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Testframe currently includes h5test, so including them both here is redundant. I'm guessing the goal is to eventually separate the two?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Separate or ideally unify. In the meantime, both headers are included here without assuming what each header includes. testframe.h mostly just includes h5test.h as a convenience since library developers have generally assumed they can just include h5test.h and get everything needed. This is moving a bit more toward a test either including testframe.h or h5test.h, depending on the functionality needed, until tests are maybe made consistent at some point in the future. The general rule with these changes is the testhdf5-style tests can access functionality from both testframe.h and h5test.h, but not the other way around.

@qkoziol
Copy link
Contributor

qkoziol commented Oct 1, 2024

Looking at this now...

@jhendersonHDF jhendersonHDF force-pushed the feature/test_framework_refactor branch from 2f16023 to ba4fd07 Compare October 1, 2024 17:25
@jhendersonHDF
Copy link
Collaborator Author

Rebased off of develop

Added new testframe.h header to document testing framework functions and
split them away from h5test.h and from test programs that don't
integrate with the testframe.c testing framework

Added new test setup callback to testframe.c testing framework

Added parameters to AddTest() to specify size of test parameters so they
can be copied for later use

Enabled HDF5 error stacks in testframe.c framework by default and added
some error stack suppressions to some testhdf5 tests

Added new maxthreads option to testframe.c framework to allow specifying
the maximum number of threads a multi-threaded test can use

Moved TestExpress functionality out of testframe.c and into more general
h5test.c for wider use by tests through getter and setter

Updated some tests to not mix and match functionality between h5test.c/h
and testframe.c/h

Moved some functionality from testphdf5.h into testpar.h for parallel
tests that aren't part of testphdf5

Added new parallel test library that contains common shared
functionality for parallel tests (similar to h5test library)

/* Reduce the number of metadata cache slots, so that there are cache
* collisions during the raw data I/O on the chunked dataset. This stresses
* the metadata cache and tests for cache bugs. -QAK
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My comment above may not have showed up inline, but every single test function that was removed from this file wasn't being tested in the first place. They were exact or near-exact duplicates of the same functions from testphdf5's t_dset.c and they weren't actually being run by the t_2Gio.c testing; they simply existed in this file for no reason. Since t_2Gio.c previously included testphdf5.h, these functions matched the prototypes declared there for t_dset.c's tests and caused confusion for some code editors.

mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL);
VRFY((mem_dataspace >= 0), "");

/* Extend its current dim sizes before writing */
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, why was this test removed?

*/

void
extend_writeInd2(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here - why was this test removed?

H5Eset_auto2(H5E_DEFAULT, old_func, old_client_data);
H5Sclose(file_dataspace);

/* Read dataset1 using BYROW pattern */
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here - why removed?

*/

void
extend_writeAll(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here - removed?

* collisions during the raw data I/O on the chunked dataset. This stresses
* the metadata cache and tests for cache bugs. -QAK
*/
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here - removed?

* Define the dimensions of the overall datasets and create them.
* ------------------------------------------------------------- */

/* set up dataset storage chunk sizes and creation property list */
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here - removed?

dataset_print(start, block, data_array1);
}

/* create a memory dataspace independently */
Copy link
Contributor

Choose a reason for hiding this comment

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

So many tests removed, I'll stop commenting :-)

Copy link
Contributor

@qkoziol qkoziol left a comment

Choose a reason for hiding this comment

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

Generally speaking, this looks like a solid improvement to the testing infrastructure, particularly the TLC invested in improving the parallel tests. Just concerned about some of the tests that were removed.

@lrknox lrknox merged commit 34d6ef5 into HDFGroup:develop Oct 1, 2024
56 checks passed
lrknox pushed a commit to lrknox/hdf5 that referenced this pull request Oct 2, 2024
…roup#4891)

Added new testframe.h header to document testing framework functions and
split them away from h5test.h and from test programs that don't
integrate with the testframe.c testing framework

Added new test setup callback to testframe.c testing framework

Added parameters to AddTest() to specify size of test parameters so they
can be copied for later use

Enabled HDF5 error stacks in testframe.c framework by default and added
some error stack suppressions to some testhdf5 tests

Added new maxthreads option to testframe.c framework to allow specifying
the maximum number of threads a multi-threaded test can use

Moved TestExpress functionality out of testframe.c and into more general
h5test.c for wider use by tests through getter and setter

Updated some tests to not mix and match functionality between h5test.c/h
and testframe.c/h

Moved some functionality from testphdf5.h into testpar.h for parallel
tests that aren't part of testphdf5

Added new parallel test library that contains common shared
functionality for parallel tests (similar to h5test library)
lrknox pushed a commit that referenced this pull request Oct 2, 2024
Added new testframe.h header to document testing framework functions and
split them away from h5test.h and from test programs that don't
integrate with the testframe.c testing framework

Added new test setup callback to testframe.c testing framework

Added parameters to AddTest() to specify size of test parameters so they
can be copied for later use

Enabled HDF5 error stacks in testframe.c framework by default and added
some error stack suppressions to some testhdf5 tests

Added new maxthreads option to testframe.c framework to allow specifying
the maximum number of threads a multi-threaded test can use

Moved TestExpress functionality out of testframe.c and into more general
h5test.c for wider use by tests through getter and setter

Updated some tests to not mix and match functionality between h5test.c/h
and testframe.c/h

Moved some functionality from testphdf5.h into testpar.h for parallel
tests that aren't part of testphdf5

Added new parallel test library that contains common shared
functionality for parallel tests (similar to h5test library)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Build CMake, Autotools Component - Parallel Parallel HDF5 (NOT thread-safety) Component - Testing Code in test or testpar directories, GitHub workflows Merge - To 1.14 This needs to be merged to HDF5 1.14 Priority - 2. Medium ⏹ It would be nice to have this in the next release Type - Improvement Improvements that don't add a new feature or functionality
Projects
Status: Needs Merged
Development

Successfully merging this pull request may close these issues.

4 participants