summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-11-04 06:27:10 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-11-04 06:27:10 (GMT)
commit0d12ce44b2486809100d460645710373ec138b64 (patch)
treeef76c0c026725750edc73ab8ecab5ea7c62381a4
parented452ce6905b7affbaf6d0bceb675e37ddf54ea8 (diff)
downloadhdf5-0d12ce44b2486809100d460645710373ec138b64.zip
hdf5-0d12ce44b2486809100d460645710373ec138b64.tar.gz
hdf5-0d12ce44b2486809100d460645710373ec138b64.tar.bz2
Add cache logging test.
-rw-r--r--MANIFEST1
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/CMakeTests.cmake3
-rw-r--r--test/Makefile.am6
-rw-r--r--test/cache_logging.c176
5 files changed, 185 insertions, 2 deletions
diff --git a/MANIFEST b/MANIFEST
index 16cc953..f6b2ea9 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -891,6 +891,7 @@
./test/cache_api.c
./test/cache_common.c
./test/cache_common.h
+./test/cache_logging.c
./test/cache_tagging.c
./test/cmpd_dset.c
./test/cork.c
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 6e6a0b9..22774cd 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -249,6 +249,7 @@ set (H5_TESTS
vds
file_image
unregister
+ cache_logging
cork
)
diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake
index 1e7940a..f4b37f3 100644
--- a/test/CMakeTests.cmake
+++ b/test/CMakeTests.cmake
@@ -493,6 +493,8 @@ set (test_CLEANFILES
vds_src_0.h5
vds_src_1.h5
tbogus.h5.copy
+ cache_logging.h5
+ cache_logging.out
)
# Remove any output file left over from previous test run
@@ -558,6 +560,7 @@ set (H5TEST_TESTS
vds
file_image
unregister
+ cache_logging
cork
)
diff --git a/test/Makefile.am b/test/Makefile.am
index 7d062f4..b6be746 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -48,7 +48,7 @@ TEST_PROG= testhdf5 cache cache_api cache_tagging lheap ohdr stab gheap \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe enc_dec_plist enc_dec_plist_cross_platform\
getname vfd ntypes dangle dtransform reserved cross_read \
- freespace mf vds file_image unregister cork
+ freespace mf vds file_image unregister cache_logging cork
# List programs to be built when testing here.
# error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh.
@@ -160,7 +160,9 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \
split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \
file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 \
- vds_virt.h5 vds_dapl.h5 vds_src_[0-1].h5
+ vds_virt.h5 vds_dapl.h5 vds_src_[0-1].h5 \
+ cache_logging.h5 cache_logging.out
+
# Sources for testhdf5 executable
testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
tgenprop.c th5o.c th5s.c tcoords.c theap.c tid.c titerate.c tmeta.c tmisc.c \
diff --git a/test/cache_logging.c b/test/cache_logging.c
new file mode 100644
index 0000000..a5e399c
--- /dev/null
+++ b/test/cache_logging.c
@@ -0,0 +1,176 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* Purpose: Tests the metadata cache logging framework */
+
+#include "h5test.h"
+
+#define LOG_LOCATION "cache_logging.out"
+#define FILE_NAME "cache_logging"
+
+#define N_GROUPS 100
+
+/*-------------------------------------------------------------------------
+ * Function: test_logging_api
+ *
+ * Purpose: Tests the API calls that affect mdc logging
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_logging_api(void)
+{
+ hid_t fapl = -1;
+ hbool_t is_enabled;
+ hbool_t is_enabled_out;
+ hbool_t start_on_access;
+ hbool_t start_on_access_out;
+ char *location = NULL;
+ size_t size;
+
+ hid_t fid;
+ hid_t gid;
+ hbool_t is_currently_logging;
+ char group_name[8];
+ char filename[1024];
+ int i;
+
+ TESTING("metadata cache log api calls");
+
+ fapl = h5_fileaccess();
+ h5_fixname(FILE_NAME, fapl, filename, sizeof filename);
+
+ /* Set up metadata cache logging */
+ is_enabled = TRUE;
+ start_on_access = FALSE;
+ if(H5Pset_mdc_log_options(fapl, is_enabled, LOG_LOCATION, start_on_access) < 0)
+ TEST_ERROR;
+
+ /* Check to make sure that the property list getter returns the correct
+ * location string buffer size;
+ */
+ is_enabled_out = FALSE;
+ start_on_access_out = TRUE;
+ location = NULL;
+ size = 999;
+ if(H5Pget_mdc_log_options(fapl, &is_enabled_out, location, &size,
+ &start_on_access_out) < 0)
+ TEST_ERROR;
+ if(size != strlen(LOG_LOCATION) + 1)
+ TEST_ERROR;
+
+ /* Check to make sure that the property list getter works */
+ if(NULL == (location = (char *)HDcalloc(size, sizeof(char))))
+ TEST_ERROR;
+ if(H5Pget_mdc_log_options(fapl, &is_enabled_out, location, &size,
+ &start_on_access_out) < 0)
+ TEST_ERROR;
+ if((is_enabled != is_enabled_out)
+ || (start_on_access != start_on_access_out)
+ || HDstrcmp(LOG_LOCATION, location))
+ TEST_ERROR;
+
+ /* Create a file */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR;
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
+
+
+ /* Check to see if the logging flags were set correctly */
+ is_enabled = FALSE;
+ is_currently_logging = TRUE;
+ if((H5Fget_mdc_logging_status(fid, &is_enabled, &is_currently_logging) < 0)
+ || (is_enabled != TRUE)
+ || (is_currently_logging != FALSE))
+ TEST_ERROR;
+
+ /* Turn on logging and check flags */
+ if(H5Fstart_mdc_logging(fid) < 0)
+ TEST_ERROR;
+ is_enabled = FALSE;
+ is_currently_logging = FALSE;
+ if((H5Fget_mdc_logging_status(fid, &is_enabled, &is_currently_logging) < 0)
+ || (is_enabled != TRUE)
+ || (is_currently_logging != TRUE))
+ TEST_ERROR;
+
+ /* Perform some manipulations */
+ for(i = 0; i < N_GROUPS; i++) {
+ HDmemset(group_name, 0, 8);
+ HDsnprintf(group_name, 8, "%d", i);
+ if((gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ if(H5Gclose(gid) < 0)
+ TEST_ERROR;
+ }
+
+ /* Turn off logging and check flags */
+ if(H5Fstop_mdc_logging(fid) < 0)
+ TEST_ERROR;
+ is_enabled = FALSE;
+ is_currently_logging = TRUE;
+ if((H5Fget_mdc_logging_status(fid, &is_enabled, &is_currently_logging) < 0)
+ || (is_enabled != TRUE)
+ || (is_currently_logging != FALSE))
+ TEST_ERROR;
+
+ /* Clean up */
+ if(H5Fclose(fid) < 0)
+ TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ return 1;
+ } /* test_logging_api() */
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Test basic cache logging operations
+ *
+ * Return: Success: zero
+ * Failure: non-zero
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ int nerrors = 0;
+
+ /* Reset library */
+ h5_reset();
+
+ printf("Testing basic metadata cache logging functionality.\n");
+
+ nerrors += test_logging_api();
+
+ if(nerrors) {
+ printf("***** %d Metadata cache logging TEST%s FAILED! *****\n",
+ nerrors, nerrors > 1 ? "S" : "");
+ return 1;
+ }
+
+ printf("All Metadata Cache Logging tests passed.\n");
+ return 0;
+}
+