diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h index 4b34be52b50..6c8560d5c8d 100644 --- a/c++/test/h5cpputil.h +++ b/c++/test/h5cpputil.h @@ -30,7 +30,7 @@ using std::endl; #define MESSAGE(V, A) \ do { \ - if (HDGetTestVerbosity() > (V)) \ + if (GetTestVerbosity() > (V)) \ printf A; \ } while (0) #define SUBTEST(TEST) \ diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 9a86b8ab75d..ec4e917b50e 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -18,7 +18,7 @@ #define H5F_TESTING #include "H5Fpkg.h" -#include "testhdf5.h" +#include "h5test.h" #include "cache_common.h" #include "H5CXprivate.h" /* API Contexts */ diff --git a/test/chunk_info.c b/test/chunk_info.c index 4591b7242b4..fc3168e1b8f 100644 --- a/test/chunk_info.c +++ b/test/chunk_info.c @@ -38,7 +38,7 @@ #define H5D_TESTING /* to use H5D__ functions */ #include "H5Dpkg.h" -#include "testhdf5.h" +#include "h5test.h" #ifdef H5_HAVE_FILTER_DEFLATE #include "zlib.h" #endif diff --git a/test/dsets.c b/test/dsets.c index 1b273c418ba..e88dbc25d6c 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -20,7 +20,7 @@ #define H5Z_FRIEND /*suppress error about including H5Zpkg */ -#include "testhdf5.h" +#include "h5test.h" #include "H5srcdir.h" #include "H5CXprivate.h" /* API Contexts */ diff --git a/test/dtypes.c b/test/dtypes.c index 72f9a5d5b03..c5f3422a0e5 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -14,7 +14,7 @@ * Purpose: Tests the datatype interface (H5T) */ -#include "testhdf5.h" +#include "h5test.h" #include "H5srcdir.h" #include "H5Iprivate.h" /* For checking that datatype id's don't leak */ @@ -9956,7 +9956,8 @@ verify_version(hid_t dtype, H5F_libver_t low, unsigned *highest_version) /* Get the base datatype of this array type */ base_dtype = H5Tget_super(dtype); - CHECK(base_dtype, FAIL, "H5Tget_super"); + if (base_dtype == H5I_INVALID_HID) + TEST_ERROR; /* Get the base type's internal structure for version */ base_dtypep = (H5T_t *)H5I_object(base_dtype); diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index 3fe137efd77..7a289618eaa 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -191,9 +191,6 @@ main(void) "Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, high_string); puts(msg); - if (VERBOSE_MED) - printf("Encode/Decode DCPLs\n"); - /******* ENCODE/DECODE DCPLS *****/ TESTING("Default DCPL Encoding/Decoding"); if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) diff --git a/test/enc_dec_plist_cross_platform.c b/test/enc_dec_plist_cross_platform.c index d2d68105986..e7403576a8e 100644 --- a/test/enc_dec_plist_cross_platform.c +++ b/test/enc_dec_plist_cross_platform.c @@ -26,9 +26,6 @@ static int test_plists(const char *filename_prefix); int main(void) { - if (VERBOSE_MED) - printf("Encode/Decode property list endianness\n"); - /******* ENCODE/DECODE DCPLS *****/ TESTING("Default DCPL Encoding/Decoding"); if (test_plists("plist_files/def_dcpl_") < 0) diff --git a/test/flushrefresh.c b/test/flushrefresh.c index bab334f1c68..0e662209212 100644 --- a/test/flushrefresh.c +++ b/test/flushrefresh.c @@ -26,7 +26,7 @@ /* Includes */ /* ======== */ -#include "testhdf5.h" +#include "h5test.h" #include "H5FDpkg.h" /* File Drivers */ /* ======= */ diff --git a/test/h5test.h b/test/h5test.h index 1ee99efa383..1b33664fbf0 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -24,48 +24,6 @@ #include "H5private.h" #include "H5Eprivate.h" -/* - * Predefined test verbosity levels. - * - * Convention: - * - * The higher the verbosity value, the more information printed. - * So, output for higher verbosity also include output of all lower - * verbosity. - * - * Value Description - * 0 None: No informational message. - * 1 "All tests passed" - * 2 Header of overall test - * 3 Default: header and results of individual test - * 4 - * 5 Low: Major category of tests. - * 6 - * 7 Medium: Minor category of tests such as functions called. - * 8 - * 9 High: Highest level. All information. - */ -#define VERBO_NONE 0 /* None */ -#define VERBO_DEF 3 /* Default */ -#define VERBO_LO 5 /* Low */ -#define VERBO_MED 7 /* Medium */ -#define VERBO_HI 9 /* High */ - -/* - * Verbose queries - * Only None needs an exact match. The rest are at least as much. - */ - -/* A macro version of HDGetTestVerbosity(). */ -/* Should be used internally by the libtest.a only. */ -#define HDGetTestVerbosity() (TestVerbosity_g) - -#define VERBOSE_NONE (HDGetTestVerbosity() == VERBO_NONE) -#define VERBOSE_DEF (HDGetTestVerbosity() >= VERBO_DEF) -#define VERBOSE_LO (HDGetTestVerbosity() >= VERBO_LO) -#define VERBOSE_MED (HDGetTestVerbosity() >= VERBO_MED) -#define VERBOSE_HI (HDGetTestVerbosity() >= VERBO_HI) - /* * This contains the filename prefix specified as command line option for * the parallel test files. @@ -321,7 +279,6 @@ H5TEST_DLL char *getenv_all(MPI_Comm comm, int root, const char *name); #endif /* Extern global variables */ -H5TEST_DLLVAR int TestVerbosity_g; H5TEST_DLLVAR size_t n_tests_run_g; H5TEST_DLLVAR size_t n_tests_passed_g; H5TEST_DLLVAR size_t n_tests_failed_g; diff --git a/test/objcopy.c b/test/objcopy.c index 72dfdea6d3e..88a709ad5ee 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -14,7 +14,7 @@ * Purpose: Test H5Ocopy(). */ -#include "testhdf5.h" +#include "h5test.h" #include "H5srcdir.h" #include "H5Iprivate.h" @@ -10063,14 +10063,14 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, for (i = 0; i < DIM_SIZE_1; i++) { buf[i].p = malloc((i + 1) * sizeof(hvl_t)); if (buf[i].p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u\n", i); + fprintf(stderr, "Cannot allocate memory for VL data! i=%u\n", i); return 1; } /* end if */ buf[i].len = i + 1; for (tvl = (hvl_t *)buf[i].p, j = 0; j < (i + 1); j++, tvl++) { tvl->p = malloc((j + 1) * sizeof(unsigned int)); if (tvl->p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); + fprintf(stderr, "Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return 1; } /* end if */ tvl->len = j + 1; @@ -10260,14 +10260,14 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h for (i = 0; i < DIM_SIZE_1; i++) { buf[i].p = malloc((i + 1) * sizeof(hvl_t)); if (buf[i].p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u\n", i); + fprintf(stderr, "Cannot allocate memory for VL data! i=%u\n", i); TEST_ERROR; } /* end if */ buf[i].len = i + 1; for (tvl = (hvl_t *)buf[i].p, j = 0; j < (i + 1); j++, tvl++) { tvl->p = malloc((j + 1) * sizeof(unsigned int)); if (tvl->p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); + fprintf(stderr, "Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); TEST_ERROR; } /* end if */ tvl->len = j + 1; @@ -10452,14 +10452,14 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, for (i = 0; i < DIM_SIZE_1; i++) { buf[i].p = malloc((i + 1) * sizeof(hvl_t)); if (buf[i].p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u\n", i); + fprintf(stderr, "Cannot allocate memory for VL data! i=%u\n", i); TEST_ERROR; } /* end if */ buf[i].len = i + 1; for (tvl = (hvl_t *)buf[i].p, j = 0; j < (i + 1); j++, tvl++) { tvl->p = malloc((j + 1) * sizeof(unsigned int)); if (tvl->p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); + fprintf(stderr, "Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); TEST_ERROR; } /* end if */ tvl->len = j + 1; @@ -10693,14 +10693,14 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap for (i = 0; i < DIM_SIZE_1; i++) { buf[i].p = malloc((i + 1) * sizeof(hvl_t)); if (buf[i].p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u\n", i); + fprintf(stderr, "Cannot allocate memory for VL data! i=%u\n", i); TEST_ERROR; } /* end if */ buf[i].len = i + 1; for (tvl = (hvl_t *)buf[i].p, j = 0; j < (i + 1); j++, tvl++) { tvl->p = malloc((j + 1) * sizeof(unsigned int)); if (tvl->p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); + fprintf(stderr, "Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); TEST_ERROR; } /* end if */ tvl->len = j + 1; diff --git a/test/objcopy_ref.c b/test/objcopy_ref.c index d21b3d71bb6..0aed2a0d010 100644 --- a/test/objcopy_ref.c +++ b/test/objcopy_ref.c @@ -14,7 +14,7 @@ * Purpose: Test H5Ocopy() for references. */ -#include "testhdf5.h" +#include "h5test.h" #define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING diff --git a/test/select_io_dset.c b/test/select_io_dset.c index f9a4975eb50..c17d3b03a21 100644 --- a/test/select_io_dset.c +++ b/test/select_io_dset.c @@ -14,7 +14,7 @@ * Purpose: Tests selection IO for the dataset interface (H5D) */ -#include "testhdf5.h" +#include "h5test.h" #include "H5srcdir.h" const char *FILENAME[] = {"select_io", /* 0 */ diff --git a/test/tattr.c b/test/tattr.c index 0a889081042..4831e1604b0 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -4009,7 +4009,16 @@ test_attr_big(hid_t fcpl, hid_t fapl) /* Create attribute */ u = 2; snprintf(attrname, sizeof(attrname), "attr %02u", u); - attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, big_sid, H5P_DEFAULT, H5P_DEFAULT); + + if (vol_is_native && low != H5F_LIBVER_LATEST) { + H5E_BEGIN_TRY + { + attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, big_sid, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY + } + else + attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, big_sid, H5P_DEFAULT, H5P_DEFAULT); if (low == H5F_LIBVER_LATEST) { CHECK(attr, FAIL, "H5Acreate2"); diff --git a/test/testframe.c b/test/testframe.c index 8cb527036ec..9863fb9fafd 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -17,8 +17,6 @@ #include "testframe.h" #include "h5test.h" -#include "testhdf5.h" /* TODO: separate and remove */ - /* * Definitions for the testing structure. */ @@ -46,15 +44,16 @@ static const char *TestProgName = NULL; static void (*TestPrivateUsage_g)(FILE *stream) = NULL; static herr_t (*TestPrivateParser_g)(int argc, char *argv[]) = NULL; -int TestVerbosity_g = VERBO_DEF; /* Default Verbosity is Low */ /* TODO: can probably be static */ -static int TestMaxNumThreads_g = 0; /* Max number of threads that can be spawned */ +static int TestNumErrs_g = 0; /* Total number of errors that occurred for whole test program */ +static bool TestEnableErrorStack = true; /* Whether to show error stacks from the library */ + +static int TestMaxNumThreads_g = -1; /* Max number of threads that can be spawned */ -static int TestNumErrs_g = 0; /* Total number of errors that occurred for whole test program */ -static int enable_error_stack = 1; /* enable error stack; disable=0 enable=1 */ -int TestFrameworkMPIRank_g = 0; /* MPI process rank value for parallel tests */ +static bool TestDoSummary_g = false; /* Show test summary. Default is no. */ +static bool TestDoCleanUp_g = true; /* Do cleanup or not. Default is yes. */ -static bool TestDoSummary_g = 0; /* Show test summary. Default is no. */ -static int TestDoCleanUp_g = 1; /* Do cleanup or not. Default is yes. */ +int TestFrameworkProcessID_g = 0; /* MPI process rank value for parallel tests */ +int TestVerbosity_g = VERBO_DEF; /* Default Verbosity is Low */ /* * Add a new test to the list of tests to be executed @@ -141,7 +140,7 @@ TestInit(const char *ProgName, void (*TestPrivateUsage)(FILE *stream), int TestProcessID) { /* Turn off automatic error reporting if requested */ - if (enable_error_stack == 0) { + if (!TestEnableErrorStack) { if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) { fprintf(stderr, "%s: can't disable error stack\n", __func__); return FAIL; @@ -158,17 +157,16 @@ TestInit(const char *ProgName, void (*TestPrivateUsage)(FILE *stream), if (NULL != TestPrivateParser) TestPrivateParser_g = TestPrivateParser; - TestFrameworkMPIRank_g = TestProcessID; + TestFrameworkProcessID_g = TestProcessID; - /* Reset global variables used by the testing framework */ - /* TODO: move from h5test to here */ + /* Set/reset global variables from h5test that may be used by + * tests integrated with the testing framework + */ n_tests_run_g = 0; n_tests_passed_g = 0; n_tests_failed_g = 0; n_tests_skipped_g = 0; - /* TODO: set global so other functions can know if test framework was initialized */ - return SUCCEED; } @@ -178,8 +176,10 @@ TestInit(const char *ProgName, void (*TestPrivateUsage)(FILE *stream), void TestUsage(FILE *stream) { + size_t max_test_name_len = 0; + /* If running in parallel, only print output from a single MPI process */ - if (TestFrameworkMPIRank_g != 0) + if (TestFrameworkProcessID_g != 0) return; if (!stream) @@ -208,12 +208,21 @@ TestUsage(FILE *stream) TestPrivateUsage_g(stream); } fprintf(stream, "\n\n"); + + /* Collect some information for cleaner printing */ + for (unsigned Loop = 0; Loop < TestCount; Loop++) { + size_t test_name_len = strlen(TestArray[Loop].Name); + + if (test_name_len > max_test_name_len) + max_test_name_len = test_name_len; + } + fprintf(stream, "This program currently tests the following: \n\n"); - fprintf(stream, "%16s %s\n", "Name", "Description"); - fprintf(stream, "%16s %s\n", "----", "-----------"); + fprintf(stream, "%*s %s\n", (int)max_test_name_len, "Name", " Description"); + fprintf(stream, "%*s %s\n", (int)max_test_name_len, "----", " -----------"); for (unsigned i = 0; i < TestCount; i++) - fprintf(stream, "%16s -- %s\n", TestArray[i].Name, TestArray[i].Description); + fprintf(stream, "%*s %s\n", (int)max_test_name_len, TestArray[i].Name, TestArray[i].Description); fprintf(stream, "\n\n"); } @@ -227,7 +236,7 @@ TestInfo(FILE *stream) unsigned major, minor, release; /* If running in parallel, only print output from a single MPI process */ - if (TestFrameworkMPIRank_g != 0) + if (TestFrameworkProcessID_g != 0) return; if (!stream) @@ -310,9 +319,8 @@ TestParseCmdLine(int argc, char *argv[]) } else if ((strcmp(*argv, "-summary") == 0) || (strcmp(*argv, "-s") == 0)) TestDoSummary_g = true; - else if (strcmp(*argv, "-enable-error-stack") == 0) { - /* TODO: implement logic to disable error stack if requested */ - enable_error_stack = 1; + else if (strcmp(*argv, "-disable-error-stack") == 0) { + TestEnableErrorStack = false; } else if ((strcmp(*argv, "-help") == 0) || (strcmp(*argv, "-h") == 0)) { TestUsage(stdout); @@ -383,12 +391,12 @@ PerformTests(void) int old_num_errs = TestNumErrs_g; if (TestArray[Loop].TestSkipFlag) { - if (TestFrameworkMPIRank_g == 0) + if (TestFrameworkProcessID_g == 0) MESSAGE(2, ("Skipping -- %s (%s) \n", TestArray[Loop].Description, TestArray[Loop].Name)); continue; } - if (TestFrameworkMPIRank_g == 0) { + if (TestFrameworkProcessID_g == 0) { MESSAGE(2, ("Testing -- %s (%s) \n", TestArray[Loop].Description, TestArray[Loop].Name)); MESSAGE(5, ("===============================================\n")); } @@ -407,13 +415,13 @@ PerformTests(void) TestArray[Loop].TestNumErrors = TestNumErrs_g - old_num_errs; - if (TestFrameworkMPIRank_g == 0) { + if (TestFrameworkProcessID_g == 0) { MESSAGE(5, ("===============================================\n")); MESSAGE(5, ("There were %d errors detected.\n\n", TestArray[Loop].TestNumErrors)); } } - if (TestFrameworkMPIRank_g == 0) { + if (TestFrameworkProcessID_g == 0) { MESSAGE(2, ("\n\n")); if (TestNumErrs_g) MESSAGE(VERBO_NONE, ("!!! %d Error(s) were detected !!!\n\n", TestNumErrs_g)); @@ -428,24 +436,59 @@ PerformTests(void) void TestSummary(FILE *stream) { + size_t max_test_name_len = 0; + size_t max_test_desc_len = 0; + size_t test_name_header_len = 0; + size_t test_desc_header_len = 0; + /* If running in parallel, only print output from a single MPI process */ - if (TestFrameworkMPIRank_g != 0) + if (TestFrameworkProcessID_g != 0) return; if (!stream) stream = stdout; - /* TODO: dynamically adjust headers based on max test name length */ + /* Collect some information for cleaner printing */ + for (unsigned Loop = 0; Loop < TestCount; Loop++) { + size_t test_name_len = strlen(TestArray[Loop].Name); + size_t test_desc_len = strlen(TestArray[Loop].Description); + + if (test_name_len > max_test_name_len) + max_test_name_len = test_name_len; + if (test_desc_len > max_test_desc_len) + max_test_desc_len = test_desc_len; + } + + test_name_header_len = MAX(max_test_name_len, strlen("Name of Test")); + test_desc_header_len = MAX(max_test_desc_len, strlen("Description of Test")); + + /* Print header, adjusted to maximum test name and description lengths */ fprintf(stream, "Summary of Test Results:\n"); - fprintf(stream, "Name of Test Errors Description of Test\n"); - fprintf(stream, "---------------- ------ --------------------------------------\n"); + fprintf(stream, "%-*s Errors %-*s\n", (int)test_name_header_len, "Name of Test", + (int)test_desc_header_len, "Description of Test"); + + /* Print a separating line row for each column header, adjusted to maximum + * test name and description lengths + */ + for (size_t i = 0; i < test_name_header_len; i++) /* 'Name of Test' */ + putc('-', stream); + putc(' ', stream); + putc(' ', stream); + for (size_t i = 0; i < 6; i++) /* 'Errors' */ + putc('-', stream); + putc(' ', stream); + putc(' ', stream); + for (size_t i = 0; i < test_desc_header_len; i++) /* 'Description of Test' */ + putc('-', stream); + putc('\n', stream); for (unsigned Loop = 0; Loop < TestCount; Loop++) { if (TestArray[Loop].TestNumErrors == -1) - fprintf(stream, "%16s %6s %s\n", TestArray[Loop].Name, "N/A", TestArray[Loop].Description); + fprintf(stream, "%-*s %-6s %-*s\n", (int)test_name_header_len, TestArray[Loop].Name, + "N/A", (int)test_desc_header_len, TestArray[Loop].Description); else - fprintf(stream, "%16s %6d %s\n", TestArray[Loop].Name, TestArray[Loop].TestNumErrors, - TestArray[Loop].Description); + fprintf(stream, "%-*s %-6d %-*s\n", (int)test_name_header_len, TestArray[Loop].Name, + TestArray[Loop].TestNumErrors, (int)test_desc_header_len, TestArray[Loop].Description); } fprintf(stream, "\n\n"); @@ -457,7 +500,7 @@ TestSummary(FILE *stream) void TestCleanup(void) { - if (TestFrameworkMPIRank_g == 0) + if (TestFrameworkProcessID_g == 0) MESSAGE(2, ("\nCleaning Up temp files...\n\n")); for (unsigned Loop = 0; Loop < TestCount; Loop++) @@ -471,8 +514,9 @@ TestCleanup(void) void TestShutdown(void) { - for (unsigned Loop = 0; Loop < TestCount; Loop++) - free(TestArray[Loop].TestParameters); + if (TestArray) + for (unsigned Loop = 0; Loop < TestCount; Loop++) + free(TestArray[Loop].TestParameters); free(TestArray); } @@ -483,7 +527,7 @@ TestShutdown(void) H5_ATTR_PURE int GetTestVerbosity(void) { - return (TestVerbosity_g); + return TestVerbosity_g; } /* @@ -547,7 +591,7 @@ GetTestCleanup(void) void SetTestNoCleanup(void) { - TestDoCleanUp_g = 0; + TestDoCleanUp_g = false; } /* @@ -675,7 +719,7 @@ SetTest(const char *testname, int action) break; default: /* error */ - if (TestFrameworkMPIRank_g == 0) + if (TestFrameworkProcessID_g == 0) fprintf(stderr, "%s: invalid action %d specified\n", __func__, action); return FAIL; } @@ -700,12 +744,6 @@ GetTestMaxNumThreads(void) herr_t SetTestMaxNumThreads(int max_num_threads) { - if (max_num_threads < 0) { - fprintf(stderr, "%s: invalid value (%d) specified for maximum number of threads value\n", - __func__, max_num_threads); - return FAIL; - } - TestMaxNumThreads_g = max_num_threads; return SUCCEED; diff --git a/test/testframe.h b/test/testframe.h index f360d4d1491..1b3ff5e9154 100644 --- a/test/testframe.h +++ b/test/testframe.h @@ -56,6 +56,54 @@ #define ONLYTEST 2 /* Do only this test */ #define BEGINTEST 3 /* Skip all tests before this test */ +/* + * Predefined test verbosity levels. + * + * Convention: + * + * The higher the verbosity value, the more information printed. + * So, output for higher verbosity also include output of all lower + * verbosity. + */ +//! +/* + * + * Value Description + * 0 None: No informational message. + * 1 "All tests passed" + * 2 Header of overall test + * 3 Default: header and results of individual test + * 4 + * 5 Low: Major category of tests. + * 6 + * 7 Medium: Minor category of tests such as functions called. + * 8 + * 9 High: Highest level. All information. + */ +//! +#define VERBO_NONE 0 /* None */ +#define VERBO_DEF 3 /* Default */ +#define VERBO_LO 5 /* Low */ +#define VERBO_MED 7 /* Medium */ +#define VERBO_HI 9 /* High */ + +/* + * Verbose queries + * Only None needs an exact match. The rest are at least as much. + */ +#define VERBOSE_NONE (TestVerbosity_g == VERBO_NONE) +#define VERBOSE_DEF (TestVerbosity_g >= VERBO_DEF) +#define VERBOSE_LO (TestVerbosity_g >= VERBO_LO) +#define VERBOSE_MED (TestVerbosity_g >= VERBO_MED) +#define VERBOSE_HI (TestVerbosity_g >= VERBO_HI) + +/* Used to document process through a test */ +#define MESSAGE(V, A) \ + do { \ + if (TestFrameworkProcessID_g == 0 && TestVerbosity_g > (V)) \ + printf A; \ + } while (0) + /************/ /* Typedefs */ /************/ @@ -64,6 +112,9 @@ /* Variables */ /*************/ +H5TEST_DLLVAR int TestFrameworkProcessID_g; +H5TEST_DLLVAR int TestVerbosity_g; + /**************/ /* Prototypes */ /**************/ @@ -114,8 +165,7 @@ extern "C" { * program. The TestParseCmdLine() function defers to this function * when it encounters a command-line argument that is not among the * standard list of arguments it recognizes. \p TestPrivateParser - * may be NULL. TODO: may need note about how all standard options - * have to come first, unless that gets fixed. + * may be NULL. * * \p TestProcessID is an integer value that is used to distinguish * between processes when multiple are involved in running a test @@ -228,14 +278,52 @@ H5TEST_DLL void TestInfo(FILE *stream); * \p TestName is a short name given to a test that can be used to * control how a test is executed, including skipping that test if * necessary. The name specified in \p TestName must be #MAXTESTNAME - * bytes or less, including the NUL terminator. + * bytes or less, including the NUL terminator. The name specified + * in \p TestName must also not be an empty string. If \p TestName + * begins with the character '-', the test will be set to be + * skipped by default. * * \p TestFunc is a pointer to the function that will be called for - * the test. - * - * TODO: parameters - * - * \see TODO PerformTests() + * the test. The function must return no value and accept a single + * const void * as an argument, which will point to any parameters + * to be passed to the test that are specified in \p TestData. + * + * \p TestSetupFunc is an optional pointer to a function that will + * be called before the main test function is called. This allows + * tests to perform any pre-test setup necessary. The function must + * return no value and accept a single void * as an argument, which + * will point to any parameters to be passed to the test that are + * specified in \p TestData. + * + * \p TestCleanupFunc is an optional pointer to a function that + * will be called after a test's main test function has finished + * executing. This allows tests to perform any post-test cleanup + * necessary. The function must return no value and accept a single + * void * as an argument, which will point to any parameters to be + * passed to the test that are specified in \p TestData. + * + * \p TestData is an optional pointer to test parameters that will + * be passed to the test's main test function when executed, as well + * as the test's optional setup and cleanup callbacks. If given, the + * testing framework will make a copy of the parameters according to + * the size specified in \p TestDataSize. If \p TestData is not NULL, + * \p TestDataSize must be a positive value. Otherwise, if + * \p TestData is NULL, \p TestDataSize must be 0. + * + * \p TestDataSize is the size of the test parameter data to be + * passed to the test's main function and setup and callback + * functions during execution. If \p TestData is not NULL, + * \p TestDataSize must be a positive value. Otherwise, if + * \p TestData is NULL, \p TestDataSize must be 0. + * + * \p TestDescr is an informational description given to a test + * which may be printed out by the testing framework in various + * places. The string passed in \p TestDescr must be #MAXTESTDESC + * bytes or less, including the NUL terminator. The string passed + * in \p TestDescr may be an empty string, but it is advised that + * test authors give a description to a test. + * + * \see PerformTests() * */ H5TEST_DLL herr_t AddTest(const char *TestName, void (*TestFunc)(const void *), @@ -257,7 +345,10 @@ H5TEST_DLL herr_t AddTest(const char *TestName, void (*TestFunc)(const void *), * test program. If an optional argument parsing callback was * specified in the call to TestInit(), TestParseCmdLine() will * defer to that function for parsing command-line arguments that - * it doesn't recognize. + * it doesn't recognize. Note: TestParseCmdLine() requires + * that all standard command-line arguments must appear before any + * non-standard arguments that would be parsed by an optional + * argument parsing callback function specified in TestInit(). * * Note: TestParseCmdLine() should not be called until all * tests have been added by AddTest() since some of the command-line @@ -278,9 +369,16 @@ H5TEST_DLL herr_t TestParseCmdLine(int argc, char *argv[]); * * \return void * - * \details PerformTests() TODO + * \details PerformTests() runs all tests that aren't flagged to be skipped + * in the order added by calls to AddTest(). For each test, the + * test's setup callback function (if supplied) will be called + * first, followed by the test's primary function and then the + * test's cleanup callback function (if supplied). Before each test + * begins, a timer is enabled by a call to TestAlarmOn() to prevent + * the test from running longer than desired. A call to + * TestAlarmOff() disables this timer after each test has finished. * - * \see TestInit() TODO + * \see AddTest(), TestAlarmOn() * */ H5TEST_DLL void PerformTests(void); @@ -318,12 +416,7 @@ H5TEST_DLL void TestSummary(FILE *stream); * * \details TestCleanup() performs cleanup by calling the 'cleanup' callback * for each test added to the lists of tests, as long as the test - * isn't flagged to be skipped. Normally, each test's 'cleanup' - * callback is called immediately after the test finishes running, - * as long as the cleanup status isn't set to "no cleanup" by - * calling SetTestCleanup(). If desired, a test program can defer - * this cleanup by setting the "no cleanup" status and later calling - * TestCleanup() manually. + * isn't flagged to be skipped. * * \see SetTestCleanup() * @@ -336,12 +429,12 @@ H5TEST_DLL void TestCleanup(void); * * \brief Returns the current test verbosity level setting * - * \return TODO + * \return The current test verbosity level setting * * \details GetTestVerbosity() returns the current setting for the level of * test verbosity. These levels are as follows: * - * TODO + * \snippet this test_verbo_snip * * \see SetTestVerbosity() * @@ -354,12 +447,13 @@ H5TEST_DLL int GetTestVerbosity(void); * * \brief Sets the current test verbosity level setting * - * \return TODO + * \return The previous test verbosity level setting * * \details SetTestVerbosity() sets a new value for the level of test - * verbosity. These levels are as follows: + * verbosity and returns the previous value. These levels are as + * follows: * - * TODO + * \snippet this test_verbo_snip * * If \p newval is negative, the test verbosity level is set to the * lowest value (VERBO_NONE). If \p newval is greater than the @@ -491,7 +585,6 @@ H5TEST_DLL bool GetTestSummary(void); * any temporary files it has created when it is finished running. * If true is returned, the test should clean up temporary files. * Otherwise, it should leave them in place. - * TODO * * \see SetTestNoCleanup() * @@ -511,7 +604,6 @@ H5TEST_DLL bool GetTestCleanup(void); * to false, causing future calls to GetTestCleanup() to return * false and inform tests that they should not clean up temporary * test files they have created. - * TODO * * \see GetTestCleanup() * @@ -546,7 +638,6 @@ H5TEST_DLL int GetTestNumErrs(void); * * \details IncTestNumErrs() increments the number of errors recorded * for the test program. - * TODO * * \see GetTestNumErrs() * @@ -566,7 +657,6 @@ H5TEST_DLL void IncTestNumErrs(void); * to print out messages to stderr when a test failure occurs. * TestErrPrintf() increments the number of errors recorded for the * test program when called. - * TODO * */ H5TEST_DLL int TestErrPrintf(const char *format, ...) H5_ATTR_FORMAT(printf, 1, 2); @@ -622,13 +712,13 @@ H5TEST_DLL herr_t SetTest(const char *testname, int action); * and is intended for allowing tests to adjust their workload * according to the resources of the testing environment. * - * TODO: determine default and allowable values - * - * The default value is 0, which means that multi-threaded tests + * The default value is -1, which means that multi-threaded tests * aren't limited in the number of threads they can spawn, but * should still only use a reasonable amount of threads. The value - * returned by GetTestMaxNumThreads() is meaningless for - * non-multi-threaded tests. + * 0 indicates that no additional threads should be spawned, which + * is primarily for testing purposes. The value returned by + * GetTestMaxNumThreads() is meaningless for non-multi-threaded + * tests. * * \see SetTestMaxNumThreads() * @@ -651,7 +741,11 @@ H5TEST_DLL int GetTestMaxNumThreads(void); * and is intended for allowing tests to adjust their workload * according to the resources of the testing environment. * - * TODO: determine default and allowable values + * If \p max_num_threads is a negative value, test programs will be + * allowed to spawn any number of threads, though it is advised + * that test programs try to limit this to a reasonable number. + * The value 0 indicates that no additional threads should be + * spawned, which is primarily for testing purposes. * * \see SetTestMaxNumThreads() * diff --git a/test/testhdf5.h b/test/testhdf5.h index d38b0dc4591..f4f3136d8a4 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -164,24 +164,6 @@ } \ } while (0) -/* Used to document process through a test */ -#if defined(H5_HAVE_PARALLEL) && defined(H5_PARALLEL_TEST) -#define MESSAGE(V, A) \ - do { \ - int mpi_rank; \ - \ - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); \ - if (mpi_rank == 0 && HDGetTestVerbosity() > (V)) \ - print_func A; \ - } while (0) -#else /* H5_HAVE_PARALLEL */ -#define MESSAGE(V, A) \ - do { \ - if (HDGetTestVerbosity() > (V)) \ - printf A; \ - } while (0) -#endif /* H5_HAVE_PARALLEL */ - /* Used to indicate an error that is complex to check for */ #define ERROR(where) \ do { \ diff --git a/test/tfile.c b/test/tfile.c index 33599b8b7bc..f12dc6a079c 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -4885,7 +4885,11 @@ test_sects_freespace(const char *driver_name, bool new_format) CHECK(nall, FAIL, "H5Fget_free_sections"); /* Should return failure when nsects is 0 with a nonnull sect_info */ - nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, all_sect_info); + H5E_BEGIN_TRY + { + nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, all_sect_info); + } + H5E_END_TRY VERIFY(nsects, FAIL, "H5Fget_free_sections"); /* Retrieve and verify free space info for all the sections */ @@ -5108,7 +5112,11 @@ test_filespace_compatible(void) CHECK(fid, FAIL, "H5Fopen"); /* The dataset should not be there */ - did = H5Dopen2(fid, DSETNAME, H5P_DEFAULT); + H5E_BEGIN_TRY + { + did = H5Dopen2(fid, DSETNAME, H5P_DEFAULT); + } + H5E_END_TRY VERIFY(did, FAIL, "H5Dopen"); /* There should not be any free space in the file */ diff --git a/test/th5s.c b/test/th5s.c index e7094925d06..e3505f2d0fa 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -212,7 +212,11 @@ test_h5s_basic(void) fid1 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK_I(fid1, "H5Fopen"); if (fid1 >= 0) { - dset1 = H5Dopen2(fid1, "dset", H5P_DEFAULT); + H5E_BEGIN_TRY + { + dset1 = H5Dopen2(fid1, "dset", H5P_DEFAULT); + } + H5E_END_TRY; VERIFY(dset1, FAIL, "H5Dopen2"); ret = H5Fclose(fid1); CHECK_I(ret, "H5Fclose"); diff --git a/test/titerate.c b/test/titerate.c index 4abd468fd58..6128508d1b1 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -322,7 +322,12 @@ test_iter_group(hid_t fapl, bool new_format) i = 0; idx = 0; memset(info.name, 0, NAMELEN); - while ((ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) > 0) { + H5E_BEGIN_TRY + { + ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); + } + H5E_END_TRY + while (ret > 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 2, "H5Literate2"); @@ -341,7 +346,13 @@ test_iter_group(hid_t fapl, bool new_format) TestErrPrintf( "Group iteration function didn't return name correctly for link - lnames[%u] = '%s'!\n", (unsigned)(idx - 1), lnames[(size_t)(idx - 1)]); - } /* end while */ + + H5E_BEGIN_TRY + { + ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); + } + H5E_END_TRY + } VERIFY(ret, -1, "H5Literate2"); if (i != (NDATASETS + 2)) @@ -354,7 +365,12 @@ test_iter_group(hid_t fapl, bool new_format) i = 0; idx = 0; memset(info.name, 0, NAMELEN); - while ((ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) >= 0) { + H5E_BEGIN_TRY + { + ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); + } + H5E_END_TRY + while (ret >= 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 1, "H5Literate2"); @@ -373,6 +389,12 @@ test_iter_group(hid_t fapl, bool new_format) TestErrPrintf( "Group iteration function didn't return name correctly for link - lnames[%u] = '%s'!\n", (unsigned)(idx - 1), lnames[(size_t)(idx - 1)]); + + H5E_BEGIN_TRY + { + ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); + } + H5E_END_TRY } /* end while */ VERIFY(ret, -1, "H5Literate2"); diff --git a/test/tmisc.c b/test/tmisc.c index e3ce99eeea8..9c4c3764dc9 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -1196,11 +1196,19 @@ test_misc7(void) CHECK(tid, FAIL, "H5Tcreate"); /* Attempt to commit an empty compound datatype */ - ret = H5Tcommit2(fid, MISC7_TYPENAME1, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5E_BEGIN_TRY + { + ret = H5Tcommit2(fid, MISC7_TYPENAME1, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Tcommit2"); /* Attempt to use empty compound datatype to create dataset */ - did = H5Dcreate2(fid, MISC7_DSETNAME1, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5E_BEGIN_TRY + { + did = H5Dcreate2(fid, MISC7_DSETNAME1, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Dcreate2"); /* Add a field to the compound datatype */ @@ -1228,11 +1236,19 @@ test_misc7(void) CHECK(tid, FAIL, "H5Tenum_create"); /* Attempt to commit an empty enum datatype */ - ret = H5Tcommit2(fid, MISC7_TYPENAME2, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5E_BEGIN_TRY + { + ret = H5Tcommit2(fid, MISC7_TYPENAME2, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Tcommit2"); /* Attempt to use empty enum datatype to create dataset */ - did = H5Dcreate2(fid, MISC7_DSETNAME2, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5E_BEGIN_TRY + { + did = H5Dcreate2(fid, MISC7_DSETNAME2, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY VERIFY(did, FAIL, "H5Dcreate2"); /* Add a member to the enum datatype */ @@ -3821,7 +3837,11 @@ test_misc20(void) CHECK(dcpl, FAIL, "H5Pcreate"); /* Try to use chunked storage for this dataset */ - ret = H5Pset_chunk(dcpl, rank, big_dims); + H5E_BEGIN_TRY + { + ret = H5Pset_chunk(dcpl, rank, big_dims); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Pset_chunk"); /* Verify that the storage for the dataset is the correct size and hasn't diff --git a/test/trefer.c b/test/trefer.c index ba43f070a87..e2a09c0a21e 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -2254,7 +2254,11 @@ test_reference_obj_deleted(void) CHECK(ret, FAIL, "H5Dread"); /* Open deleted dataset object */ - dset2 = H5Ropen_object(&oref, H5P_DEFAULT, H5P_DEFAULT); + H5E_BEGIN_TRY + { + dset2 = H5Ropen_object(&oref, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object"); /* Close Dataset */ diff --git a/test/trefer_deprec.c b/test/trefer_deprec.c index 1a1a3dc8092..533d9f5c17d 100644 --- a/test/trefer_deprec.c +++ b/test/trefer_deprec.c @@ -166,53 +166,133 @@ test_reference_params(void) CHECK(ret, FAIL, "H5Dcreate2"); /* Test parameters to H5Rcreate */ - ret = H5Rcreate(NULL, fid1, "/Group1/Dataset1", H5R_OBJECT, (hid_t)H5I_INVALID_HID); + H5E_BEGIN_TRY + { + ret = H5Rcreate(NULL, fid1, "/Group1/Dataset1", H5R_OBJECT, (hid_t)H5I_INVALID_HID); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rcreate ref"); - ret = H5Rcreate(&wbuf[0], (hid_t)H5I_INVALID_HID, "/Group1/Dataset1", H5R_OBJECT, (hid_t)H5I_INVALID_HID); + H5E_BEGIN_TRY + { + ret = H5Rcreate(&wbuf[0], (hid_t)H5I_INVALID_HID, "/Group1/Dataset1", H5R_OBJECT, (hid_t)H5I_INVALID_HID); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rcreate loc_id"); - ret = H5Rcreate(&wbuf[0], fid1, NULL, H5R_OBJECT, (hid_t)H5I_INVALID_HID); + H5E_BEGIN_TRY + { + ret = H5Rcreate(&wbuf[0], fid1, NULL, H5R_OBJECT, (hid_t)H5I_INVALID_HID); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rcreate name"); - ret = H5Rcreate(&wbuf[0], fid1, "", H5R_OBJECT, (hid_t)H5I_INVALID_HID); + H5E_BEGIN_TRY + { + ret = H5Rcreate(&wbuf[0], fid1, "", H5R_OBJECT, (hid_t)H5I_INVALID_HID); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rcreate null name"); - ret = H5Rcreate(&wbuf[0], fid1, "/Group1/Dataset1", H5R_MAXTYPE, (hid_t)H5I_INVALID_HID); + H5E_BEGIN_TRY + { + ret = H5Rcreate(&wbuf[0], fid1, "/Group1/Dataset1", H5R_MAXTYPE, (hid_t)H5I_INVALID_HID); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rcreate type"); - ret = H5Rcreate(&wbuf[0], fid1, "/Group1/Dataset1", H5R_DATASET_REGION, (hid_t)H5I_INVALID_HID); + H5E_BEGIN_TRY + { + ret = H5Rcreate(&wbuf[0], fid1, "/Group1/Dataset1", H5R_DATASET_REGION, (hid_t)H5I_INVALID_HID); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rcreate region space"); - ret = H5Rcreate(&wbuf[0], fid1, "/Group1/Dataset1", H5R_MAXTYPE, (hid_t)0); + H5E_BEGIN_TRY + { + ret = H5Rcreate(&wbuf[0], fid1, "/Group1/Dataset1", H5R_MAXTYPE, (hid_t)0); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rcreate space"); /* Test parameters to H5Rdereference */ - dset2 = H5Rdereference2((hid_t)H5I_INVALID_HID, H5P_DEFAULT, H5R_OBJECT, &rbuf[0]); + H5E_BEGIN_TRY + { + dset2 = H5Rdereference2((hid_t)H5I_INVALID_HID, H5P_DEFAULT, H5R_OBJECT, &rbuf[0]); + } + H5E_END_TRY VERIFY(dset2, FAIL, "H5Rdereference2 loc_id"); - dset2 = H5Rdereference2(dataset, (hid_t)H5I_INVALID_HID, H5R_OBJECT, &rbuf[0]); + H5E_BEGIN_TRY + { + dset2 = H5Rdereference2(dataset, (hid_t)H5I_INVALID_HID, H5R_OBJECT, &rbuf[0]); + } + H5E_END_TRY VERIFY(dset2, FAIL, "H5Rdereference2 oapl_id"); - dset2 = H5Rdereference2(dataset, dapl_id, H5R_OBJECT, NULL); + H5E_BEGIN_TRY + { + dset2 = H5Rdereference2(dataset, dapl_id, H5R_OBJECT, NULL); + } + H5E_END_TRY VERIFY(dset2, FAIL, "H5Rdereference2 ref"); - dset2 = H5Rdereference2(dataset, dapl_id, H5R_MAXTYPE, &rbuf[0]); + H5E_BEGIN_TRY + { + dset2 = H5Rdereference2(dataset, dapl_id, H5R_MAXTYPE, &rbuf[0]); + } + H5E_END_TRY VERIFY(dset2, FAIL, "H5Rdereference2 type"); /* Test parameters to H5Rget_obj_type2 */ - ret = H5Rget_obj_type2((hid_t)H5I_INVALID_HID, H5R_OBJECT, &rbuf[0], NULL); + H5E_BEGIN_TRY + { + ret = H5Rget_obj_type2((hid_t)H5I_INVALID_HID, H5R_OBJECT, &rbuf[0], NULL); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rget_obj_type2 loc_id"); - ret = H5Rget_obj_type2(fid1, H5R_OBJECT, NULL, NULL); + H5E_BEGIN_TRY + { + ret = H5Rget_obj_type2(fid1, H5R_OBJECT, NULL, NULL); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rget_obj_type2 ref"); - ret = H5Rget_obj_type2(fid1, H5R_MAXTYPE, &rbuf[0], NULL); + H5E_BEGIN_TRY + { + ret = H5Rget_obj_type2(fid1, H5R_MAXTYPE, &rbuf[0], NULL); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Rget_obj_type2 type"); /* Test parameters to H5Rget_name */ - name_size = H5Rget_name((hid_t)H5I_INVALID_HID, H5R_DATASET_REGION, &rbuf[0], NULL, 0); + H5E_BEGIN_TRY + { + name_size = H5Rget_name((hid_t)H5I_INVALID_HID, H5R_DATASET_REGION, &rbuf[0], NULL, 0); + } + H5E_END_TRY VERIFY(name_size, FAIL, "H5Rget_name loc_id"); - name_size = H5Rget_name(fid1, H5R_DATASET_REGION, NULL, NULL, 0); + H5E_BEGIN_TRY + { + name_size = H5Rget_name(fid1, H5R_DATASET_REGION, NULL, NULL, 0); + } + H5E_END_TRY VERIFY(name_size, FAIL, "H5Rget_name ref"); - name_size = H5Rget_name(fid1, H5R_MAXTYPE, &rbuf[0], NULL, 0); + H5E_BEGIN_TRY + { + name_size = H5Rget_name(fid1, H5R_MAXTYPE, &rbuf[0], NULL, 0); + } + H5E_END_TRY VERIFY(name_size, FAIL, "H5Rget_name type"); /* Test parameters to H5Rget_region */ - ret_id = H5Rget_region((hid_t)H5I_INVALID_HID, H5R_OBJECT, &rbuf[0]); + H5E_BEGIN_TRY + { + ret_id = H5Rget_region((hid_t)H5I_INVALID_HID, H5R_OBJECT, &rbuf[0]); + } + H5E_END_TRY VERIFY(ret_id, FAIL, "H5Rget_region loc_id"); - ret_id = H5Rget_region(fid1, H5R_OBJECT, NULL); + H5E_BEGIN_TRY + { + ret_id = H5Rget_region(fid1, H5R_OBJECT, NULL); + } + H5E_END_TRY VERIFY(ret_id, FAIL, "H5Rget_region ref"); - ret_id = H5Rget_region(fid1, H5R_OBJECT, &rbuf[0]); + H5E_BEGIN_TRY + { + ret_id = H5Rget_region(fid1, H5R_OBJECT, &rbuf[0]); + } + H5E_END_TRY VERIFY(ret_id, FAIL, "H5Rget_region type"); /* Close disk dataspace */ @@ -773,7 +853,11 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) /* Try to read an unaddressed dataset */ memset(&undef_reg, 0, sizeof(undef_reg)); - dset2 = H5Rdereference2(dset1, dapl_id, H5R_DATASET_REGION, undef_reg); + H5E_BEGIN_TRY + { + dset2 = H5Rdereference2(dset1, dapl_id, H5R_DATASET_REGION, undef_reg); + } + H5E_END_TRY VERIFY(dset2, FAIL, "H5Rdereference2 haddr_undef"); /* Try to open objects */ @@ -1314,7 +1398,11 @@ test_reference_obj_deleted(void) CHECK(ret, FAIL, "H5Dopen2"); /* Open undefined reference */ - dset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &addr); + H5E_BEGIN_TRY + { + dset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &addr); + } + H5E_END_TRY VERIFY(dset2, FAIL, "H5Rdereference2"); /* Read selection from disk */ @@ -1323,12 +1411,20 @@ test_reference_obj_deleted(void) CHECK(ret, FAIL, "H5Dread"); /* Open deleted dataset object */ - dset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &oref); + H5E_BEGIN_TRY + { + dset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &oref); + } + H5E_END_TRY VERIFY(dset2, FAIL, "H5Rdereference2"); /* Open nonsense reference */ memset(&oref, 0, sizeof(hobj_ref_t)); - dset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &oref); + H5E_BEGIN_TRY + { + dset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &oref); + } + H5E_END_TRY VERIFY(dset2, FAIL, "H5Rdereference2"); /* Close Dataset */ @@ -1771,10 +1867,18 @@ test_reference_compat(void) CHECK(obj_type, H5G_UNKNOWN, "H5Rget_obj_type1"); VERIFY(obj_type, H5G_DATASET, "H5Rget_obj_type1"); - obj_type = H5Rget_obj_type1(dataset, H5R_DATASET_REGION, &rbuf_reg[2]); + H5E_BEGIN_TRY + { + obj_type = H5Rget_obj_type1(dataset, H5R_DATASET_REGION, &rbuf_reg[2]); + } + H5E_END_TRY VERIFY(obj_type, H5G_UNKNOWN, "H5Rget_obj_type1"); - obj_type = H5Rget_obj_type1(dataset, H5R_DATASET_REGION, &rbuf_reg[3]); + H5E_BEGIN_TRY + { + obj_type = H5Rget_obj_type1(dataset, H5R_DATASET_REGION, &rbuf_reg[3]); + } + H5E_END_TRY VERIFY(obj_type, H5G_UNKNOWN, "H5Rget_obj_type1"); /* Make sure the referenced objects can be opened */ diff --git a/testpar/t_2Gio.c b/testpar/t_2Gio.c index 215e00a7757..fad80b45a2c 100644 --- a/testpar/t_2Gio.c +++ b/testpar/t_2Gio.c @@ -1266,6 +1266,22 @@ dataset_writeAll(const void *params) /* 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) { + hsize_t k = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t i = 0; i < num_points; i++) { + printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); + k += MAX_RANK; + } + } + file_dataspace = H5Dget_space(dataset5); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); @@ -1302,6 +1318,22 @@ dataset_writeAll(const void *params) start[0] = (hsize_t)dim0 / (hsize_t)mpi_size * (hsize_t)mpi_rank; start[1] = 0; point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + if (VERBOSE_MED) { + hsize_t k = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t i = 0; i < num_points; i++) { + printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); + k += MAX_RANK; + } + } + file_dataspace = H5Dget_space(dataset6); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); @@ -1310,6 +1342,22 @@ dataset_writeAll(const void *params) start[0] = 0; start[1] = 0; point_set(start, count, stride, block, num_points, coords, IN_ORDER); + if (VERBOSE_MED) { + hsize_t k = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t i = 0; i < num_points; i++) { + printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); + k += MAX_RANK; + } + } + mem_dataspace = H5Dget_space(dataset6); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); @@ -1339,6 +1387,22 @@ dataset_writeAll(const void *params) start[0] = (hsize_t)dim0 / (hsize_t)mpi_size * (hsize_t)mpi_rank; start[1] = 0; point_set(start, count, stride, block, num_points, coords, IN_ORDER); + if (VERBOSE_MED) { + hsize_t k = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t i = 0; i < num_points; i++) { + printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); + k += MAX_RANK; + } + } + file_dataspace = H5Dget_space(dataset7); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); @@ -1658,6 +1722,22 @@ dataset_readAll(const void *params) start[0] = 0; start[1] = 0; point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + if (VERBOSE_MED) { + hsize_t idx = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t point = 0; point < num_points; point++) { + printf("(%d, %d)\n", (int)coords[idx], (int)coords[idx + 1]); + idx += MAX_RANK; + } + } + mem_dataspace = H5Dget_space(dataset5); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); @@ -1696,6 +1776,22 @@ dataset_readAll(const void *params) start[0] = (hsize_t)dim0 / (hsize_t)mpi_size * (hsize_t)mpi_rank; start[1] = 0; point_set(start, count, stride, block, num_points, coords, IN_ORDER); + if (VERBOSE_MED) { + hsize_t idx = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t point = 0; point < num_points; point++) { + printf("(%d, %d)\n", (int)coords[idx], (int)coords[idx + 1]); + idx += MAX_RANK; + } + } + file_dataspace = H5Dget_space(dataset6); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); @@ -1704,6 +1800,22 @@ dataset_readAll(const void *params) start[0] = 0; start[1] = 0; point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + if (VERBOSE_MED) { + hsize_t idx = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t point = 0; point < num_points; point++) { + printf("(%d, %d)\n", (int)coords[idx], (int)coords[idx + 1]); + idx += MAX_RANK; + } + } + mem_dataspace = H5Dget_space(dataset6); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); diff --git a/testpar/t_coll_chunk.c b/testpar/t_coll_chunk.c index a02886c7e37..eeaced0a067 100644 --- a/testpar/t_coll_chunk.c +++ b/testpar/t_coll_chunk.c @@ -739,6 +739,22 @@ coll_chunktest(const char *filename, int chunk_factor, int select_factor, int ap VRFY((coords != NULL), "coords malloc succeeded"); point_set(start, count, stride, block, num_points, coords, mode); + if (VERBOSE_MED) { + hsize_t k = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t i = 0; i < num_points; i++) { + printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); + k += RANK; + } + } + file_dataspace = H5Screate_simple(2, dims, NULL); VRFY((file_dataspace >= 0), "file dataspace created succeeded"); diff --git a/testpar/t_dset.c b/testpar/t_dset.c index ea9898fa995..c2a2cab9e04 100644 --- a/testpar/t_dset.c +++ b/testpar/t_dset.c @@ -901,6 +901,22 @@ dataset_writeAll(const void *params) /* 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) { + hsize_t k = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t i = 0; i < num_points; i++) { + printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); + k += RANK; + } + } + file_dataspace = H5Dget_space(dataset5); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); @@ -937,6 +953,22 @@ dataset_writeAll(const void *params) start[0] = (hsize_t)(dim0 / mpi_size * mpi_rank); start[1] = 0; point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + if (VERBOSE_MED) { + hsize_t k = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t i = 0; i < num_points; i++) { + printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); + k += RANK; + } + } + file_dataspace = H5Dget_space(dataset6); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); @@ -945,6 +977,22 @@ dataset_writeAll(const void *params) start[0] = 0; start[1] = 0; point_set(start, count, stride, block, num_points, coords, IN_ORDER); + if (VERBOSE_MED) { + hsize_t k = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t i = 0; i < num_points; i++) { + printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); + k += RANK; + } + } + mem_dataspace = H5Dget_space(dataset6); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); @@ -974,6 +1022,22 @@ dataset_writeAll(const void *params) start[0] = (hsize_t)(dim0 / mpi_size * mpi_rank); start[1] = 0; point_set(start, count, stride, block, num_points, coords, IN_ORDER); + if (VERBOSE_MED) { + hsize_t k = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t i = 0; i < num_points; i++) { + printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); + k += RANK; + } + } + file_dataspace = H5Dget_space(dataset7); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); @@ -1306,6 +1370,22 @@ dataset_readAll(const void *params) start[0] = 0; start[1] = 0; point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + if (VERBOSE_MED) { + hsize_t idx = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t point = 0; point < num_points; point++) { + printf("(%d, %d)\n", (int)coords[idx], (int)coords[idx + 1]); + idx += RANK; + } + } + mem_dataspace = H5Dget_space(dataset5); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); @@ -1344,6 +1424,22 @@ dataset_readAll(const void *params) start[0] = (hsize_t)(dim0 / mpi_size * mpi_rank); start[1] = 0; point_set(start, count, stride, block, num_points, coords, IN_ORDER); + if (VERBOSE_MED) { + hsize_t idx = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t point = 0; point < num_points; point++) { + printf("(%d, %d)\n", (int)coords[idx], (int)coords[idx + 1]); + idx += RANK; + } + } + file_dataspace = H5Dget_space(dataset6); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); @@ -1352,6 +1448,22 @@ dataset_readAll(const void *params) start[0] = 0; start[1] = 0; point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + if (VERBOSE_MED) { + hsize_t idx = 0; + + printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); + + for (size_t point = 0; point < num_points; point++) { + printf("(%d, %d)\n", (int)coords[idx], (int)coords[idx + 1]); + idx += RANK; + } + } + mem_dataspace = H5Dget_space(dataset6); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); diff --git a/testpar/testpar.c b/testpar/testpar.c index b3c22f0163b..c674f61c5c2 100644 --- a/testpar/testpar.c +++ b/testpar/testpar.c @@ -104,18 +104,4 @@ point_set(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], s coords[k++] = s1 + stride[0] * i + m; coords[k++] = s2 + stride[1] * j + n; } - - if (VERBOSE_MED) { - printf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " - "datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], - (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], - (unsigned long)block[0], (unsigned long)block[1], - (unsigned long)(block[0] * block[1] * count[0] * count[1])); - k = 0; - for (i = 0; i < num_points; i++) { - printf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); - k += 2; - } - } } diff --git a/testpar/testpar.h b/testpar/testpar.h index 8438bbec5f0..71ff72a5f13 100644 --- a/testpar/testpar.h +++ b/testpar/testpar.h @@ -20,6 +20,11 @@ #include "h5test.h" +/* For now, include testing framework functionality since the MESG, VRFY, + * etc. macros depend on the test verbosity level + */ +#include "testframe.h" + /* File_Access_type bits */ #define FACC_DEFAULT 0x0 /* default */ #define FACC_MPIO 0x1 /* MPIO */