summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJacob Smith <jake.smith@hdfgroup.org>2018-09-11 21:37:14 (GMT)
committerJacob Smith <jake.smith@hdfgroup.org>2018-09-11 21:37:14 (GMT)
commit602dd3ac15c9f5cd47fc78985266ce66a68a8789 (patch)
tree149023d5992abebe5a5a36e45e8132ab478a8c63 /test
parent5647dea421be9dc8429f08632aa72a8a22904292 (diff)
downloadhdf5-602dd3ac15c9f5cd47fc78985266ce66a68a8789.zip
hdf5-602dd3ac15c9f5cd47fc78985266ce66a68a8789.tar.gz
hdf5-602dd3ac15c9f5cd47fc78985266ce66a68a8789.tar.bz2
Stash work on object header reduction code and tests.
CMake stuff is not verified.
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/CMakeTests.cmake2
-rw-r--r--test/Makefile.am15
-rw-r--r--test/dsets.c109
-rw-r--r--test/enc_dec_plist.c3
-rw-r--r--test/gen_plist.c3
-rw-r--r--test/tfile.c139
7 files changed, 265 insertions, 7 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 517a620..6c1e0eb 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -234,6 +234,7 @@ set (H5_TESTS
cache_logging
cork
swmr
+ ohdr_min
)
macro (ADD_H5_EXE file)
diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake
index cc6ebb8..44494e9 100644
--- a/test/CMakeTests.cmake
+++ b/test/CMakeTests.cmake
@@ -359,6 +359,8 @@ set (test_CLEANFILES
lheap.h5
fheap.h5
ohdr.h5
+ ohdr_min_a.h5
+ ohdr_min_b.h5
stab.h5
extern_*.h5
extern_*.raw
diff --git a/test/Makefile.am b/test/Makefile.am
index b9aa3fb..551c5ee 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -52,15 +52,15 @@ 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_image cache_tagging lheap ohdr stab gheap \
- evict_on_close farray earray btree2 fheap \
+ cache cache_api cache_image cache_tagging lheap ohdr ohdr_min stab \
+ gheap evict_on_close farray earray btree2 fheap \
pool accum hyperslab istore bittests dt_arith page_buffer \
dtypes dsets cmpd_dset filter_fail extend direct_chunk external efc \
- objcopy links unlink twriteorder 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 \
- cache_logging cork swmr
+ objcopy links unlink twriteorder 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 \
+ cache_logging cork swmr
# 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.
@@ -165,6 +165,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \
sys_file1 tfile[1-7].h5 th5s[1-4].h5 lheap.h5 fheap.h5 ohdr.h5 \
stab.h5 extern_[1-5].h5 extern_[1-4][rw].raw gheap[0-4].h5 \
+ ohdr_min_a.h5 ohdr_min_b.h5 \
dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \
big.data big[0-9][0-9][0-9][0-9][0-9].h5 \
stdio.h5 sec2.h5 dtypes[0-9].h5 dtypes1[0].h5 dt_arith[1-2].h5 tattr.h5 \
diff --git a/test/dsets.c b/test/dsets.c
index d23f438..94c967e 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -13034,6 +13034,113 @@ test_versionbounds()
return -1;
} /* test_versionbounds() */
+
+/*-----------------------------------------------------------------------------
+ * Function: test_object_header_minimization_dcpl
+ *
+ * Purpose: Test the "datset object header minimization" property as part of
+ * the DCPL.
+ *
+ * Return: Success/pass: 0
+ * Failure/error: -1
+ *
+ * Programmer: Jacob Smith
+ * 15 Aug 2018
+ *
+ * Changes: None.
+ *-----------------------------------------------------------------------------
+ */
+static herr_t
+test_object_header_minimization_dcpl(void)
+{
+ hid_t dcpl_id = -1;
+ hid_t file_id = -1;
+ hbool_t minimize = FALSE;
+
+ TESTING("dcpl flags to minimize dataset object header");
+
+ /*********/
+ /* SETUP */
+ /*********/
+
+ file_id = H5Fcreate(
+ "some_arbitrary_filename",
+ H5F_ACC_TRUNC,
+ H5P_DEFAULT,
+ H5P_DEFAULT);
+ if (0 > file_id)
+ FAIL_PUTS_ERROR("unable to create test file\n");
+
+ dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
+ if (0 > dcpl_id)
+ FAIL_PUTS_ERROR("unable to create DCPL\n");
+
+ /*********/
+ /* TESTS */
+ /*********/
+
+ /* TEST default value (not set explicitly)
+ */
+ if (FAIL == H5Pget_dset_no_attrs_hint(dcpl_id, &minimize))
+ FAIL_PUTS_ERROR("unable to get minimize value\n");
+ if (FALSE != minimize)
+ FAIL_PUTS_ERROR("Expected FALSE default but was not!\n");
+
+ /* TEST FALSE-set value
+ */
+ if (FAIL == H5Pset_dset_no_attrs_hint(dcpl_id, FALSE))
+ FAIL_PUTS_ERROR("unable to set minimize value to FALSE\n");
+ if (FAIL == H5Pget_dset_no_attrs_hint(dcpl_id, &minimize))
+ FAIL_PUTS_ERROR("unable to get minimize value\n");
+ if (FALSE != minimize)
+ FAIL_PUTS_ERROR("Expected FALSE default but was not!\n");
+
+ /* TEST TRUE-set value
+ */
+ if (FAIL == H5Pset_dset_no_attrs_hint(dcpl_id, TRUE))
+ FAIL_PUTS_ERROR("unable to set minimize value to TRUE\n");
+ if (FAIL == H5Pget_dset_no_attrs_hint(dcpl_id, &minimize))
+ FAIL_PUTS_ERROR("unable to get minimize value\n");
+ if (TRUE != minimize)
+ FAIL_PUTS_ERROR("Expected TRUE default but was not!\n");
+
+ /* TEST error cases
+ */
+ H5E_BEGIN_TRY {
+ if (SUCCEED == H5Pget_dset_no_attrs_hint(-1, &minimize))
+ FAIL_PUTS_ERROR("Invalid DCPL ID should fail\n");
+
+ if (SUCCEED == H5Pset_dset_no_attrs_hint(-1, FALSE))
+ FAIL_PUTS_ERROR("Invalid DCPL ID should fail\n");
+
+ if (SUCCEED == H5Pset_dset_no_attrs_hint(-1, TRUE))
+ FAIL_PUTS_ERROR("Invalid DCPL ID should fail\n");
+
+ if (SUCCEED == H5Pget_dset_no_attrs_hint(dcpl_id, NULL))
+ FAIL_PUTS_ERROR("NULL out pointer should fail\n");
+ } H5E_END_TRY;
+
+ /************/
+ /* TEARDOWN */
+ /************/
+
+ if (FAIL == H5Fclose(file_id))
+ FAIL_PUTS_ERROR("can't close FILE");
+
+ if (FAIL == H5Pclose(dcpl_id))
+ FAIL_PUTS_ERROR("unable to close DCPL\n");
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl_id);
+ H5Fclose(file_id);
+ } H5E_END_TRY;
+ return -1;
+} /* test_object_header_minimization_dcpl */
+
/*-------------------------------------------------------------------------
* Function: main
@@ -13234,6 +13341,8 @@ main(void)
/* Tests version bounds using its own file */
nerrors += (test_versionbounds() < 0 ? 1 : 0);
+ nerrors += (test_object_header_minimization_dcpl() < 0 ? 1 : 0);
+
/* Run misc tests */
nerrors += dls_01_main();
diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c
index 36db2d0..cee38f3 100644
--- a/test/enc_dec_plist.c
+++ b/test/enc_dec_plist.c
@@ -146,6 +146,9 @@ main(void)
if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0)
FAIL_STACK_ERROR
+ if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0)
+ FAIL_STACK_ERROR
+
max_size[0] = 100;
if((H5Pset_external(dcpl, "ext1.data", (off_t)0,
(hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
diff --git a/test/gen_plist.c b/test/gen_plist.c
index 62693bd..d8096e3 100644
--- a/test/gen_plist.c
+++ b/test/gen_plist.c
@@ -125,6 +125,9 @@ main(void)
if((ret = H5Pset_fill_value(dcpl1, H5T_STD_I32BE, &fill)) < 0)
assert(ret > 0);
+ if((ret = H5Pset_dset_no_attrs_hint(dcpl1, FALSE)) < 0)
+ assert(ret > 0);
+
max_size[0] = 100;
if((ret = H5Pset_external(dcpl1, "ext1.data", (off_t)0,
(hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
diff --git a/test/tfile.c b/test/tfile.c
index d3134f8..96e469c 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -7051,6 +7051,144 @@ test_incr_filesize(void)
/****************************************************************
**
+** test_min_dset_ohdr():
+** Test API calls to toggle dataset object header minimization.
+**
+** TODO (as separate function?):
+** + setting persists between close and (re)open?
+** + dataset header sizes created while changing value of toggle
+**
+****************************************************************/
+static void
+test_min_dset_ohdr(void)
+{
+ const char my_filename[] = "some_arbitrary_filename";
+ hid_t file_id = -1;
+ hid_t file2_id = -1;
+ hbool_t minimize;
+
+ MESSAGE(5, ("Testing dataset object header minimization\n"));
+
+ /*********/
+ /* SETUP */
+ /*********/
+
+ file_id = H5Fcreate(
+ my_filename,
+ H5F_ACC_TRUNC,
+ H5P_DEFAULT,
+ H5P_DEFAULT);
+ CHECK_I(file_id, "H5Fcreate");
+
+ /*********/
+ /* TESTS */
+ /*********/
+
+ /*----------------------------------------
+ * TEST default value
+ */
+ VERIFY(H5Fget_dset_no_attrs_hint(file_id, &minimize),
+ SUCCEED,
+ "H5Fget_dset_no_attrs_hint");
+ VERIFY(minimize,
+ FALSE,
+ "getting default dset minimize flag value");
+
+ /*----------------------------------------
+ * TEST set to TRUE
+ */
+ VERIFY(H5Fset_dset_no_attrs_hint(file_id, TRUE),
+ SUCCEED,
+ "H5Fset_dset_no_attrs_hint");
+ VERIFY(H5Fget_dset_no_attrs_hint(file_id, &minimize),
+ SUCCEED,
+ "H5Fget_dset_no_attrs_hint");
+ VERIFY(minimize,
+ TRUE,
+ "getting set-TRUE dset minimize flag value");
+
+ /*----------------------------------------
+ * TEST second file open on same filename
+ */
+ file2_id = H5Fopen(
+ my_filename,
+ H5F_ACC_RDWR,
+ H5P_DEFAULT);
+ CHECK_I(file2_id, "H5Fopen");
+
+ /* verify TRUE setting on second open */
+ VERIFY(H5Fget_dset_no_attrs_hint(file_id, &minimize),
+ SUCCEED,
+ "H5Fget_dset_no_attrs_hint");
+ VERIFY(minimize,
+ TRUE,
+ "getting set-TRUE dset minimize flag value");
+
+ /* re-set to FALSE on first open */
+ VERIFY(H5Fset_dset_no_attrs_hint(file_id, FALSE),
+ SUCCEED,
+ "H5Fset_dset_no_attrs_hint");
+
+ /* verify FALSE set on both opens */
+ VERIFY(H5Fget_dset_no_attrs_hint(file_id, &minimize),
+ SUCCEED,
+ "H5Fget_dset_no_attrs_hint");
+ VERIFY(minimize,
+ FALSE,
+ "getting set-FALSE dset minimize flag value");
+ VERIFY(H5Fget_dset_no_attrs_hint(file2_id, &minimize),
+ SUCCEED,
+ "H5Fget_dset_no_attrs_hint");
+ VERIFY(minimize,
+ FALSE,
+ "getting set-FALSE dset minimize flag value");
+
+ /* re-set to TRUE on second open */
+ VERIFY(H5Fset_dset_no_attrs_hint(file2_id, TRUE),
+ SUCCEED,
+ "H5Fset_dset_no_attrs_hint");
+
+ /* verify TRUE set on both opens */
+ VERIFY(H5Fget_dset_no_attrs_hint(file_id, &minimize),
+ SUCCEED,
+ "H5Fget_dset_no_attrs_hint");
+ VERIFY(minimize,
+ TRUE,
+ "getting set-FALSE dset minimize flag value");
+ VERIFY(H5Fget_dset_no_attrs_hint(file2_id, &minimize),
+ SUCCEED,
+ "H5Fget_dset_no_attrs_hint");
+ VERIFY(minimize,
+ TRUE,
+ "getting set-FALSE dset minimize flag value");
+
+ /*----------------------------------------
+ * TEST error cases
+ */
+ H5E_BEGIN_TRY {
+ VERIFY(H5Fset_dset_no_attrs_hint(-1, TRUE),
+ FAIL,
+ "trying to set with invalid file ID");
+
+ VERIFY(H5Fget_dset_no_attrs_hint(-1, &minimize),
+ FAIL,
+ "trying to get with invalid file ID");
+
+ VERIFY(H5Fget_dset_no_attrs_hint(file_id, NULL),
+ FAIL,
+ "trying to get with invalid pointer");
+ } H5E_END_TRY;
+
+ /************/
+ /* TEARDOWN */
+ /************/
+
+ VERIFY(H5Fclose(file_id), SUCCEED, "H5Fclose");
+ VERIFY(H5Fclose(file2_id), SUCCEED, "H5Fclose");
+} /* end test_min_dset_ohdr() */
+
+/****************************************************************
+**
** test_deprec():
** Test deprecated functionality.
**
@@ -7336,6 +7474,7 @@ test_file(void)
test_libver_macros(); /* Test the macros for library version comparison */
test_libver_macros2(); /* Test the macros for library version comparison */
test_incr_filesize(); /* Test H5Fincrement_filesize() and H5Fget_eoa() */
+ test_min_dset_ohdr(); /* Test datset object header minimization */
#ifndef H5_NO_DEPRECATED_SYMBOLS
test_deprec(); /* Test deprecated routines */
#endif /* H5_NO_DEPRECATED_SYMBOLS */