summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/tmisc.c139
1 files changed, 139 insertions, 0 deletions
diff --git a/test/tmisc.c b/test/tmisc.c
index 0ea9c4c..a555b3e 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -329,6 +329,14 @@ typedef struct
/* and bad offset values are written to that file for testing */
#define MISC33_FILE "bad_offset.h5"
+/* Definitions for misc. test #35 */
+#define MISC35_SPACE_RANK 3
+#define MISC35_SPACE_DIM1 3
+#define MISC35_SPACE_DIM2 15
+#define MISC35_SPACE_DIM3 13
+#define MISC35_NPOINTS 10
+
+
/****************************************************************
**
** test_misc1(): test unlinking a dataset from a group and immediately
@@ -5684,6 +5692,136 @@ test_misc34(void)
/****************************************************************
**
+** test_misc35(): Check operation of free-list routines
+**
+****************************************************************/
+static void
+test_misc35(void)
+{
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hsize_t dims[] = {MISC35_SPACE_DIM1, MISC35_SPACE_DIM2, MISC35_SPACE_DIM3}; /* Dataspace dims */
+ hsize_t coord[MISC35_NPOINTS][MISC35_SPACE_RANK]; /* Coordinates for point selection */
+ size_t reg_size_start; /* Initial amount of regular memory allocated */
+ size_t arr_size_start; /* Initial amount of array memory allocated */
+ size_t blk_size_start; /* Initial amount of block memory allocated */
+ size_t fac_size_start; /* Initial amount of factory memory allocated */
+ size_t reg_size_final; /* Final amount of regular memory allocated */
+ size_t arr_size_final; /* Final amount of array memory allocated */
+ size_t blk_size_final; /* Final amount of block memory allocated */
+ size_t fac_size_final; /* Final amount of factory memory allocated */
+ unsigned long long total_alloc_bytes; /* Running count of total # of bytes allocated */
+ size_t curr_alloc_bytes; /* Current # of bytes allocated */
+ size_t peak_alloc_bytes; /* Peak # of bytes allocated */
+ size_t max_block_size; /* Largest block allocated */
+ size_t total_alloc_blocks_count; /* Running count of total # of blocks allocated */
+ size_t curr_alloc_blocks_count; /* Current # of blocks allocated */
+ size_t peak_alloc_blocks_count; /* Peak # of blocks allocated */
+ herr_t ret; /* Return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Free-list API calls"));
+
+ /* Create dataspace */
+ /* (Allocates array free-list nodes) */
+ sid = H5Screate_simple(MISC35_SPACE_RANK, dims, NULL);
+ CHECK(sid, H5I_INVALID_HID, "H5Screate_simple");
+
+ /* Select sequence of ten points */
+ coord[0][0]=0; coord[0][1]=10; coord[0][2]= 5;
+ coord[1][0]=1; coord[1][1]= 2; coord[1][2]= 7;
+ coord[2][0]=2; coord[2][1]= 4; coord[2][2]= 9;
+ coord[3][0]=0; coord[3][1]= 6; coord[3][2]=11;
+ coord[4][0]=1; coord[4][1]= 8; coord[4][2]=13;
+ coord[5][0]=2; coord[5][1]=12; coord[5][2]= 0;
+ coord[6][0]=0; coord[6][1]=14; coord[6][2]= 2;
+ coord[7][0]=1; coord[7][1]= 0; coord[7][2]= 4;
+ coord[8][0]=2; coord[8][1]= 1; coord[8][2]= 6;
+ coord[9][0]=0; coord[9][1]= 3; coord[9][2]= 8;
+ ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)MISC35_NPOINTS, (const hsize_t *)coord);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ /* Retrieve initial free list values */
+ ret = H5get_free_list_sizes(&reg_size_start, &arr_size_start, &blk_size_start, &fac_size_start);
+ CHECK(ret, FAIL, "H5get_free_list_sizes");
+
+ /* All the free list values should be >0 */
+ if(0 == reg_size_start)
+ ERROR("reg_size_start == 0");
+ if(0 == arr_size_start)
+ ERROR("arr_size_start == 0");
+ if(0 == blk_size_start)
+ ERROR("blk_size_start == 0");
+ if(0 == fac_size_start)
+ ERROR("fac_size_start == 0");
+
+ /* Garbage collect the free lists */
+ ret = H5garbage_collect();
+ CHECK(ret, FAIL, "H5garbage_collect");
+
+ /* Retrieve free list values again */
+ ret = H5get_free_list_sizes(&reg_size_final, &arr_size_final, &blk_size_final, &fac_size_final);
+ CHECK(ret, FAIL, "H5get_free_list_sizes");
+
+ /* All the free list values should be <= previous values */
+ if(reg_size_final > reg_size_start)
+ ERROR("reg_size_final > reg_size_start");
+ if(arr_size_final > arr_size_start)
+ ERROR("arr_size_final > arr_size_start");
+ if(blk_size_final > blk_size_start)
+ ERROR("blk_size_final > blk_size_start");
+ if(fac_size_final > fac_size_start)
+ ERROR("fac_size_final > fac_size_start");
+
+ /* Retrieve memory allocation statistics */
+ ret = H5get_alloc_stats(&total_alloc_bytes, &curr_alloc_bytes,
+ &peak_alloc_bytes, &max_block_size, &total_alloc_blocks_count,
+ &curr_alloc_blocks_count, &peak_alloc_blocks_count);
+ CHECK(ret, FAIL, "H5get_alloc_stats");
+
+#if defined H5_MEMORY_ALLOC_SANITY_CHECK
+ /* All the values should be >0 */
+ if(0 == total_alloc_bytes)
+ ERROR("total_alloc_bytes == 0");
+ if(0 == curr_alloc_bytes)
+ ERROR("curr_alloc_bytes == 0");
+ if(0 == peak_alloc_bytes)
+ ERROR("peak_alloc_bytes == 0");
+ if(0 == max_block_size)
+ ERROR("max_block_size == 0");
+ if(0 == total_alloc_blocks_count)
+ ERROR("total_alloc_blocks_count == 0");
+ if(0 == curr_alloc_blocks_count)
+ ERROR("curr_alloc_blocks_count == 0");
+ if(0 == peak_alloc_blocks_count)
+ ERROR("peak_alloc_blocks_count == 0");
+#else /* H5_MEMORY_ALLOC_SANITY_CHECK */
+ /* All the values should be == 0 */
+ if(0 != total_alloc_bytes)
+ ERROR("total_alloc_bytes != 0");
+ if(0 != curr_alloc_bytes)
+ ERROR("curr_alloc_bytes != 0");
+ if(0 != peak_alloc_bytes)
+ ERROR("peak_alloc_bytes != 0");
+ if(0 != max_block_size)
+ ERROR("max_block_size != 0");
+ if(0 != total_alloc_blocks_count)
+ ERROR("total_alloc_blocks_count != 0");
+ if(0 != curr_alloc_blocks_count)
+ ERROR("curr_alloc_blocks_count != 0");
+ if(0 != peak_alloc_blocks_count)
+ ERROR("peak_alloc_blocks_count != 0");
+#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */
+
+} /* end test_misc35() */
+
+
+/****************************************************************
+**
** test_misc(): Main misc. test routine.
**
****************************************************************/
@@ -5731,6 +5869,7 @@ test_misc(void)
test_misc32(); /* Test filter memory allocation functions */
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_misc() */