summaryrefslogtreecommitdiffstats
path: root/test/gheap.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-03-18 23:36:49 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-03-18 23:36:49 (GMT)
commitf38864920d4e0bc8adaf9a23fd3f775ad90cb3f7 (patch)
treeb5f709e5415db2f1a9287b43565fea826b3018f5 /test/gheap.c
parent4a17aff4085ad6ee265b95730aca3f493056dec8 (diff)
parent7aa4eb1b04014f1ad7e1c857ca6509aeeb6c0ae7 (diff)
downloadhdf5-f38864920d4e0bc8adaf9a23fd3f775ad90cb3f7.zip
hdf5-f38864920d4e0bc8adaf9a23fd3f775ad90cb3f7.tar.gz
hdf5-f38864920d4e0bc8adaf9a23fd3f775ad90cb3f7.tar.bz2
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/hdffv/hdf5 into merge_func_enter_vol
Plus initial steps toward merging API context push into FUNC_ENTER_API* macros
Diffstat (limited to 'test/gheap.c')
-rw-r--r--test/gheap.c377
1 files changed, 188 insertions, 189 deletions
diff --git a/test/gheap.c b/test/gheap.c
index 01ea385..716c34a 100644
--- a/test/gheap.c
+++ b/test/gheap.c
@@ -15,12 +15,11 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Tuesday, March 31, 1998
*
- * Purpose: Tests the global heap. The global heap is the set of all
- * collections but the collections are not related to one
- * another by anything that appears in the file format.
+ * Purpose: Tests the global heap. The global heap is the set of all
+ * collections but the collections are not related to one
+ * another by anything that appears in the file format.
*/
#include "h5test.h"
-#include "H5private.h"
#include "H5ACprivate.h"
#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h"
@@ -57,18 +56,18 @@ const char *FILENAME[] = {
NULL
};
-
+
/*-------------------------------------------------------------------------
- * Function: test_1
+ * Function: test_1
*
- * Purpose: Writes a sequence of objects to the global heap where each
- * object is larger than the one before.
+ * Purpose: Writes a sequence of objects to the global heap where each
+ * object is larger than the one before.
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: number of errors
+ * Failure: number of errors
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, March 31, 1998
*
* Modifications:
@@ -78,16 +77,16 @@ const char *FILENAME[] = {
static int
test_1 (hid_t fapl)
{
- hid_t file = -1;
- H5F_t *f = NULL;
- H5HG_t *obj = NULL;
- uint8_t out[GHEAP_TEST_NOBJS];
- uint8_t in[GHEAP_TEST_NOBJS];
- size_t u;
- size_t size;
- herr_t status;
- int nerrors = 0;
- char filename[1024];
+ hid_t file = -1;
+ H5F_t *f = NULL;
+ H5HG_t *obj = NULL;
+ uint8_t out[GHEAP_TEST_NOBJS];
+ uint8_t in[GHEAP_TEST_NOBJS];
+ size_t u;
+ size_t size;
+ herr_t status;
+ int nerrors = 0;
+ char filename[1024];
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("monotonically increasing lengths");
@@ -103,9 +102,9 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
if(H5CX_push() < 0) FAIL_STACK_ERROR
api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file))) {
- H5_FAILED();
- puts(" Unable to create file");
- goto error;
+ H5_FAILED();
+ puts(" Unable to create file");
+ goto error;
}
/*
@@ -114,37 +113,37 @@ api_ctx_pushed = TRUE;
* be monotonically increasing.
*/
for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
- size = u + 1;
- HDmemset(out, (int)('A' + u % 26), size);
- H5Eclear2(H5E_DEFAULT);
- status = H5HG_insert(f, size, out, obj + u);
- if(status < 0) {
- H5_FAILED();
- puts(" Unable to insert object into global heap");
- nerrors++;
- } else if(u && H5F_addr_gt(obj[u - 1].addr, obj[u].addr)) {
- H5_FAILED();
- puts(" Collection addresses are not monotonically increasing");
- nerrors++;
- }
+ size = u + 1;
+ HDmemset(out, (int)('A' + u % 26), size);
+ H5Eclear2(H5E_DEFAULT);
+ status = H5HG_insert(f, size, out, obj + u);
+ if(status < 0) {
+ H5_FAILED();
+ puts(" Unable to insert object into global heap");
+ nerrors++;
+ } else if(u && H5F_addr_gt(obj[u - 1].addr, obj[u].addr)) {
+ H5_FAILED();
+ puts(" Collection addresses are not monotonically increasing");
+ nerrors++;
+ }
}
/*
* Now try to read each object back.
*/
for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
- size = u + 1;
- HDmemset(out, (int)('A' + u % 26), size);
- H5Eclear2(H5E_DEFAULT);
- if(NULL == H5HG_read(f, obj + u, in, NULL)) {
- H5_FAILED();
- puts(" Unable to read object");
- nerrors++;
- } else if(HDmemcmp(in, out, size)) {
- H5_FAILED();
- puts(" Value read doesn't match value written");
- nerrors++;
- }
+ size = u + 1;
+ HDmemset(out, (int)('A' + u % 26), size);
+ H5Eclear2(H5E_DEFAULT);
+ if(NULL == H5HG_read(f, obj + u, in, NULL)) {
+ H5_FAILED();
+ puts(" Unable to read object");
+ nerrors++;
+ } else if(HDmemcmp(in, out, size)) {
+ H5_FAILED();
+ puts(" Value read doesn't match value written");
+ nerrors++;
+ }
}
/* Release buffer */
@@ -169,18 +168,18 @@ if(api_ctx_pushed) H5CX_pop();
return MAX(1, nerrors);
}
-
+
/*-------------------------------------------------------------------------
- * Function: test_2
+ * Function: test_2
*
- * Purpose: Writes a sequence of objects to the global heap where each
- * object is smaller than the one before.
+ * Purpose: Writes a sequence of objects to the global heap where each
+ * object is smaller than the one before.
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: number of errors
+ * Failure: number of errors
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, March 31, 1998
*
* Modifications:
@@ -190,15 +189,15 @@ if(api_ctx_pushed) H5CX_pop();
static int
test_2 (hid_t fapl)
{
- hid_t file = -1;
- H5F_t *f = NULL;
- H5HG_t *obj = NULL;
- uint8_t out[GHEAP_TEST_NOBJS];
- uint8_t in[GHEAP_TEST_NOBJS];
- size_t u;
- size_t size;
- int nerrors = 0;
- char filename[1024];
+ hid_t file = -1;
+ H5F_t *f = NULL;
+ H5HG_t *obj = NULL;
+ uint8_t out[GHEAP_TEST_NOBJS];
+ uint8_t in[GHEAP_TEST_NOBJS];
+ size_t u;
+ size_t size;
+ int nerrors = 0;
+ char filename[1024];
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("monotonically decreasing lengths");
@@ -214,41 +213,41 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
if(H5CX_push() < 0) FAIL_STACK_ERROR
api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file))) {
- H5_FAILED();
- puts(" Unable to create file");
- goto error;
+ H5_FAILED();
+ puts(" Unable to create file");
+ goto error;
}
/*
* Write the objects, monotonically decreasing in length.
*/
for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
- size = GHEAP_TEST_NOBJS - u;
- HDmemset(out, (int)('A' + u % 26), size);
- H5Eclear2(H5E_DEFAULT);
- if (H5HG_insert (f, size, out, obj + u) < 0) {
- H5_FAILED();
- puts(" Unable to insert object into global heap");
- nerrors++;
- }
+ size = GHEAP_TEST_NOBJS - u;
+ HDmemset(out, (int)('A' + u % 26), size);
+ H5Eclear2(H5E_DEFAULT);
+ if (H5HG_insert (f, size, out, obj + u) < 0) {
+ H5_FAILED();
+ puts(" Unable to insert object into global heap");
+ nerrors++;
+ }
}
/*
* Now try to read each object back.
*/
for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
- size = GHEAP_TEST_NOBJS - u;
- HDmemset(out, (int)('A' + u % 26), size);
- H5Eclear2(H5E_DEFAULT);
- if (NULL==H5HG_read (f, obj + u, in, NULL)) {
- H5_FAILED();
- puts(" Unable to read object");
- nerrors++;
- } else if (memcmp (in, out, size)) {
- H5_FAILED();
- puts(" Value read doesn't match value written");
- nerrors++;
- }
+ size = GHEAP_TEST_NOBJS - u;
+ HDmemset(out, (int)('A' + u % 26), size);
+ H5Eclear2(H5E_DEFAULT);
+ if(NULL == H5HG_read(f, obj + u, in, NULL)) {
+ H5_FAILED();
+ puts(" Unable to read object");
+ nerrors++;
+ } else if (memcmp (in, out, size)) {
+ H5_FAILED();
+ puts(" Value read doesn't match value written");
+ nerrors++;
+ }
}
/* Release buffer */
@@ -273,18 +272,18 @@ if(api_ctx_pushed) H5CX_pop();
return MAX(1, nerrors);
}
-
+
/*-------------------------------------------------------------------------
- * Function: test_3
+ * Function: test_3
*
- * Purpose: Creates a few global heap objects and then removes them all.
- * The collection should also be removed.
+ * Purpose: Creates a few global heap objects and then removes them all.
+ * The collection should also be removed.
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: number of errors
+ * Failure: number of errors
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, March 31, 1998
*
* Modifications:
@@ -294,15 +293,15 @@ if(api_ctx_pushed) H5CX_pop();
static int
test_3 (hid_t fapl)
{
- hid_t file = -1;
- H5F_t *f = NULL;
- H5HG_t *obj = NULL;
- uint8_t out[GHEAP_TEST_NOBJS];
- size_t u;
- size_t size;
- herr_t status;
- int nerrors = 0;
- char filename[1024];
+ hid_t file = -1;
+ H5F_t *f = NULL;
+ H5HG_t *obj = NULL;
+ uint8_t out[GHEAP_TEST_NOBJS];
+ size_t u;
+ size_t size;
+ herr_t status;
+ int nerrors = 0;
+ char filename[1024];
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("complete object removal");
@@ -318,32 +317,32 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
if(H5CX_push() < 0) FAIL_STACK_ERROR
api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file))) {
- H5_FAILED();
- puts(" Unable to create file");
- goto error;
+ H5_FAILED();
+ puts(" Unable to create file");
+ goto error;
}
/* Create some stuff */
for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
- size = u % 30 + 100;
- HDmemset(out, (int)('A' + u % 26), size);
- H5Eclear2(H5E_DEFAULT);
- status = H5HG_insert (f, size, out, obj + u);
- if (status<0) {
- H5_FAILED();
- puts(" Unable to insert object into global heap");
- nerrors++;
- }
+ size = u % 30 + 100;
+ HDmemset(out, (int)('A' + u % 26), size);
+ H5Eclear2(H5E_DEFAULT);
+ status = H5HG_insert(f, size, out, obj + u);
+ if (status<0) {
+ H5_FAILED();
+ puts(" Unable to insert object into global heap");
+ nerrors++;
+ }
}
/* Remove everything */
for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
- status = H5HG_remove (f, obj + u);
- if (status<0) {
- H5_FAILED();
- puts(" Unable to remove object");
- nerrors++;
- }
+ status = H5HG_remove(f, obj + u);
+ if (status<0) {
+ H5_FAILED();
+ puts(" Unable to remove object");
+ nerrors++;
+ }
}
/* Release buffer */
@@ -368,19 +367,19 @@ if(api_ctx_pushed) H5CX_pop();
return MAX(1, nerrors);
}
-
+
/*-------------------------------------------------------------------------
- * Function: test_4
+ * Function: test_4
*
- * Purpose: Tests the H5HG_remove() feature by writing lots of objects
- * and occassionally removing some. When we're done they're all
- * removed.
+ * Purpose: Tests the H5HG_remove() feature by writing lots of objects
+ * and occassionally removing some. When we're done they're all
+ * removed.
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: number of errors
+ * Failure: number of errors
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, March 31, 1998
*
* Modifications:
@@ -390,15 +389,15 @@ if(api_ctx_pushed) H5CX_pop();
static int
test_4 (hid_t fapl)
{
- hid_t file = -1;
- H5F_t *f = NULL;
- H5HG_t *obj = NULL;
- uint8_t out[GHEAP_TEST_NOBJS];
- size_t u;
- size_t size;
- herr_t status;
- int nerrors = 0;
- char filename[1024];
+ hid_t file = -1;
+ H5F_t *f = NULL;
+ H5HG_t *obj = NULL;
+ uint8_t out[GHEAP_TEST_NOBJS];
+ size_t u;
+ size_t size;
+ herr_t status;
+ int nerrors = 0;
+ char filename[1024];
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("partial object removal");
@@ -414,38 +413,38 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
if(H5CX_push() < 0) FAIL_STACK_ERROR
api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file))) {
- H5_FAILED();
- puts(" Unable to create file");
- goto error;
+ H5_FAILED();
+ puts(" Unable to create file");
+ goto error;
}
for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
- /* Insert */
- size = u % 30 + 100;
- HDmemset(out, (int)('A' + u % 26), size);
- H5Eclear2(H5E_DEFAULT);
- status = H5HG_insert (f, size, out, obj + u);
- if (status<0) {
- H5_FAILED();
- puts(" Unable to insert object into global heap");
- nerrors++;
- }
-
- /*
- * Remove every third one beginning with the second, but after the
- * next one has already been inserted. That is, insert A, B, C;
- * remove B, insert D, E, F; remove E; etc.
- */
- if(1 == (u % 3)) {
- H5Eclear2(H5E_DEFAULT);
- status = H5HG_remove (f, obj + u - 1);
- if (status<0) {
- H5_FAILED();
- puts(" Unable to remove object");
- nerrors++;
- }
- HDmemset(obj + u - 1, 0, sizeof *obj);
- }
+ /* Insert */
+ size = u % 30 + 100;
+ HDmemset(out, (int)('A' + u % 26), size);
+ H5Eclear2(H5E_DEFAULT);
+ status = H5HG_insert(f, size, out, obj + u);
+ if (status<0) {
+ H5_FAILED();
+ puts(" Unable to insert object into global heap");
+ nerrors++;
+ }
+
+ /*
+ * Remove every third one beginning with the second, but after the
+ * next one has already been inserted. That is, insert A, B, C;
+ * remove B, insert D, E, F; remove E; etc.
+ */
+ if(1 == (u % 3)) {
+ H5Eclear2(H5E_DEFAULT);
+ status = H5HG_remove(f, obj + u - 1);
+ if (status<0) {
+ H5_FAILED();
+ puts(" Unable to remove object");
+ nerrors++;
+ }
+ HDmemset(obj + u - 1, 0, sizeof *obj);
+ }
}
/* Release buffer */
@@ -470,20 +469,20 @@ if(api_ctx_pushed) H5CX_pop();
return MAX(1, nerrors);
}
-
+
/*-------------------------------------------------------------------------
- * Function: test_ooo_indices
+ * Function: test_ooo_indices
*
- * Purpose: Tests that indices can be stored out of order. This can
+ * Purpose: Tests that indices can be stored out of order. This can
* happen when the indices "wrap around" due to many
* insertions and deletions (for example, from rewriting a
* VL dataset).
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: number of errors
+ * Failure: number of errors
*
- * Programmer: Neil Fortner
+ * Programmer: Neil Fortner
* Monday, October 26, 2009
*
* Modifications:
@@ -493,13 +492,13 @@ if(api_ctx_pushed) H5CX_pop();
static int
test_ooo_indices(hid_t fapl)
{
- hid_t file = -1;
- H5F_t *f = NULL;
- unsigned i, j;
- H5HG_t *obj = NULL;
- herr_t status;
- int nerrors=0;
- char filename[1024];
+ hid_t file = -1;
+ H5F_t *f = NULL;
+ unsigned i, j;
+ H5HG_t *obj = NULL;
+ herr_t status;
+ int nerrors=0;
+ char filename[1024];
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("out of order indices");
@@ -592,17 +591,17 @@ if(api_ctx_pushed) H5CX_pop();
return MAX(1, nerrors);
} /* end test_ooo_indices */
-
+
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Tests global heap.
+ * Purpose: Tests global heap.
*
- * Return: Success: zero
+ * Return: Success: zero
*
- * Failure: non-zero
+ * Failure: non-zero
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, March 31, 1998
*
* Modifications:
@@ -612,8 +611,8 @@ if(api_ctx_pushed) H5CX_pop();
int
main (void)
{
- int nerrors=0;
- hid_t fapl;
+ int nerrors=0;
+ hid_t fapl;
h5_reset();
fapl = h5_fileaccess();