summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/CMakeTests.cmake2
-rw-r--r--test/Makefile.am2
-rw-r--r--test/evict_on_close.c144
4 files changed, 148 insertions, 1 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1ab4165..6e6a0b9 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -204,6 +204,7 @@ set (H5_TESTS
ohdr
stab
gheap
+ evict_on_close
farray
earray
btree2
diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake
index ca890ba..1e7940a 100644
--- a/test/CMakeTests.cmake
+++ b/test/CMakeTests.cmake
@@ -513,6 +513,7 @@ set (H5TEST_TESTS
ohdr
stab
gheap
+ evict_on_close
farray
earray
btree2
@@ -865,6 +866,7 @@ if (HDF5_TEST_VFD)
ohdr
stab
gheap
+ evict_on_close
pool
# accum
farray
diff --git a/test/Makefile.am b/test/Makefile.am
index 9e0f9c5..7d062f4 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -42,7 +42,7 @@ check_SCRIPTS = $(TEST_SCRIPT)
# As an exception, long-running tests should occur earlier in the list.
# This gives them more time to run when tests are executing in parallel.
TEST_PROG= testhdf5 cache cache_api cache_tagging lheap ohdr stab gheap \
- farray earray btree2 fheap \
+ evict_on_close farray earray btree2 fheap \
pool accum hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset filter_fail extend external efc objcopy links unlink \
big mtime fillval mount flush1 flush2 app_ref enum \
diff --git a/test/evict_on_close.c b/test/evict_on_close.c
new file mode 100644
index 0000000..bcbd030
--- /dev/null
+++ b/test/evict_on_close.c
@@ -0,0 +1,144 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Dana Robinson
+ * Spring 2016
+ *
+ * Purpose: Tests the basic operation of the evict-on-close cache
+ * behavior. Tests that ensure the tagging is handled correctly
+ * are located in cache.c.
+ */
+
+#include "h5test.h"
+
+static herr_t check_evict_on_close_api(void);
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_evict_on_close_api()
+ *
+ * Purpose: Verify that the H5Pset/get_evict_on_close() calls behave
+ * correctly.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Dana Robinson
+ * Spring 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+check_evict_on_close_api(void)
+{
+ hid_t fapl_id = -1;
+ hid_t dapl_id = -1;
+ hbool_t evict_on_close;
+ herr_t status;
+
+ TESTING("evict on close API");
+
+ /* Create a fapl */
+ if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Check the default */
+ evict_on_close = TRUE;
+ if(H5Pget_evict_on_close(fapl_id, &evict_on_close) < 0)
+ FAIL_STACK_ERROR;
+ if(evict_on_close != FALSE)
+ FAIL_PUTS_ERROR("Incorrect default evict on close value.");
+
+ /* Set the evict on close property */
+ evict_on_close = TRUE;
+ if(H5Pset_evict_on_close(fapl_id, evict_on_close) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Make sure we can get it back out */
+ evict_on_close = FALSE;
+ if(H5Pget_evict_on_close(fapl_id, &evict_on_close) < 0)
+ FAIL_STACK_ERROR;
+ if(evict_on_close != TRUE)
+ FAIL_PUTS_ERROR("Incorrect evict on close value.");
+
+ /* close fapl */
+ if(H5Pclose(fapl_id) < 0)
+ FAIL_STACK_ERROR;
+
+ /**********************************************/
+ /* Trying passing in a non-fapl property list */
+ /**********************************************/
+
+ if((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* ensure using an incorrect access plist fails */
+ H5E_BEGIN_TRY {
+ status = H5Pset_evict_on_close(dapl_id, evict_on_close);
+ } H5E_END_TRY;
+ if(status >= 0)
+ FAIL_PUTS_ERROR("H5Pset_evict_on_close() accepted invalid access plist.");
+
+ /* ensure an invalid plist fails */
+ H5E_BEGIN_TRY {
+ status = H5Pget_evict_on_close((hid_t)-1, &evict_on_close);
+ } H5E_END_TRY;
+ if(status >= 0)
+ FAIL_PUTS_ERROR("H5Pget_evict_on_close() accepted invalid hid_t.");
+
+ /* close dapl */
+ if(H5Pclose(dapl_id) < 0)
+ FAIL_STACK_ERROR;
+
+ PASSED();
+ return SUCCEED;
+
+error:
+ H5_FAILED();
+ return FAIL;
+
+} /* check_evict_on_close_api() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Return: EXIT_FAILURE/EXIT_SUCCESS
+ *
+ * Programmer: Dana Robinson
+ * Spring 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ unsigned nerrors = 0;
+
+ printf("Testing evict-on-close cache behavior.\n");
+
+ nerrors += check_evict_on_close_api() < 0 ? 1 : 0;
+
+ if(nerrors) {
+ printf("***** %u evict-on-close test%s FAILED! *****\n",
+ nerrors, nerrors > 1 ? "S" : "");
+ return EXIT_FAILURE;
+ }
+
+ printf("All evict-on-close tests passed.\n");
+
+ return EXIT_SUCCESS;
+}
+