From 61350bf3504272dcf6e264b02812283d2d993218 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Thu, 13 Dec 2018 22:11:29 -0600 Subject: Re-format test/ohdr_mindset.c Fix a few transcription errors in other test files. --- test/dsets.c | 2 +- test/ohdr_mindset.c | 1410 +++++++++++++-------------------------------------- test/tfile.c | 8 +- 3 files changed, 360 insertions(+), 1060 deletions(-) diff --git a/test/dsets.c b/test/dsets.c index 0b6d0ad..395a98a 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -826,7 +826,7 @@ test_compact_io(hid_t fapl) **************************************/ /* Create a copy of file access property list */ - if((new_fapl = new_fapl = h5_fileaccess()) < 0) TEST_ERROR + if((new_fapl = h5_fileaccess()) < 0) TEST_ERROR /* Loop through all the combinations of low/high library format bounds, skipping invalid combinations. diff --git a/test/ohdr_mindset.c b/test/ohdr_mindset.c index 7ec58e2..5d4b659 100644 --- a/test/ohdr_mindset.c +++ b/test/ohdr_mindset.c @@ -11,340 +11,6 @@ #define DEBUG_OH_SIZE 0 /* toggle some debug printing (0 off, 1 on)*/ -#ifndef JSMITH_TESTING - -/***************************************************************************** - * - * FILE-LOCAL TESTING MACROS - * - * Purpose: - * - * 1) Upon test failure, goto-jump to single-location teardown in test - * function. E.g., `error:` (consistency with HDF corpus) or - * `failed:` (reflects purpose). - * >>> using "error", in part because `H5E_BEGIN_TRY` expects it. - * 2) Increase clarity and reduce overhead found with `TEST_ERROR`. - * e.g., "if(somefunction(arg, arg2) < 0) TEST_ERROR:" - * requires reading of entire line to know whether this if/call is - * part of the test setup, test operation, or a test unto itself. - * 3) Provide testing macros with optional user-supplied failure message; - * if not supplied (NULL), generate comparison output in the spirit of - * test-driven development. E.g., "expected 5 but was -3" - * User messages clarify test's purpose in code, encouraging description - * without relying on comments. - * 4) Configurable expected-actual order in generated comparison strings. - * Some prefer `VERIFY(expected, actual)`, others - * `VERIFY(actual, expected)`. Provide preprocessor ifdef switch - * to satifsy both parties, assuming one paradigm per test file. - * (One could #undef and redefine the flag through the file as desired, - * but _why_.) - * - * Provided as courtesy, per consideration for inclusion in the library - * proper. - * - * Macros: - * - * JSVERIFY_EXP_ACT - ifdef flag, configures comparison order - * FAIL_IF() - check condition - * FAIL_UNLESS() - check _not_ condition - * JSVERIFY() - long-int equality check; prints reason/comparison - * JSVERIFY_NOT() - long-int inequality check; prints - * JSVERIFY_STR() - string equality check; prints - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *****************************************************************************/ - - -/*---------------------------------------------------------------------------- - * - * ifdef flag: JSVERIFY_EXP_ACT - * - * JSVERIFY macros accept arguments as (EXPECTED, ACTUAL[, reason]) - * default, if this is undefined, is (ACTUAL, EXPECTED[, reason]) - * - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_EXP_ACT 1L - - -/*---------------------------------------------------------------------------- - * - * Macro: JSFAILED_AT() - * - * Purpose: - * - * Preface a test failure by printing "*FAILED*" and location to stdout - * Similar to `H5_FAILED(); AT();` from h5test.h - * - * *FAILED* at somefile.c:12 in function_name()... - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSFAILED_AT() { \ - HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ -} - - -/*---------------------------------------------------------------------------- - * - * Macro: FAIL_IF() - * - * Purpose: - * - * Make tests more accessible and less cluttered than - * `if (thing == otherthing()) TEST_ERROR` - * paradigm. - * - * The following lines are roughly equivalent: - * - * `if (myfunc() < 0) TEST_ERROR;` (as seen elsewhere in HDF tests) - * `FAIL_IF(myfunc() < 0)` - * - * Prints a generic "FAILED AT" line to stdout and jumps to `error`, - * similar to `TEST_ERROR` in h5test.h - * - * Programmer: Jacob Smith - * 2017-10-23 - * - *---------------------------------------------------------------------------- - */ -#define FAIL_IF(condition) \ -if (condition) { \ - JSFAILED_AT() \ - goto error; \ -} - - -/*---------------------------------------------------------------------------- - * - * Macro: FAIL_UNLESS() - * - * Purpose: - * - * TEST_ERROR wrapper to reduce cognitive overhead from "negative tests", - * e.g., "a != b". - * - * Opposite of FAIL_IF; fails if the given condition is _not_ true. - * - * `FAIL_IF( 5 != my_op() )` - * is equivalent to - * `FAIL_UNLESS( 5 == my_op() )` - * However, `JSVERIFY(5, my_op(), "bad return")` may be even clearer. - * (see JSVERIFY) - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#if 0 /* UNUSED */ -#define FAIL_UNLESS(condition) \ -if (!(condition)) { \ - JSFAILED_AT() \ - goto error; \ -} -#endif /* UNUSED */ - - -/*---------------------------------------------------------------------------- - * - * Macro: JSERR_LONG() - * - * Purpose: - * - * Print an failure message for long-int arguments. - * ERROR-AT printed first. - * If `reason` is given, it is printed on own line and newlined after - * else, prints "expected/actual" aligned on own lines. - * - * *FAILED* at myfile.c:488 in somefunc()... - * forest must be made of trees. - * - * or - * - * *FAILED* at myfile.c:488 in somefunc()... - * ! Expected 425 - * ! Actual 3 - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSERR_LONG(expected, actual, reason) { \ - JSFAILED_AT() \ - if (reason!= NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ - (long)(expected), (long)(actual)); \ - } \ -} - - -/*---------------------------------------------------------------------------- - * - * Macro: JSERR_STR() - * - * Purpose: - * - * Print an failure message for string arguments. - * ERROR-AT printed first. - * If `reason` is given, it is printed on own line and newlined after - * else, prints "expected/actual" aligned on own lines. - * - * *FAILED* at myfile.c:421 in myfunc()... - * Blue and Red strings don't match! - * - * or - * - * *FAILED* at myfile.c:421 in myfunc()... - * !!! Expected: - * this is my expected - * string - * !!! Actual: - * not what I expected at all - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSERR_STR(expected, actual, reason) { \ - JSFAILED_AT() \ - if ((reason) != NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ - (expected), (actual)); \ - } \ -} - -#ifdef JSVERIFY_EXP_ACT - - -/*---------------------------------------------------------------------------- - * - * Macro: JSVERIFY() - * - * Purpose: - * - * Verify that two long integers are equal. - * If unequal, print failure message - * (with `reason`, if not NULL; expected/actual if NULL) - * and jump to `error` at end of function - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSVERIFY(expected, actual, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY */ - - -/*---------------------------------------------------------------------------- - * - * Macro: JSVERIFY_NOT() - * - * Purpose: - * - * Verify that two long integers are _not_ equal. - * If equal, print failure message - * (with `reason`, if not NULL; expected/actual if NULL) - * and jump to `error` at end of function - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_NOT(expected, actual, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ - - -/*---------------------------------------------------------------------------- - * - * Macro: JSVERIFY_STR() - * - * Purpose: - * - * Verify that two strings are equal. - * If unequal, print failure message - * (with `reason`, if not NULL; expected/actual if NULL) - * and jump to `error` at end of function - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_STR(expected, actual, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ - -#else /* JSVERIFY_EXP_ACT */ - /* Repeats macros above, but with actual/expected parameters reversed. */ - - -/*---------------------------------------------------------------------------- - * Macro: JSVERIFY() - * See: JSVERIFY documentation above. - * Programmer: Jacob Smith - * 2017-10-14 - *---------------------------------------------------------------------------- - */ -#define JSVERIFY(actual, expected, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY */ - - -/*---------------------------------------------------------------------------- - * Macro: JSVERIFY_NOT() - * See: JSVERIFY_NOT documentation above. - * Programmer: Jacob Smith - * 2017-10-14 - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_NOT(actual, expected, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ - - -/*---------------------------------------------------------------------------- - * Macro: JSVERIFY_STR() - * See: JSVERIFY_STR documentation above. - * Programmer: Jacob Smith - * 2017-10-14 - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_STR(actual, expected, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ - -#endif /* JSVERIFY_EXP_ACT */ - -#endif /* JSMITH_TESTING */ - /* basenames of test files created in this test suite */ #define OHMIN_FILENAME_A "ohdr_min_a" #define OHMIN_FILENAME_B "ohdr_min_b" @@ -354,51 +20,6 @@ if (strcmp((actual), (expected)) != 0) { \ #define LT 2 #define GT 3 -/* pseudo-enumeration of symbols to select H5*close() function in macro */ -#define CLOSE_ATTRIBUTE 1 -#define CLOSE_DATASET 2 -#define CLOSE_DATASPACE 3 -#define CLOSE_DATATYPE 4 -#define CLOSE_FILE 5 -#define CLOSE_PLIST 6 - - -/* --------------------------------------------------------------------------- - * Macro: MUST_CLOSE(...) - * - * Trigger an error if calling close on the id fails (e.g., H5Fclose(fid). - * Uses #defined values to indicate expected id kind (plist vs file, &c.). - * Prints message on error. - * Please use only at "top level" of test function (because JSVERIFY). - * --------------------------------------------------------------------------- - */ -#define MUST_CLOSE(id, kind) \ -{ switch (kind) { \ - case CLOSE_ATTRIBUTE : \ - JSVERIFY(SUCCEED, H5Aclose((id)), "closing attribute") \ - break; \ - case CLOSE_DATASET : \ - JSVERIFY(SUCCEED, H5Dclose((id)), "closing dataset") \ - break; \ - case CLOSE_DATASPACE : \ - JSVERIFY(SUCCEED, H5Sclose((id)), "closing dataspace") \ - break; \ - case CLOSE_DATATYPE : \ - JSVERIFY(SUCCEED, H5Tclose((id)), "closing datatype") \ - break; \ - case CLOSE_FILE : \ - JSVERIFY(SUCCEED, H5Fclose((id)), "closing file") \ - break; \ - case CLOSE_PLIST : \ - JSVERIFY(SUCCEED, H5Pclose((id)), "closing plist") \ - break; \ - default: \ - JSVERIFY(0, 1, "Unidentified MUST_CLOSE constant") \ - break; \ - } \ - (id) = -1; \ -} - /* --------------------------------------------------------------------------- * Macro: PRINT_DSET_OH_COMPARISON(...) @@ -407,66 +28,31 @@ if (strcmp((actual), (expected)) != 0) { \ * Please use only at "top level" of test function. * --------------------------------------------------------------------------- */ -#define PRINT_DSET_OH_COMPARISON(did1, did2) \ -{ H5O_info_t info1; \ - H5O_info_t info2; \ - \ - FAIL_IF( SUCCEED != H5Oget_info2((did1), &info1, H5O_INFO_HDR) ) \ - FAIL_IF( SUCCEED != H5Oget_info2((did2), &info2, H5O_INFO_HDR) ) \ - \ - HDprintf("\n==HEADERS== UNMINIMIZED MINIMIZED\n"); \ - HDprintf(" version: %11u %9u\n", \ - info1.hdr.version, \ - info2.hdr.version); \ - HDprintf(" # messages: %11u %9u\n", \ - info1.hdr.nmesgs, \ - info2.hdr.nmesgs); \ - HDprintf(" meta: %11llu %9llu\n", \ - info1.hdr.space.meta, \ - info2.hdr.space.meta); \ - HDprintf(" free: %11llu %9llu\n", \ - info1.hdr.space.free, \ - info2.hdr.space.free); \ - HDprintf(" total: %11llu %9llu\n", \ - info1.hdr.space.total, \ - info2.hdr.space.total); \ +#define PRINT_DSET_OH_COMPARISON(did1, did2) \ +{ H5O_info_t info1; \ + H5O_info_t info2; \ + \ + if(H5Oget_info2((did1), &info1, H5O_INFO_HDR) < 0) TEST_ERROR \ + if(H5Oget_info2((did2), &info2, H5O_INFO_HDR) < 0) TEST_ERROR \ + \ + HDprintf("\n==HEADERS== UNMINIMIZED MINIMIZED\n"); \ + HDprintf(" version: %11u %9u\n", \ + info1.hdr.version, \ + info2.hdr.version); \ + HDprintf(" # messages: %11u %9u\n", \ + info1.hdr.nmesgs, \ + info2.hdr.nmesgs); \ + HDprintf(" meta: %11llu %9llu\n", \ + info1.hdr.space.meta, \ + info2.hdr.space.meta); \ + HDprintf(" free: %11llu %9llu\n", \ + info1.hdr.space.free, \ + info2.hdr.space.free); \ + HDprintf(" total: %11llu %9llu\n", \ + info1.hdr.space.total, \ + info2.hdr.space.total); \ } - -/* --------------------------------------------------------------------------- - * Macro: CREATE_FILE(...) - * - * Wrapper to create an hdf5 file, and report an error. - * Call only at test function "top level", because of JSVERIFY. - * --------------------------------------------------------------------------- - */ -#define CREATE_FILE(name, id_out) \ -{ char errmsg[128] = ""; \ - snprintf(errmsg, 128, "unable to create file '%s'", (name)); \ - JSVERIFY( SUCCEED, _create_file((name), id_out), errmsg) \ -} - - -/* --------------------------------------------------------------------------- - * Macro: CREATE_DATASET(...) - * + file id - * + dataset name - * + datatype id - * + dataspace id - * + dcpl id - * + pointer to dataset id (store H5Dcreate result ) - * - * Wrapper to create a dataset, and report an error. - * Call only at test function "top level", because of JSVERIFY. - * --------------------------------------------------------------------------- - */ -#define CREATE_DATASET(Fid, name, Tid, Sid, dcpl, Did_out) \ -{ char errmsg[32] = ""; \ - snprintf(errmsg, 32, "unable to create dataset '%s'", (name)); \ - JSVERIFY( SUCCEED, \ - _make_dataset((Fid), (name), (Tid), (Sid), (dcpl), (Did_out)), \ - errmsg) \ -} /********************* * UTILITY FUNCTIONS * @@ -474,70 +60,6 @@ if (strcmp((actual), (expected)) != 0) { \ /* --------------------------------------------------------------------------- - * Function: _create_file() - * - * Purpose: Create a file with the name, and record its ID in out parameter. - * - * Return: 0 (success) or -1 (failure) - * - * --------------------------------------------------------------------------- - */ -static herr_t -_create_file( \ - const char *filename, \ - hid_t *fid) -{ - hid_t id = -1; - id = H5Fcreate( - filename, - H5F_ACC_TRUNC, - H5P_DEFAULT, - H5P_DEFAULT); - if (id < 0) - return FAIL; - *fid = id; - - return SUCCEED; -} /* _create_file */ - - -/* --------------------------------------------------------------------------- - * Function: _make_dataset() - * - * Purpose: Create a dataset and record its ID in out parameter `dset_id`. - * - * Return: 0 (success) or -1 (failure) - * - * --------------------------------------------------------------------------- - */ -static herr_t -_make_dataset( \ - hid_t loc_id, \ - const char *name, \ - hid_t datatype_id, \ - hid_t dataspace_id, \ - hid_t dcpl_id, \ - hid_t *dset_id) -{ - hid_t id = -1; - - id = H5Dcreate( - loc_id, - name, - datatype_id, - dataspace_id, - H5P_DEFAULT, /* LCPL id */ - dcpl_id, - H5P_DEFAULT); /* DAPL id */ - if (id < 0) - return FAIL; - *dset_id = id; - - return SUCCEED; -} /* _make_dataset */ - - -/* --------------------------------------------------------------------------- * Function: put_attribute() * * Purpose: Set an attribute with the given information. @@ -546,28 +68,18 @@ _make_dataset( \ * created with the given information. Else, it will attempt to update the * attribute with the new value. * + * `dataspace_id` ignored if `attribute_id` >= 0 + * * Return: 0 (success) or -1 (failure) * * --------------------------------------------------------------------------- */ static herr_t -put_attribute( \ - hid_t loc_id, \ - const char *attrname, \ - const void *attrvalue, \ - hid_t datatype_id, \ - hid_t dataspace_id, /* ignored if attribute_id >= 0 */ \ - hid_t *attribute_id) +put_attribute(hid_t loc_id, const char *attrname, const void *attrvalue, hid_t datatype_id, hid_t dataspace_id, hid_t *attribute_id) { if ((*attribute_id) < 0) { hid_t id = -1; - id = H5Acreate( - loc_id, - attrname, - datatype_id, - dataspace_id, - H5P_DEFAULT, /* acpl */ - H5P_DEFAULT); /* aapl */ + id = H5Acreate(loc_id, attrname, datatype_id, dataspace_id, H5P_DEFAULT, H5P_DEFAULT); if (id < 0) return FAIL; *attribute_id = id; @@ -633,9 +145,7 @@ _oh_getsize(hid_t did, hsize_t *size_out) * --------------------------------------------------------------------------- */ static int -oh_compare( \ - hid_t did1, \ - hid_t did2) +oh_compare(hid_t did1, hid_t did2) { hsize_t space1 = 0; hsize_t space2 = 0; @@ -688,6 +198,8 @@ test_attribute_addition(void) hid_t attr_3_id = -1; hid_t attr_3a_id = -1; hid_t file_id = -1; + herr_t ret; + int count = 0; TESTING("attribute additions to [un]minimized dataset") @@ -695,56 +207,43 @@ test_attribute_addition(void) * SETUP * *********/ - FAIL_IF( NULL == h5_fixname( - OHMIN_FILENAME_A, - H5P_DEFAULT, - filename, - sizeof(filename)) ) + if(h5_fixname(OHMIN_FILENAME_A, H5P_DEFAULT, filename, sizeof(filename)) == NULL) + TEST_ERROR dspace_id = H5Screate_simple( 1, /* rank */ array_10, /* current dimensions */ NULL); /* maximum dimensions */ - FAIL_IF( 0 > dspace_id ) + if(dspace_id < 0) TEST_ERROR dspace_scalar_id = H5Screate(H5S_SCALAR); - FAIL_IF( 0 > dspace_scalar_id ) + if(dspace_scalar_id < 0) TEST_ERROR char_type_id = H5Tcopy(H5T_NATIVE_CHAR); - FAIL_IF( 0 > char_type_id ) + if(char_type_id < 0) TEST_ERROR int_type_id = H5Tcopy(H5T_NATIVE_INT); - FAIL_IF( 0 > int_type_id ) + if(int_type_id < 0) TEST_ERROR dcpl_id = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_id ) - JSVERIFY( SUCCEED, \ - H5Pset_dset_no_attrs_hint(dcpl_id, TRUE), \ - "can't set DCPL to minimize object header") + if(dcpl_id < 0) TEST_ERROR + + ret = H5Pset_dset_no_attrs_hint(dcpl_id, TRUE); + if(ret < 0) TEST_ERROR - CREATE_FILE(filename, &file_id) + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if(file_id < 0) TEST_ERROR H5E_BEGIN_TRY { - JSVERIFY( -1, \ - count_attributes(dset_id), \ - "shouldn't be able to count missing dataset") + count = count_attributes(dset_id); } H5E_END_TRY; + if(count != -1) TEST_ERROR - CREATE_DATASET( \ - file_id, /* shorthand for root group? */ \ - "dataset", \ - int_type_id, \ - dspace_id, \ - H5P_DEFAULT, /* default DCPL */ \ - &dset_id) - - CREATE_DATASET( \ - file_id, \ - "mindataset", \ - int_type_id, \ - dspace_id, \ - dcpl_id, \ - &mindset_id) + dset_id = H5Dcreate(file_id, "dataset", int_type_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_id < 0) TEST_ERROR + + mindset_id = H5Dcreate(file_id, "mindataset", int_type_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if(mindset_id < 0) TEST_ERROR /******************** * TEST/DEMONSTRATE * @@ -754,12 +253,10 @@ test_attribute_addition(void) * no attributes added */ - JSVERIFY( 0, \ - count_attributes(dset_id), \ - NULL) - JSVERIFY( 0, \ - count_attributes(mindset_id), \ - NULL) + count = count_attributes(dset_id); + if(count != 0) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 0) TEST_ERROR if (DEBUG_OH_SIZE) PRINT_DSET_OH_COMPARISON(dset_id, mindset_id) @@ -767,41 +264,24 @@ test_attribute_addition(void) /* ----------------- * add one attribute */ + ret = put_attribute(dset_id, "PURPOSE", "DEMO", char_type_id, dspace_id, &attr_1_id); + if(ret < 0) TEST_ERROR + + ret = put_attribute(mindset_id, "PURPOSE", "DEMO", char_type_id, dspace_id, &attr_1a_id); + if(ret < 0) TEST_ERROR - JSVERIFY( SUCCEED, \ - put_attribute( \ - dset_id, \ - "PURPOSE", \ - "DEMO", \ - char_type_id, \ - dspace_id, \ - &attr_1_id), \ - "unable to set attribute 'PURPOSE:DEMO'") - JSVERIFY( SUCCEED, \ - put_attribute( \ - mindset_id, \ - "PURPOSE", \ - "DEMO", \ - char_type_id, \ - dspace_id, \ - &attr_1a_id), \ - "unable to set attribute 'PURPOSE:DEMO'") - - JSVERIFY( 1, \ - count_attributes(dset_id), \ - NULL) - JSVERIFY( 1, \ - count_attributes(mindset_id), \ - NULL) - - JSVERIFY( SUCCEED, - H5Aread(attr_1_id, char_type_id, buffer), - "can't read attribute 'PURPOSE'") - JSVERIFY_STR( "DEMO", buffer, NULL ) - JSVERIFY( SUCCEED, - H5Aread(attr_1a_id, char_type_id, buffer), - "can't read attribute 'PURPOSE'") - JSVERIFY_STR( "DEMO", buffer, NULL ) + count = count_attributes(dset_id); + if(count != 1) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 1) TEST_ERROR + + ret = H5Aread(attr_1_id, char_type_id, buffer); + if(ret < 0) TEST_ERROR + if(HDstrcmp("DEMO", buffer)) TEST_ERROR + + ret = H5Aread(attr_1a_id, char_type_id, buffer); + if(ret < 0) TEST_ERROR + if(HDstrcmp("DEMO", buffer)) TEST_ERROR if (DEBUG_OH_SIZE) PRINT_DSET_OH_COMPARISON(dset_id, mindset_id) @@ -810,40 +290,24 @@ test_attribute_addition(void) * modify one attribute */ - JSVERIFY( SUCCEED, \ - put_attribute( \ - dset_id, \ - "PURPOSE", \ - "REWRITE", \ - char_type_id, \ - -1, \ - &attr_1_id), \ - "unable to rewrite attribute 'PURPOSE:REWRITE'") - JSVERIFY( SUCCEED, \ - put_attribute( \ - mindset_id, \ - "PURPOSE", \ - "REWRITE", \ - char_type_id, \ - -1, \ - &attr_1a_id), \ - "unable to rewrite attribute 'PURPOSE:REWRITE'") - - JSVERIFY( 1, \ - count_attributes(dset_id), \ - NULL) - JSVERIFY( 1, \ - count_attributes(mindset_id), \ - NULL) - - JSVERIFY( SUCCEED, - H5Aread(attr_1_id, char_type_id, buffer), - "can't read attribute 'PURPOSE'") - JSVERIFY_STR( "REWRITE", buffer, NULL ) - JSVERIFY( SUCCEED, - H5Aread(attr_1a_id, char_type_id, buffer), - "can't read attribute 'PURPOSE'") - JSVERIFY_STR( "REWRITE", buffer, NULL ) + ret = put_attribute(dset_id, "PURPOSE", "REWRITE", char_type_id, -1, &attr_1_id); + if(ret < 0) TEST_ERROR + + ret = put_attribute(mindset_id, "PURPOSE", "REWRITE", char_type_id, -1, &attr_1a_id); + if(ret < 0) TEST_ERROR + + count = count_attributes(dset_id); + if(count != 1) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 1) TEST_ERROR + + ret = H5Aread(attr_1_id, char_type_id, buffer); + if(ret < 0) TEST_ERROR + if(HDstrcmp("REWRITE", buffer)) TEST_ERROR + + ret = H5Aread(attr_1a_id, char_type_id, buffer); + if(ret < 0) TEST_ERROR + if(HDstrcmp("REWRITE", buffer)) TEST_ERROR if (DEBUG_OH_SIZE) PRINT_DSET_OH_COMPARISON(dset_id, mindset_id) @@ -853,41 +317,25 @@ test_attribute_addition(void) */ a_out = 5; - JSVERIFY( SUCCEED, \ - put_attribute( \ - dset_id, \ - "RANK", \ - &a_out, \ - int_type_id, \ - dspace_scalar_id, \ - &attr_2_id), \ - "unable to set attribute 'RANK:5'") + ret = put_attribute(dset_id, "RANK", &a_out, int_type_id, dspace_scalar_id, &attr_2_id); + if(ret < 0) TEST_ERROR + a_out = 3; - JSVERIFY( SUCCEED, \ - put_attribute( \ - mindset_id, \ - "RANK", \ - &a_out, \ - int_type_id, \ - dspace_scalar_id, \ - &attr_2a_id), \ - "unable to set attribute (minimized) 'RANK:3'") - - JSVERIFY( 2, \ - count_attributes(dset_id), \ - NULL) - JSVERIFY( 2, \ - count_attributes(mindset_id), \ - NULL) - - JSVERIFY( SUCCEED, - H5Aread(attr_2_id, int_type_id, &a_out), - "can't read attribute 'RANK'") - JSVERIFY( 5, a_out, NULL ) - JSVERIFY( SUCCEED, - H5Aread(attr_2a_id, int_type_id, &a_out), - "can't read attribute (minimized) 'RANK'") - JSVERIFY( 3, a_out, NULL ) + ret = put_attribute(mindset_id, "RANK", &a_out, int_type_id, dspace_scalar_id, &attr_2a_id); + if(ret < 0) TEST_ERROR + + count = count_attributes(dset_id); + if(count != 2) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 2) TEST_ERROR + + ret = H5Aread(attr_2_id, int_type_id, &a_out); + if(ret < 0) TEST_ERROR + if(a_out != 5) TEST_ERROR + + ret = H5Aread(attr_2a_id, int_type_id, &a_out); + if(ret < 0) TEST_ERROR + if(a_out != 3) TEST_ERROR if (DEBUG_OH_SIZE) PRINT_DSET_OH_COMPARISON(dset_id, mindset_id) @@ -897,41 +345,25 @@ test_attribute_addition(void) */ a_out = -86; - JSVERIFY( SUCCEED, \ - put_attribute( \ - dset_id, \ - "FLAVOR", \ - &a_out, \ - int_type_id, \ - dspace_scalar_id, \ - &attr_3_id), \ - "unable to set attribute 'FLAVOR:-86'") + ret = put_attribute(dset_id, "FLAVOR", &a_out, int_type_id, dspace_scalar_id, &attr_3_id); + if(ret < 0) TEST_ERROR + a_out = 2185; - JSVERIFY( SUCCEED, \ - put_attribute( \ - mindset_id, \ - "FLAVOR", \ - &a_out, \ - int_type_id, \ - dspace_scalar_id, \ - &attr_3a_id), \ - "unable to set attribute (minimized) 'FLAVOR:2185'") - - JSVERIFY( 3, \ - count_attributes(dset_id), \ - NULL) - JSVERIFY( 3, \ - count_attributes(mindset_id), \ - NULL) - - JSVERIFY( SUCCEED, - H5Aread(attr_3_id, int_type_id, &a_out), - "can't read attribute 'RANK'") - JSVERIFY( -86, a_out, NULL ) - JSVERIFY( SUCCEED, - H5Aread(attr_3a_id, int_type_id, &a_out), - "can't read attribute (minimized) 'RANK'") - JSVERIFY( 2185, a_out, NULL ) + ret = put_attribute(mindset_id, "FLAVOR", &a_out, int_type_id, dspace_scalar_id, &attr_3a_id); + if(ret < 0) TEST_ERROR + + count = count_attributes(dset_id); + if(count != 3) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 3) TEST_ERROR + + ret = H5Aread(attr_3_id, int_type_id, &a_out); + if(ret < 0) TEST_ERROR + if(a_out != -86) TEST_ERROR + + ret = H5Aread(attr_3a_id, int_type_id, &a_out); + if(ret < 0) TEST_ERROR + if(a_out != 2185) TEST_ERROR if (DEBUG_OH_SIZE) PRINT_DSET_OH_COMPARISON(dset_id, mindset_id) @@ -940,19 +372,19 @@ test_attribute_addition(void) * TEARDOWN * ************/ - MUST_CLOSE(int_type_id, CLOSE_DATATYPE) - MUST_CLOSE(char_type_id, CLOSE_DATATYPE) - MUST_CLOSE(dcpl_id, CLOSE_PLIST) - MUST_CLOSE(dspace_id, CLOSE_DATASPACE) - MUST_CLOSE(dset_id, CLOSE_DATASET) - MUST_CLOSE(mindset_id, CLOSE_DATASET) - MUST_CLOSE(attr_1_id, CLOSE_ATTRIBUTE) - MUST_CLOSE(attr_1a_id, CLOSE_ATTRIBUTE) - MUST_CLOSE(attr_2_id, CLOSE_ATTRIBUTE) - MUST_CLOSE(attr_2a_id, CLOSE_ATTRIBUTE) - MUST_CLOSE(attr_3_id, CLOSE_ATTRIBUTE) - MUST_CLOSE(attr_3a_id, CLOSE_ATTRIBUTE) - MUST_CLOSE(file_id, CLOSE_FILE) + if(H5Tclose(int_type_id) < 0) TEST_ERROR + if(H5Tclose(char_type_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_id) < 0) TEST_ERROR + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Dclose(dset_id) < 0) TEST_ERROR + if(H5Dclose(mindset_id) < 0) TEST_ERROR + if(H5Aclose(attr_1_id) < 0) TEST_ERROR + if(H5Aclose(attr_1a_id) < 0) TEST_ERROR + if(H5Aclose(attr_2_id) < 0) TEST_ERROR + if(H5Aclose(attr_2a_id) < 0) TEST_ERROR + if(H5Aclose(attr_3_id) < 0) TEST_ERROR + if(H5Aclose(attr_3a_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR PASSED() return 0; @@ -1012,114 +444,80 @@ test_size_comparisons(void) char filename_a[512] = ""; char filename_b[512] = ""; + herr_t ret; + TESTING("default size comparisons"); /********* * SETUP * *********/ - FAIL_IF( NULL == h5_fixname( - OHMIN_FILENAME_A, - H5P_DEFAULT, - filename_a, - sizeof(filename_a)) ) + if(h5_fixname(OHMIN_FILENAME_A, H5P_DEFAULT, filename_a, sizeof(filename_a)) == NULL) + TEST_ERROR - FAIL_IF( NULL == h5_fixname( - OHMIN_FILENAME_B, - H5P_DEFAULT, - filename_b, - sizeof(filename_b)) ) + if(h5_fixname(OHMIN_FILENAME_B, H5P_DEFAULT, filename_b, sizeof(filename_b)) == NULL) + TEST_ERROR dcpl_minimize = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_minimize ) - JSVERIFY( SUCCEED, - H5Pset_dset_no_attrs_hint(dcpl_minimize, TRUE), - NULL ) + if(dcpl_minimize < 0) TEST_ERROR + + ret = H5Pset_dset_no_attrs_hint(dcpl_minimize, TRUE); + if(ret < 0) TEST_ERROR dcpl_dontmin = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_dontmin ) - JSVERIFY( SUCCEED, - H5Pset_dset_no_attrs_hint(dcpl_dontmin, FALSE), - NULL ) + if(dcpl_dontmin < 0) TEST_ERROR - dspace_id = H5Screate_simple( - 1, /* rank */ - array_10, /* current dimensions */ - NULL); /* maximum dimensions */ - FAIL_IF( 0 > dspace_id ) + ret = H5Pset_dset_no_attrs_hint(dcpl_dontmin, FALSE); + if(ret < 0) TEST_ERROR + + dspace_id = H5Screate_simple(1, array_10, NULL); + if(dspace_id < 0) TEST_ERROR int_type_id = H5Tcopy(H5T_NATIVE_INT); - FAIL_IF( 0 > int_type_id ) - - CREATE_FILE(filename_a, &file_f_id) - - CREATE_DATASET( \ - file_f_id, \ - "default", \ - int_type_id, \ - dspace_id, \ - H5P_DEFAULT, \ - &dset_f_x_id) - - CREATE_DATASET( \ - file_f_id, \ - "dsetNOT", \ - int_type_id, \ - dspace_id, \ - dcpl_dontmin, \ - &dset_f_N_id) - - CREATE_DATASET( \ - file_f_id, \ - "dsetMIN", \ - int_type_id, \ - dspace_id, \ - dcpl_minimize, \ - &dset_f_Y_id) - - CREATE_FILE(filename_b, &file_F_id) - FAIL_IF( 0 > H5Fset_dset_no_attrs_hint(file_F_id, TRUE) ) - - CREATE_DATASET( \ - file_F_id, \ - "default", \ - int_type_id, \ - dspace_id, \ - H5P_DEFAULT, \ - &dset_F_x_id) - - CREATE_DATASET( \ - file_F_id, \ - "dsetNOT", \ - int_type_id, \ - dspace_id, \ - dcpl_dontmin, \ - &dset_F_N_id) - - CREATE_DATASET( \ - file_F_id, \ - "dsetMIN", \ - int_type_id, \ - dspace_id, \ - dcpl_minimize, \ - &dset_F_Y_id) + if(int_type_id < 0) TEST_ERROR + + file_f_id = H5Fcreate(filename_a, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if(file_f_id < 0) TEST_ERROR + + dset_f_x_id = H5Dcreate(file_f_id, "default", int_type_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_f_x_id < 0) TEST_ERROR + + dset_f_N_id = H5Dcreate(file_f_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); + if(dset_f_N_id < 0) TEST_ERROR + + dset_f_Y_id = H5Dcreate(file_f_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); + if(dset_f_x_id < 0) TEST_ERROR + + file_F_id = H5Fcreate(filename_b, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if(file_F_id < 0) TEST_ERROR + ret = H5Fset_dset_no_attrs_hint(file_F_id, TRUE); + if(ret < 0) TEST_ERROR + + dset_F_x_id = H5Dcreate(file_F_id, "default", int_type_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_F_x_id < 0) TEST_ERROR + + dset_F_N_id = H5Dcreate(file_F_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); + if(dset_F_N_id < 0) TEST_ERROR + + dset_F_Y_id = H5Dcreate(file_F_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); + if(dset_F_Y_id < 0) TEST_ERROR /********* * TESTS * *********/ - JSVERIFY( EQ, oh_compare(dset_f_x_id, dset_f_x_id), NULL ) /* identity */ + if(oh_compare(dset_f_x_id, dset_f_x_id) != EQ) TEST_ERROR /* identity */ - JSVERIFY( EQ, oh_compare(dset_f_x_id, dset_f_N_id), NULL ) - JSVERIFY( GT, oh_compare(dset_f_x_id, dset_f_Y_id), NULL ) - JSVERIFY( GT, oh_compare(dset_f_N_id, dset_f_Y_id), NULL ) + if(oh_compare(dset_f_x_id, dset_f_N_id) != EQ) TEST_ERROR + if(oh_compare(dset_f_x_id, dset_f_Y_id) != GT) TEST_ERROR + if(oh_compare(dset_f_N_id, dset_f_Y_id) != GT) TEST_ERROR - JSVERIFY( EQ, oh_compare(dset_F_x_id, dset_F_N_id), NULL ) - JSVERIFY( EQ, oh_compare(dset_F_x_id, dset_F_Y_id), NULL ) - JSVERIFY( EQ, oh_compare(dset_F_N_id, dset_F_Y_id), NULL ) + if(oh_compare(dset_F_x_id, dset_F_N_id) != EQ) TEST_ERROR + if(oh_compare(dset_F_x_id, dset_F_Y_id) != EQ) TEST_ERROR + if(oh_compare(dset_F_N_id, dset_F_Y_id) != EQ) TEST_ERROR - JSVERIFY( EQ, oh_compare(dset_F_x_id, dset_f_Y_id), NULL ) - JSVERIFY( LT, oh_compare(dset_F_x_id, dset_f_x_id), NULL ) + if(oh_compare(dset_F_x_id, dset_f_Y_id) != EQ) TEST_ERROR + if(oh_compare(dset_F_x_id, dset_f_x_id) != LT) TEST_ERROR if (DEBUG_OH_SIZE) PRINT_DSET_OH_COMPARISON(dset_f_x_id, dset_F_x_id) @@ -1128,20 +526,20 @@ test_size_comparisons(void) * TEARDOWN * ************/ - MUST_CLOSE(dspace_id, CLOSE_DATASPACE) - MUST_CLOSE(int_type_id, CLOSE_DATATYPE) - MUST_CLOSE(dcpl_minimize, CLOSE_PLIST) - MUST_CLOSE(dcpl_dontmin, CLOSE_PLIST) + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(int_type_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_minimize) < 0) TEST_ERROR + if(H5Pclose(dcpl_dontmin) < 0) TEST_ERROR - MUST_CLOSE(file_f_id, CLOSE_FILE) - MUST_CLOSE(dset_f_x_id, CLOSE_DATASET) - MUST_CLOSE(dset_f_N_id, CLOSE_DATASET) - MUST_CLOSE(dset_f_Y_id, CLOSE_DATASET) + if(H5Fclose(file_f_id) < 0) TEST_ERROR + if(H5Dclose(dset_f_x_id) < 0) TEST_ERROR + if(H5Dclose(dset_f_N_id) < 0) TEST_ERROR + if(H5Dclose(dset_f_Y_id) < 0) TEST_ERROR - MUST_CLOSE(file_F_id, CLOSE_FILE) - MUST_CLOSE(dset_F_x_id, CLOSE_DATASET) - MUST_CLOSE(dset_F_N_id, CLOSE_DATASET) - MUST_CLOSE(dset_F_Y_id, CLOSE_DATASET) + if(H5Fclose(file_F_id) < 0) TEST_ERROR + if(H5Dclose(dset_F_x_id) < 0) TEST_ERROR + if(H5Dclose(dset_F_N_id) < 0) TEST_ERROR + if(H5Dclose(dset_F_Y_id) < 0) TEST_ERROR PASSED() return 0; @@ -1189,6 +587,7 @@ test_minimized_with_filter(void) hid_t dset_mx_id = -1; hid_t dset_mZ_id = -1; hid_t file_id = -1; + herr_t ret; /* | default | minimize * ----------+---------+--------- @@ -1203,98 +602,59 @@ test_minimized_with_filter(void) * SETUP * *********/ - FAIL_IF( NULL == h5_fixname( - OHMIN_FILENAME_A, - H5P_DEFAULT, - filename, - sizeof(filename)) ) + if(h5_fixname(OHMIN_FILENAME_A, H5P_DEFAULT, filename, sizeof(filename)) == NULL) + TEST_ERROR dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_mx_id ) - JSVERIFY( SUCCEED, - H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE), - NULL ) + if(dcpl_mx_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); + if(ret < 0) TEST_ERROR dcpl_xZ_id = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_xZ_id ) - JSVERIFY( SUCCEED, - H5Pset_chunk(dcpl_xZ_id, ndims, chunk_dim), - "unable to chunk dataset") - JSVERIFY( SUCCEED, - H5Pset_filter( - dcpl_xZ_id, - H5Z_FILTER_DEFLATE, - H5Z_FLAG_OPTIONAL, - 0, - filter_values), - "unable to set compression") + if(dcpl_xZ_id < 0) TEST_ERROR + ret = H5Pset_chunk(dcpl_xZ_id, ndims, chunk_dim); + if(ret < 0) TEST_ERROR + ret = H5Pset_filter(dcpl_xZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); + if(ret < 0) TEST_ERROR dcpl_mZ_id = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_mZ_id ) - JSVERIFY( SUCCEED, - H5Pset_dset_no_attrs_hint(dcpl_mZ_id, TRUE), - "unable to minimize to-be-filtered dataset header") - JSVERIFY( SUCCEED, - H5Pset_chunk(dcpl_mZ_id, ndims, chunk_dim), - "unable to chunk minimized dataset") - JSVERIFY( SUCCEED, - H5Pset_filter( - dcpl_mZ_id, - H5Z_FILTER_DEFLATE, - H5Z_FLAG_OPTIONAL, - 0, - filter_values), - "unable to set compression (minimized)") + if(dcpl_mZ_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mZ_id, TRUE); + if(ret < 0) TEST_ERROR + ret = H5Pset_chunk(dcpl_mZ_id, ndims, chunk_dim); + if(ret < 0) TEST_ERROR + ret = H5Pset_filter( dcpl_mZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); + if(ret < 0) TEST_ERROR dspace_id = H5Screate_simple(1, extents, extents); - FAIL_IF( 0 > dspace_id ) + if(dspace_id < 0) TEST_ERROR dtype_id = H5Tcopy(H5T_NATIVE_INT); - FAIL_IF( 0 > dtype_id ) - - - CREATE_FILE(filename, &file_id) - - CREATE_DATASET( \ - file_id, \ - "xx", \ - dtype_id, \ - dspace_id, \ - H5P_DEFAULT, \ - &dset_xx_id) - - CREATE_DATASET( \ - file_id, \ - "Mx", \ - dtype_id, \ - dspace_id, \ - dcpl_mx_id, \ - &dset_mx_id) - - CREATE_DATASET( \ - file_id, \ - "xZ", \ - dtype_id, \ - dspace_id, \ - dcpl_xZ_id, \ - &dset_xZ_id) - - CREATE_DATASET( \ - file_id, \ - "MZ", \ - dtype_id, \ - dspace_id, \ - dcpl_mZ_id, \ - &dset_mZ_id) + if(dtype_id < 0) TEST_ERROR + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if(file_id < 0) TEST_ERROR + + dset_xx_id = H5Dcreate(file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_xx_id < 0) TEST_ERROR + + dset_mx_id = H5Dcreate(file_id, "Mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); + if(dset_mx_id < 0) TEST_ERROR + + dset_xZ_id = H5Dcreate(file_id, "xZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xZ_id, H5P_DEFAULT); + if(dset_xZ_id < 0) TEST_ERROR + + dset_mZ_id = H5Dcreate(file_id, "MZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mZ_id, H5P_DEFAULT); + if(dset_mZ_id < 0) TEST_ERROR /********* * TESTS * *********/ - JSVERIFY( LT, oh_compare(dset_mx_id, dset_xx_id), NULL ) - JSVERIFY( LT, oh_compare(dset_mx_id, dset_xZ_id), NULL ) - JSVERIFY( GT, oh_compare(dset_mZ_id, dset_mx_id), NULL ) - JSVERIFY( LT, oh_compare(dset_mZ_id, dset_xZ_id), NULL ) + if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR + if(oh_compare(dset_mx_id, dset_xZ_id) != LT) TEST_ERROR + if(oh_compare(dset_mZ_id, dset_mx_id) != GT) TEST_ERROR + if(oh_compare(dset_mZ_id, dset_xZ_id) != LT) TEST_ERROR if (DEBUG_OH_SIZE) PRINT_DSET_OH_COMPARISON(dset_xZ_id, dset_mZ_id) @@ -1303,16 +663,16 @@ test_minimized_with_filter(void) * TEARDOWN * ************/ - MUST_CLOSE(dspace_id, CLOSE_DATASPACE) - MUST_CLOSE(dtype_id, CLOSE_DATATYPE) - MUST_CLOSE(dcpl_xZ_id, CLOSE_PLIST) - MUST_CLOSE(dcpl_mx_id, CLOSE_PLIST) - MUST_CLOSE(dcpl_mZ_id, CLOSE_PLIST) - MUST_CLOSE(dset_xx_id, CLOSE_DATASET) - MUST_CLOSE(dset_xZ_id, CLOSE_DATASET) - MUST_CLOSE(dset_mx_id, CLOSE_DATASET) - MUST_CLOSE(dset_mZ_id, CLOSE_DATASET) - MUST_CLOSE(file_id, CLOSE_FILE) + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(dtype_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_xZ_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mZ_id) < 0) TEST_ERROR + if(H5Dclose(dset_xx_id) < 0) TEST_ERROR + if(H5Dclose(dset_xZ_id) < 0) TEST_ERROR + if(H5Dclose(dset_mx_id) < 0) TEST_ERROR + if(H5Dclose(dset_mZ_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR PASSED() return 0; @@ -1362,6 +722,7 @@ test_modification_times(void) hid_t dset_mN_id = -1; hid_t file_id = -1; hid_t fapl_id = -1; + herr_t ret; unsigned i = 0; /* for testcase loop */ unsigned n_cases = 2; /* must match `cases` array size below */ @@ -1376,47 +737,38 @@ test_modification_times(void) * SETUP * *********/ - FAIL_IF( NULL == h5_fixname( - OHMIN_FILENAME_A, - H5P_DEFAULT, - filename, - sizeof(filename)) ) + if(h5_fixname(OHMIN_FILENAME_A, H5P_DEFAULT, filename, sizeof(filename)) == NULL) + TEST_ERROR dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_mx_id ) - JSVERIFY( SUCCEED, - H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE), - NULL ) + if(dcpl_mx_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); + if(ret < 0) TEST_ERROR dcpl_xT_id = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_xT_id ) - JSVERIFY( SUCCEED, - H5Pset_obj_track_times(dcpl_xT_id, TRUE), - "unable to set unminimized dcpl to track modtime" ) + if(dcpl_xT_id < 0) TEST_ERROR + ret = H5Pset_obj_track_times(dcpl_xT_id, TRUE); + if(ret < 0) TEST_ERROR dcpl_mT_id = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_mT_id ) - JSVERIFY( SUCCEED, - H5Pset_dset_no_attrs_hint(dcpl_mT_id, TRUE), - "unable to minimize to-be-filtered dataset header") - JSVERIFY( SUCCEED, - H5Pset_obj_track_times(dcpl_mT_id, TRUE), - "unable to set minimized dcpl to track modtime" ) + if(dcpl_mT_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mT_id, TRUE); + if(ret < 0) TEST_ERROR + ret = H5Pset_obj_track_times(dcpl_mT_id, TRUE); + if(ret < 0) TEST_ERROR dcpl_mN_id = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_mN_id ) - JSVERIFY( SUCCEED, - H5Pset_dset_no_attrs_hint(dcpl_mN_id, TRUE), - "unable to minimize to-be-filtered dataset header") - JSVERIFY( SUCCEED, - H5Pset_obj_track_times(dcpl_mN_id, FALSE), - "unable to set minimized dcpl to NOT track modtime" ) + if(dcpl_mN_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mN_id, TRUE); + if(ret < 0) TEST_ERROR + ret = H5Pset_obj_track_times(dcpl_mN_id, FALSE); + if(ret < 0) TEST_ERROR dspace_id = H5Screate_simple(1, extents, extents); - FAIL_IF( 0 > dspace_id ) + if(dspace_id < 0) TEST_ERROR dtype_id = H5Tcopy(H5T_NATIVE_INT); - FAIL_IF( 0 > dtype_id ) + if(dtype_id < 0) TEST_ERROR for (i = 0; i < n_cases; i++) { @@ -1428,69 +780,36 @@ test_modification_times(void) if (cases[i].oh_version > 1) { fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( 0 > fapl_id); - JSVERIFY( SUCCEED, - H5Pset_libver_bounds( - fapl_id, - H5F_LIBVER_V18, - H5F_LIBVER_V110), - "unable to set file to use v2 object headers" ) + if(fapl_id < 0) TEST_ERROR + ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_V110); + if(ret < 0) TEST_ERROR } - file_id = H5Fcreate( - filename, - H5F_ACC_TRUNC, - H5P_DEFAULT, - fapl_id); - FAIL_IF( 0 > file_id ) - - CREATE_DATASET( \ - file_id, \ - "xx", \ - dtype_id, \ - dspace_id, \ - H5P_DEFAULT, \ - &dset_xx_id) - - CREATE_DATASET( \ - file_id, \ - "mx", \ - dtype_id, \ - dspace_id, \ - dcpl_mx_id, \ - &dset_mx_id) - - CREATE_DATASET( \ - file_id, \ - "xT", \ - dtype_id, \ - dspace_id, \ - dcpl_xT_id, \ - &dset_xT_id) - - CREATE_DATASET( \ - file_id, \ - "mT", \ - dtype_id, \ - dspace_id, \ - dcpl_mT_id, \ - &dset_mT_id) - - CREATE_DATASET( \ - file_id, \ - "mN", \ - dtype_id, \ - dspace_id, \ - dcpl_mN_id, \ - &dset_mN_id) + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_xx_id = H5Dcreate( file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_xx_id < 0) TEST_ERROR + + dset_mx_id = H5Dcreate(file_id, "mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); + if(dset_mx_id < 0) TEST_ERROR + + dset_xT_id = H5Dcreate(file_id, "xT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xT_id, H5P_DEFAULT); + if(dset_xT_id < 0) TEST_ERROR + + dset_mT_id = H5Dcreate(file_id, "mT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mT_id, H5P_DEFAULT); + if(dset_mT_id < 0) TEST_ERROR + + dset_mN_id = H5Dcreate(file_id, "mN", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mN_id, H5P_DEFAULT); + if(dset_mN_id < 0) TEST_ERROR /* ----- * * TESTS * * ----- */ /* sanity check */ - FAIL_IF( LT != oh_compare(dset_mx_id, dset_xx_id) ) - FAIL_IF( LT != oh_compare(dset_mx_id, dset_xT_id) ) + if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR + if(oh_compare(dset_mx_id, dset_xT_id) != LT) TEST_ERROR if (DEBUG_OH_SIZE) { PRINT_DSET_OH_COMPARISON(dset_xx_id, dset_mx_id) @@ -1498,26 +817,25 @@ test_modification_times(void) PRINT_DSET_OH_COMPARISON(dset_mT_id, dset_mN_id) } - JSVERIFY( EQ, oh_compare(dset_xx_id, dset_xT_id), NULL ) - JSVERIFY( EQ, oh_compare(dset_mx_id, dset_mT_id), NULL ) - JSVERIFY( LT, oh_compare(dset_mN_id, dset_mT_id), NULL ) + if(oh_compare(dset_xx_id, dset_xT_id) != EQ) TEST_ERROR + if(oh_compare(dset_mx_id, dset_mT_id) != EQ) TEST_ERROR + if(oh_compare(dset_mN_id, dset_mT_id) != LT) TEST_ERROR - JSVERIFY( LT, oh_compare(dset_mT_id, dset_xT_id), - "minimized should always be smaller than unminimized" ) + if(oh_compare(dset_mT_id, dset_xT_id) != LT) TEST_ERROR /* ----------------- * * per-case teardown * * ----------------- */ - MUST_CLOSE(dset_xx_id, CLOSE_DATASET) - MUST_CLOSE(dset_xT_id, CLOSE_DATASET) - MUST_CLOSE(dset_mx_id, CLOSE_DATASET) - MUST_CLOSE(dset_mT_id, CLOSE_DATASET) - MUST_CLOSE(dset_mN_id, CLOSE_DATASET) - MUST_CLOSE(file_id, CLOSE_FILE) + if(H5Dclose(dset_xx_id) < 0) TEST_ERROR + if(H5Dclose(dset_xT_id) < 0) TEST_ERROR + if(H5Dclose(dset_mx_id) < 0) TEST_ERROR + if(H5Dclose(dset_mT_id) < 0) TEST_ERROR + if(H5Dclose(dset_mN_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR - if (fapl_id != H5P_DEFAULT) - MUST_CLOSE(fapl_id, CLOSE_PLIST) + if ((fapl_id != H5P_DEFAULT) && (H5Pclose(fapl_id) < 0)) + TEST_ERROR } /* for each version tested */ @@ -1525,12 +843,12 @@ test_modification_times(void) * TEARDOWN * ************/ - MUST_CLOSE(dspace_id, CLOSE_DATASPACE) - MUST_CLOSE(dtype_id, CLOSE_DATATYPE) - MUST_CLOSE(dcpl_xT_id, CLOSE_PLIST) - MUST_CLOSE(dcpl_mx_id, CLOSE_PLIST) - MUST_CLOSE(dcpl_mT_id, CLOSE_PLIST) - MUST_CLOSE(dcpl_mN_id, CLOSE_PLIST) + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(dtype_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_xT_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mT_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mN_id) < 0) TEST_ERROR PASSED() return 0; @@ -1572,6 +890,7 @@ test_fillvalue_backwards_compatability(void) hid_t fapl_id = -1; hid_t dset_0_id = -1; hid_t dset_1_id = -1; + herr_t ret; /********* * SETUP * @@ -1579,96 +898,77 @@ test_fillvalue_backwards_compatability(void) TESTING("with fill values and different libver support"); - FAIL_IF( NULL == h5_fixname( - OHMIN_FILENAME_A, - H5P_DEFAULT, - filename, - sizeof(filename)) ) + if(h5_fixname(OHMIN_FILENAME_A, H5P_DEFAULT, filename, sizeof(filename)) == NULL) + TEST_ERROR dspace_id = H5Screate_simple(1, extents, extents); - FAIL_IF( 0 > dspace_id ) + if(dspace_id < 0) TEST_ERROR dtype_id = H5Tcopy(H5T_NATIVE_INT); - FAIL_IF( 0 > dtype_id ) + if(dtype_id < 0) TEST_ERROR dcpl_id = H5Pcreate(H5P_DATASET_CREATE); - FAIL_IF( 0 > dcpl_id ) - FAIL_IF( FAIL == H5Pset_dset_no_attrs_hint(dcpl_id, TRUE) ) - FAIL_IF( FAIL == H5Pset_fill_value(dcpl_id, dtype_id, fill) ) + if(dcpl_id < 0) TEST_ERROR + + ret = H5Pset_dset_no_attrs_hint(dcpl_id, TRUE); + if(ret == FAIL) TEST_ERROR; + + ret = H5Pset_fill_value(dcpl_id, dtype_id, fill); + if(ret == FAIL) TEST_ERROR; fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( 0 > fapl_id ) - FAIL_IF( FAIL == H5Pset_libver_bounds( - fapl_id, - H5F_LIBVER_EARLIEST, - H5F_LIBVER_LATEST) ) - - file_id = H5Fcreate( - filename, - H5F_ACC_TRUNC, - H5P_DEFAULT, - fapl_id); - FAIL_IF( 0 > file_id ) - - CREATE_DATASET( \ - file_id, \ - "fullrange", \ - dtype_id, \ - dspace_id, \ - dcpl_id, \ - &dset_0_id) + if(fapl_id < 0) TEST_ERROR + + ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST); + if(ret == FAIL) TEST_ERROR; + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_0_id = H5Dcreate(file_id, "fullrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if(dset_0_id < 0) TEST_ERROR /* Close file and re-open with different libver bounds. * Dataset "fullrange" must also be closed for expected reopen behavior. */ - MUST_CLOSE(file_id, CLOSE_FILE) - MUST_CLOSE(dset_0_id, CLOSE_DATASET) - - FAIL_IF( FAIL == H5Pset_libver_bounds( - fapl_id, - H5F_LIBVER_V18, - H5F_LIBVER_LATEST) ) - - file_id = H5Fopen( - filename, - H5F_ACC_RDWR, - fapl_id); - FAIL_IF( 0 > file_id ) - - CREATE_DATASET( \ - file_id, \ - "upperrange", \ - dtype_id, \ - dspace_id, \ - dcpl_id, \ - &dset_1_id) + if(H5Fclose(file_id) < 0) TEST_ERROR; + if(H5Dclose(dset_0_id) < 0) TEST_ERROR + + ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_LATEST); + if(ret == FAIL) TEST_ERROR; + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_1_id = H5Dcreate(file_id, "upperrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if(dset_1_id < 0) TEST_ERROR /* re-open "fullrange" dataset */ dset_0_id = H5Dopen2(file_id, "fullrange", H5P_DEFAULT); - FAIL_IF( 0 > dset_0_id) + if(dset_0_id < 0) TEST_ERROR /********* * TESTS * *********/ - if (DEBUG_OH_SIZE) + if(DEBUG_OH_SIZE) PRINT_DSET_OH_COMPARISON(dset_1_id, dset_0_id) - JSVERIFY( LT, oh_compare(dset_1_id, dset_0_id), - "dset not supporting pre-1.08 should be smaller?") + /* dset not supporting pre-1.08 should be smaller? */ + if(oh_compare(dset_1_id, dset_0_id) != LT) TEST_ERROR /************ * TEARDOWN * ************/ - MUST_CLOSE(dspace_id, CLOSE_DATASPACE) - MUST_CLOSE(dtype_id, CLOSE_DATATYPE) - MUST_CLOSE(dcpl_id, CLOSE_PLIST) - MUST_CLOSE(fapl_id, CLOSE_PLIST) - MUST_CLOSE(dset_0_id, CLOSE_DATASET) - MUST_CLOSE(dset_1_id, CLOSE_DATASET) - MUST_CLOSE(file_id, CLOSE_FILE) + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(dtype_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_id) < 0) TEST_ERROR + if(H5Pclose(fapl_id) < 0) TEST_ERROR + if(H5Dclose(dset_0_id) < 0) TEST_ERROR + if(H5Dclose(dset_1_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR; PASSED() return 0; diff --git a/test/tfile.c b/test/tfile.c index 9a556d4..b45c3ce 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -7180,7 +7180,7 @@ test_min_dset_ohdr(void) */ ret = H5Fget_dset_no_attrs_hint(file_id, &minimize); CHECK(ret, FAIL, "H5Fget_dset_no_attrs_hint"); - VERIFY(minimize, FALSE, "minimize flag); + VERIFY(minimize, FALSE, "minimize flag"); /*---------------------------------------- * TEST set to TRUE @@ -7190,7 +7190,7 @@ test_min_dset_ohdr(void) ret = H5Fget_dset_no_attrs_hint(file_id, &minimize); CHECK(ret, FAIL, "H5Fget_dset_no_attrs_hint"); - VERIFY(minimize, TRUE, "minimize flag); + VERIFY(minimize, TRUE, "minimize flag"); /*---------------------------------------- * TEST second file open on same filename @@ -7248,11 +7248,11 @@ test_min_dset_ohdr(void) H5E_BEGIN_TRY { ret = H5Fget_dset_no_attrs_hint(-1, &minimize); } H5E_END_TRY; - VERIFY(ret, FAIL, H5Fget_dset_no_attrs_hint); + VERIFY(ret, FAIL, "H5Fget_dset_no_attrs_hint"); /* trying to get with invalid pointer */ H5E_BEGIN_TRY { - ret = H5Fget_dset_no_attrs_hint(file_id, NULL) + ret = H5Fget_dset_no_attrs_hint(file_id, NULL); } H5E_END_TRY; VERIFY(ret, FAIL, "H5Fget_dset_no_attrs_hint"); -- cgit v0.12