summaryrefslogtreecommitdiffstats
path: root/test/tmisc.c
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-05-28 14:10:51 (GMT)
committerGitHub <noreply@github.com>2021-05-28 14:10:51 (GMT)
commit2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8 (patch)
tree40975e0846d101360a838d42e16f4687fed77f4a /test/tmisc.c
parente22687912dbc6fcf4fff57e86e2cd5d75c81f81e (diff)
downloadhdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.zip
hdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.tar.gz
hdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.tar.bz2
Much normalization with develop (#701)
* Brings CMake updates from develop * Brings reduction in pedantic casts from develop * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Formatted source * Bring over some VOL registration changes * VOL cleanup * H5VL_request_status_t substitutions * H5F.c cleanup * Minor API tweaks from develop * Moves H5G package init/teardown to H5Gint.c * H5G cleanup * H5M cleanup * H5SM cleanup * H5T cleanup * H5R cleanup * H5Lpublic.h cleanup * H5L cleanup * H5O cleanup * H5A, H5CS, and H5AC cleanup * Moved H5A init/teardown code to H5Aint.c * Moves H5D I/O functions to H5D.c * H5D cleanup * Misc minor cleanup * H5P close cleanup * H5Tpublic.h cleanup * Fixes err_compat test * H5PLpublic.h cleanup * Updates H5Ppublic.h * H5Fpublic.h updates * H5A.c cleanup * Brings over H5Aexists and related changes * Brings CMake shell testing changes from develop * Close callback changes * H5R and H5Tcommit normalization * err_compat test works now * H5O tweaks * Updates VOL registration code * Brings over H5VL_create_object * H5Tconv.c reformatting * H5T.c tweaks * Brings datatype and reference updates from develop * Brings VOL plugin loading changes from develop * Brings event sets from develop * Brings async functions over * Tools changes * Brings over many tools changes from develop * Brings VOL flags from develop * Fixes h5dump double/float tests * Updates h5repack tests * Brings h5diff test changes from develop * Last h5dump changes * Brings test changes from develop * Committing clang-format changes * Tidied h5_testing() * Brings chunk iteration code + misc from develop * Updates vds test * Enables external link parallel test * Brings updated property lists from develop * H5G changes from develop * H5MF cleanup * Brings vfd_swmr test back into CMake * Updates threadsafe test * Updates plist test * Brings recent changes from develop Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/tmisc.c')
-rw-r--r--test/tmisc.c136
1 files changed, 125 insertions, 11 deletions
diff --git a/test/tmisc.c b/test/tmisc.c
index b078eed..302da0d 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -2521,17 +2521,17 @@ test_misc13(void)
static void
test_misc14(void)
{
- hid_t file_id; /* File ID */
- hid_t fapl; /* File access property list ID */
- hid_t DataSpace; /* Dataspace ID */
- hid_t Dataset1; /* Dataset ID #1 */
- hid_t Dataset2; /* Dataset ID #2 */
- hid_t Dataset3; /* Dataset ID #3 */
- double data1 = 5.0F; /* Data to write for dataset #1 */
- double data2 = 10.0F; /* Data to write for dataset #2 */
- double data3 = 15.0F; /* Data to write for dataset #3 */
- double rdata; /* Data read in */
- herr_t ret; /* Generic return value */
+ hid_t file_id; /* File ID */
+ hid_t fapl; /* File access property list ID */
+ hid_t DataSpace; /* Dataspace ID */
+ hid_t Dataset1; /* Dataset ID #1 */
+ hid_t Dataset2; /* Dataset ID #2 */
+ hid_t Dataset3; /* Dataset ID #3 */
+ double data1 = 5.0; /* Data to write for dataset #1 */
+ double data2 = 10.0; /* Data to write for dataset #2 */
+ double data3 = 15.0; /* Data to write for dataset #3 */
+ double rdata; /* Data read in */
+ herr_t ret; /* Generic return value */
/* Test creating two datasets and deleting the second */
@@ -5905,6 +5905,119 @@ test_misc35(void)
} /* end test_misc35() */
+/* Context to pass to 'atclose' callbacks */
+static int test_misc36_context;
+
+/* 'atclose' callbacks for test_misc36 */
+static void
+test_misc36_cb1(void *_ctx)
+{
+ int * ctx = (int *)_ctx; /* Set up context pointer */
+ hbool_t is_terminating; /* Flag indicating the library is terminating */
+ herr_t ret; /* Return value */
+
+ /* Check whether the library thinks it's terminating */
+ is_terminating = FALSE;
+ ret = H5is_library_terminating(&is_terminating);
+ CHECK(ret, FAIL, "H5is_library_terminating");
+ VERIFY(is_terminating, TRUE, "H5is_library_terminating");
+
+ /* Verify correct ordering for 'atclose' callbacks */
+ if (0 != *ctx)
+ HDabort();
+
+ /* Update context value */
+ *ctx = 1;
+}
+
+static void
+test_misc36_cb2(void *_ctx)
+{
+ int * ctx = (int *)_ctx; /* Set up context pointer */
+ hbool_t is_terminating; /* Flag indicating the library is terminating */
+ herr_t ret; /* Return value */
+
+ /* Check whether the library thinks it's terminating */
+ is_terminating = FALSE;
+ ret = H5is_library_terminating(&is_terminating);
+ CHECK(ret, FAIL, "H5is_library_terminating");
+ VERIFY(is_terminating, TRUE, "H5is_library_terminating");
+
+ /* Verify correct ordering for 'atclose' callbacks */
+ if (1 != *ctx)
+ HDabort();
+
+ /* Update context value */
+ *ctx = 2;
+}
+
+/****************************************************************
+**
+** test_misc36(): Exercise H5atclose and H5is_library_terminating
+**
+****************************************************************/
+static void
+test_misc36(void)
+{
+ hbool_t is_terminating; /* Flag indicating the library is terminating */
+ herr_t ret; /* Return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("H5atclose and H5is_library_terminating API calls"));
+
+ /* Check whether the library thinks it's terminating */
+ is_terminating = TRUE;
+ ret = H5is_library_terminating(&is_terminating);
+ CHECK(ret, FAIL, "H5is_library_terminating");
+ VERIFY(is_terminating, FALSE, "H5is_library_terminating");
+
+ /* Shut the library down */
+ test_misc36_context = 0;
+ H5close();
+
+ /* Check whether the library thinks it's terminating */
+ is_terminating = TRUE;
+ ret = H5is_library_terminating(&is_terminating);
+ CHECK(ret, FAIL, "H5is_library_terminating");
+ VERIFY(is_terminating, FALSE, "H5is_library_terminating");
+
+ /* Check the close context was not changed */
+ VERIFY(test_misc36_context, 0, "H5atclose");
+
+ /* Restart the library */
+ H5open();
+
+ /* Check whether the library thinks it's terminating */
+ is_terminating = TRUE;
+ ret = H5is_library_terminating(&is_terminating);
+ CHECK(ret, FAIL, "H5is_library_terminating");
+ VERIFY(is_terminating, FALSE, "H5is_library_terminating");
+
+ /* Register the 'atclose' callbacks */
+ /* (Note that these will be called in reverse order, which is checked) */
+ ret = H5atclose(&test_misc36_cb2, &test_misc36_context);
+ CHECK(ret, FAIL, "H5atclose");
+ ret = H5atclose(&test_misc36_cb1, &test_misc36_context);
+ CHECK(ret, FAIL, "H5atclose");
+
+ /* Shut the library down */
+ test_misc36_context = 0;
+ H5close();
+
+ /* Check the close context was changed correctly */
+ VERIFY(test_misc36_context, 2, "H5atclose");
+
+ /* Restart the library */
+ H5open();
+
+ /* Close the library again */
+ test_misc36_context = 0;
+ H5close();
+
+ /* Check the close context was not changed */
+ VERIFY(test_misc36_context, 0, "H5atclose");
+} /* end test_misc36() */
+
/****************************************************************
**
** test_misc(): Main misc. test routine.
@@ -5956,6 +6069,7 @@ test_misc(void)
test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */
test_misc34(); /* Test behavior of 0 and NULL in H5MM API calls */
test_misc35(); /* Test behavior of free-list & allocation statistics API calls */
+ test_misc36(); /* Exercise H5atclose and H5is_library_terminating */
} /* test_misc() */