From 1a4e315a5dac7b85f4862118fa770f80fe369739 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 8 Feb 2016 20:38:44 -0500 Subject: [svn-r29069] test/gheap cleanup prior to stack size fixes. Tested on: Linux VM (minor changes) --- test/gheap.c | 591 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 285 insertions(+), 306 deletions(-) diff --git a/test/gheap.c b/test/gheap.c index fa73dcb..c8b27fb 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -55,90 +55,91 @@ const char *FILENAME[] = { NULL }; +/* Number of heap objects in tests */ +#define N_GHEAP_OBJS 1024 + +/* Size of heap object buffers */ +#define OBJ_BUF_SIZE N_GHEAP_OBJS + +/* Size of filename */ +#define FILENAME_SIZE 1024 + /*------------------------------------------------------------------------- - * Function: test_1 + * Function: test_monotonic_increasing * - * 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: - * *------------------------------------------------------------------------- */ static int -test_1 (hid_t fapl) +test_monotonic_increasing(hid_t fapl) { - hid_t file = -1; - H5F_t *f = NULL; - H5HG_t obj[1024]; - uint8_t out[1024]; - uint8_t in[1024]; - int i; - size_t size; - herr_t status; - int nerrors = 0; - char filename[1024]; + hid_t fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t obj[N_GHEAP_OBJS]; /* global heap objects */ + uint8_t in[OBJ_BUF_SIZE]; /* global heap data sent */ + uint8_t out[OBJ_BUF_SIZE]; /* global heap data received */ + unsigned i; /* iterator */ + size_t size; /* heap object size */ + int nerrors = 0; /* # of errors encountered */ + char filename[FILENAME_SIZE]; /* VFD-dependent filename */ TESTING("monotonically increasing lengths"); /* Open a clean file */ - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { - H5_FAILED(); - puts(" Unable to create file"); - goto error; - } - - /* - * Write the objects, monotonically increasing in length. Since this is + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + if(NULL == (f = (H5F_t *)H5I_object(fid))) { + H5_FAILED(); + HDputs(" Unable to create file"); + goto error; + } /* end if */ + + /* Write the objects, monotonically increasing in length. Since this is * a clean file, the addresses allocated for the collections should also * be monotonically increasing. */ - for(i = 0; i < 1024; i++) { - size = i + 1; - HDmemset(out, 'A' + i % 26, size); - H5Eclear2(H5E_DEFAULT); - status = H5HG_insert(f, H5AC_dxpl_id, size, out, obj + i); - if(status < 0) { - H5_FAILED(); - puts(" Unable to insert object into global heap"); - nerrors++; - } else if(i && H5F_addr_gt(obj[i - 1].addr, obj[i].addr)) { - H5_FAILED(); - puts(" Collection addresses are not monotonically increasing"); - nerrors++; - } - } - - /* - * Now try to read each object back. - */ - for(i = 0; i < 1024; i++) { - size = i + 1; - HDmemset(out, 'A' + i % 26, size); - H5Eclear2(H5E_DEFAULT); - if(NULL == H5HG_read(f, H5AC_dxpl_id, obj + i, 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++; - } - } - - if(H5Fclose(file) < 0) goto error; + for(i = 0; i < N_GHEAP_OBJS; i++) { + size = i + 1; + HDmemset(out, 'A' + (int)i % 26, size); + H5Eclear2(H5E_DEFAULT); + if(H5HG_insert(f, H5AC_dxpl_id, size, out, obj + i) < 0) { + H5_FAILED(); + HDputs(" Unable to insert object into global heap"); + nerrors++; + } else if(i && H5F_addr_gt(obj[i - 1].addr, obj[i].addr)) { + H5_FAILED(); + HDputs(" Collection addresses are not monotonically increasing"); + nerrors++; + } /* end if */ + } /* end for */ + + /* Now try to read each object back. */ + for(i = 0; i < N_GHEAP_OBJS; i++) { + size = i + 1; + HDmemset(out, 'A' + (int)i % 26, size); + H5Eclear2(H5E_DEFAULT); + if(NULL == H5HG_read(f, H5AC_dxpl_id, obj + i, in, NULL)) { + H5_FAILED(); + HDputs(" Unable to read object"); + nerrors++; + } else if(HDmemcmp(in, out, size)) { + H5_FAILED(); + HDputs(" Value read doesn't match value written"); + nerrors++; + } /* end if */ + } /* end for */ + + if(H5Fclose(fid) < 0) goto error; if(nerrors) goto error; PASSED(); @@ -146,291 +147,270 @@ test_1 (hid_t fapl) error: H5E_BEGIN_TRY { - H5Fclose(file); + H5Fclose(fid); } H5E_END_TRY; return MAX(1, nerrors); -} +} /* end test_monotonic_increasing() */ /*------------------------------------------------------------------------- - * Function: test_2 - * - * Purpose: Writes a sequence of objects to the global heap where each - * object is smaller than the one before. + * Function: test_monotonic_decreasing * - * Return: Success: 0 + * Purpose: Writes a sequence of objects to the global heap where each + * object is smaller than the one before. * - * Failure: number of errors + * Return: Success: 0 + * Failure: number of errors * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, March 31, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static int -test_2 (hid_t fapl) +test_monotonic_decreasing(hid_t fapl) { - hid_t file = -1; - H5F_t *f = NULL; - H5HG_t obj[1024]; - uint8_t out[1024]; - uint8_t in[1024]; - int i; - size_t size; - int nerrors = 0; - char filename[1024]; + hid_t fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t obj[N_GHEAP_OBJS]; /* global heap objects */ + uint8_t in[OBJ_BUF_SIZE]; /* global heap data sent */ + uint8_t out[OBJ_BUF_SIZE]; /* global heap data received */ + unsigned i; /* iterator */ + size_t size; /* heap object size */ + int nerrors = 0; /* # of errors encountered */ + char filename[FILENAME_SIZE]; /* VFD-dependent filename */ TESTING("monotonically decreasing lengths"); /* Open a clean file */ - h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { - H5_FAILED(); - puts(" Unable to create file"); - goto error; - } - - /* - * Write the objects, monotonically decreasing in length. - */ - for (i=0; i<1024; i++) { - size = 1024-i; - memset (out, 'A'+i%26, size); - H5Eclear2(H5E_DEFAULT); - if (H5HG_insert (f, H5AC_dxpl_id, size, out, obj+i)<0) { - H5_FAILED(); - puts(" Unable to insert object into global heap"); - nerrors++; - } - } - - /* - * Now try to read each object back. - */ - for (i=0; i<1024; i++) { - size = 1024-i; - memset (out, 'A'+i%26, size); - H5Eclear2(H5E_DEFAULT); - if (NULL==H5HG_read (f, H5AC_dxpl_id, obj+i, 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++; - } - } - - if (H5Fclose(file)<0) goto error; - if (nerrors) goto error; + h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + if(NULL == (f = (H5F_t *)H5I_object(fid))) { + H5_FAILED(); + HDputs(" Unable to create file"); + goto error; + } /* end if */ + + /* Write the objects, monotonically decreasing in length. */ + for(i = 0; i < N_GHEAP_OBJS; i++) { + size = 1024 - i; + HDmemset(out, 'A' + (int)i % 26, size); + H5Eclear2(H5E_DEFAULT); + if(H5HG_insert(f, H5AC_dxpl_id, size, out, obj+i) < 0) { + H5_FAILED(); + HDputs(" Unable to insert object into global heap"); + nerrors++; + } /* end if */ + } /* end for */ + + /* Now try to read each object back. */ + for(i = 0; i < N_GHEAP_OBJS; i++) { + size = OBJ_BUF_SIZE - i; + HDmemset(out, 'A' + (int)i % 26, size); + H5Eclear2(H5E_DEFAULT); + if(NULL == H5HG_read(f, H5AC_dxpl_id, obj+i, in, NULL)) { + H5_FAILED(); + HDputs(" Unable to read object"); + nerrors++; + } else if (HDmemcmp(in, out, size)) { + H5_FAILED(); + HDputs(" Value read doesn't match value written"); + nerrors++; + } /* end if */ + } /* end for */ + + if(H5Fclose(fid) < 0) goto error; + if(nerrors) goto error; PASSED(); return 0; error: H5E_BEGIN_TRY { - H5Fclose(file); + H5Fclose(fid); } H5E_END_TRY; return MAX(1, nerrors); -} +} /* end test_monotonic_decreasing() */ /*------------------------------------------------------------------------- - * Function: test_3 - * - * Purpose: Creates a few global heap objects and then removes them all. - * The collection should also be removed. + * Function: test_complete_removal * - * Return: Success: 0 + * Purpose: Creates a few global heap objects and then removes them all. + * The collection should also be removed. * - * Failure: number of errors + * Return: Success: 0 + * Failure: number of errors * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, March 31, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static int -test_3 (hid_t fapl) +test_complete_removal(hid_t fapl) { - hid_t file = -1; - H5F_t *f = NULL; - H5HG_t obj[1024]; - uint8_t out[1024]; - int i; - size_t size; - herr_t status; - int nerrors = 0; - char filename[1024]; + hid_t fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t obj[N_GHEAP_OBJS]; /* global heap objects */ + uint8_t out[OBJ_BUF_SIZE]; /* global heap data received */ + unsigned i; /* iterator */ + size_t size; /* heap object size */ + int nerrors = 0; /* # of errors encountered */ + char filename[FILENAME_SIZE]; /* VFD-dependent filename */ TESTING("complete object removal"); /* Open a clean file */ - h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { - H5_FAILED(); - puts(" Unable to create file"); - goto error; - } + h5_fixname(FILENAME[2], fapl, filename, sizeof(filename)); + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + if(NULL == (f = (H5F_t *)H5I_object(fid))) { + H5_FAILED(); + HDputs(" Unable to create file"); + goto error; + } /* end if */ /* Create some stuff */ - for (i=0; i<1024; i++) { - size = i%30+100; - memset (out, 'A'+i%26, size); - H5Eclear2(H5E_DEFAULT); - status = H5HG_insert (f, H5AC_dxpl_id, size, out, obj+i); - if (status<0) { - H5_FAILED(); - puts(" Unable to insert object into global heap"); - nerrors++; - } - } + for(i=0; i < N_GHEAP_OBJS; i++) { + size = i % 30 + 100; + HDmemset(out, 'A' + (int)i % 26, size); + H5Eclear2(H5E_DEFAULT); + if(H5HG_insert(f, H5AC_dxpl_id, size, out, obj+i) < 0) { + H5_FAILED(); + HDputs(" Unable to insert object into global heap"); + nerrors++; + } /* end if */ + } /* end for */ /* Remove everything */ - for (i=0; i<1024; i++) { - status = H5HG_remove (f, H5AC_dxpl_id, obj+i); - if (status<0) { - H5_FAILED(); - puts(" Unable to remove object"); - nerrors++; - } - } - - if (H5Fclose(file)<0) goto error; - if (nerrors) goto error; + for(i = 0; i < N_GHEAP_OBJS; i++) { + if(H5HG_remove(f, H5AC_dxpl_id, obj+i) < 0) { + H5_FAILED(); + HDputs(" Unable to remove object"); + nerrors++; + } /* end if */ + } /* end for */ + + if(H5Fclose(fid) < 0) goto error; + if(nerrors) goto error; + PASSED(); return 0; error: H5E_BEGIN_TRY { - H5Fclose(file); + H5Fclose(fid); } H5E_END_TRY; return MAX(1, nerrors); -} +} /* end test_complete_removal() */ /*------------------------------------------------------------------------- - * Function: test_4 + * Function: test_partial_removal * - * 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: - * *------------------------------------------------------------------------- */ static int -test_4 (hid_t fapl) +test_partial_removal(hid_t fapl) { - hid_t file = -1; - H5F_t *f = NULL; - H5HG_t obj[1024]; - uint8_t out[1024]; - int i; - size_t size; - herr_t status; - int nerrors = 0; - char filename[1024]; + hid_t fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t obj[N_GHEAP_OBJS]; /* global heap objects */ + uint8_t out[OBJ_BUF_SIZE]; /* global heap data received */ + unsigned i; /* iterator */ + size_t size; /* heap object size */ + int nerrors = 0; /* # of errors encountered */ + char filename[FILENAME_SIZE]; /* VFD-dependent filename */ TESTING("partial object removal"); /* Open a clean file */ - h5_fixname(FILENAME[3], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { - H5_FAILED(); - puts(" Unable to create file"); - goto error; - } - - for (i=0; i<1024; i++) { - /* Insert */ - size = i%30+100; - memset (out, 'A'+i%26, size); - H5Eclear2(H5E_DEFAULT); - status = H5HG_insert (f, H5AC_dxpl_id, size, out, obj+i); - 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==i%3) { - H5Eclear2(H5E_DEFAULT); - status = H5HG_remove (f, H5AC_dxpl_id, obj+i-1); - if (status<0) { - H5_FAILED(); - puts(" Unable to remove object"); - nerrors++; - } - memset (obj+i-1, 0, sizeof *obj); - } - } - - if (H5Fclose(file)<0) goto error; - if (nerrors) goto error; + h5_fixname(FILENAME[3], fapl, filename, sizeof(filename)); + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + if(NULL == (f = (H5F_t *)H5I_object(fid))) { + H5_FAILED(); + HDputs(" Unable to create file"); + goto error; + } /* end if */ + + for(i = 0; i < N_GHEAP_OBJS; i++) { + + /* Insert */ + size = i % 30 + 100; + HDmemset(out, 'A' + (int)i % 26, size); + H5Eclear2(H5E_DEFAULT); + if(H5HG_insert(f, H5AC_dxpl_id, size, out, obj+i) < 0) { + H5_FAILED(); + HDputs(" Unable to insert object into global heap"); + nerrors++; + } /* end if */ + + /* 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 == i % 3) { + H5Eclear2(H5E_DEFAULT); + if(H5HG_remove(f, H5AC_dxpl_id, obj+i-1) < 0) { + H5_FAILED(); + HDputs(" Unable to remove object"); + nerrors++; + } /* end if */ + HDmemset(obj+i-1, 0, sizeof(*obj)); + } /* end if */ + } /* end for */ + + if(H5Fclose(fid) < 0) goto error; + if(nerrors) goto error; + PASSED(); return 0; error: H5E_BEGIN_TRY { - H5Fclose(file); + H5Fclose(fid); } H5E_END_TRY; return MAX(1, nerrors); -} +} /* end test_partial_removal() */ /*------------------------------------------------------------------------- - * 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: - * *------------------------------------------------------------------------- */ 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 fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t *obj = NULL; /* global heap objects */ + unsigned i, j; /* iterators */ + int nerrors = 0; /* # of errors encountered */ + char filename[FILENAME_SIZE]; /* VFD-dependent filename */ TESTING("out of order indices"); @@ -438,25 +418,27 @@ test_ooo_indices(hid_t fapl) goto error; /* Open a clean file */ - h5_fixname(FILENAME[4], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5I_object(fid))) { H5_FAILED(); - puts(" Unable to create file"); + HDputs(" Unable to create file"); goto error; } /* end if */ /* Alternately insert 1000 entries and remove the previous group of 1000 - * entries, until the indices wrap around */ - for(i=0; i<66; i++) { + * entries, until the indices wrap around. + */ + for(i = 0; i < 66; i++) { + /* Insert 1000 entries. The index into the obj array will alternate up * and down by 1000 so the previous set of insertions is preserved and - * can be deleted. */ - for(j=1000*((~i&1)); j<1000*((~i&1)+1); j++) { + * can be deleted. + */ + for(j = 1000 * ((~i & 1)); j < 1000 * ((~i & 1) + 1); j++) { H5Eclear2(H5E_DEFAULT); - status = H5HG_insert(f, H5AC_dxpl_id, sizeof(j), &j, &obj[j]); - if (status<0) + if(H5HG_insert(f, H5AC_dxpl_id, sizeof(j), &j, &obj[j]) < 0) GHEAP_REPEATED_ERR(" Unable to insert object into global heap") /* Check that the index is as expected */ @@ -465,11 +447,10 @@ test_ooo_indices(hid_t fapl) } /* end for */ /* Remove the previous 1000 entries */ - if(i>0) - for(j=1000*(i&1); j<1000*((i&1)+1); j++) { + if(i > 0) + for(j = 1000 * (i & 1); j < 1000 * ((i & 1) + 1); j++) { H5Eclear2(H5E_DEFAULT); - status = H5HG_remove(f, H5AC_dxpl_id, &obj[j]); - if (status<0) + if(H5HG_remove(f, H5AC_dxpl_id, &obj[j]) < 0) GHEAP_REPEATED_ERR(" Unable to remove object from global heap"); } /* end for */ } /* end for */ @@ -479,36 +460,37 @@ test_ooo_indices(hid_t fapl) HDassert(obj[535].idx == 1); /* Reopen the file */ - if (H5Fclose(file)<0) goto error; - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if(H5Fclose(fid) < 0) goto error; + if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5I_object(fid))) { H5_FAILED(); - puts(" Unable to open file"); + HDputs(" Unable to open file"); goto error; } /* end if */ /* Read the objects to make sure the heap is still readable */ - for(i=0; i<1000; i++) { + for(i = 0; i < 1000; i++) { if(NULL == H5HG_read(f, H5AC_dxpl_id, &obj[i], &j, NULL)) goto error; if(i != j) { H5_FAILED(); - puts(" Incorrect read value"); + HDputs(" Incorrect read value"); goto error; } /* end if */ } /* end for */ - if (H5Fclose(file)<0) goto error; - if (nerrors) goto error; + if(H5Fclose(fid) < 0) goto error; + if(nerrors) goto error; + HDfree(obj); obj = NULL; PASSED(); return 0; - error: +error: H5E_BEGIN_TRY { - H5Fclose(file); + H5Fclose(fid); } H5E_END_TRY; if(obj) HDfree(obj); @@ -517,46 +499,43 @@ test_ooo_indices(hid_t fapl) /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: Tests global heap. + * Purpose: Tests global heap * - * Return: Success: zero + * Return: EXIT_SUCCESS/EXIT_FAILURE * - * Failure: non-zero - * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, March 31, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ int -main (void) +main(void) { - int nerrors=0; - hid_t fapl; + int nerrors = 0; /* # of errors */ + hid_t fapl = -1; /* VFD-dependent fapl ID */ h5_reset(); fapl = h5_fileaccess(); - nerrors += test_1(fapl); - nerrors += test_2(fapl); - nerrors += test_3(fapl); - nerrors += test_4(fapl); + nerrors += test_monotonic_increasing(fapl); + nerrors += test_monotonic_decreasing(fapl); + nerrors += test_complete_removal(fapl); + nerrors += test_partial_removal(fapl); nerrors += test_ooo_indices(fapl); /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if (nerrors) goto error; + if(nerrors) goto error; - puts("All global heap tests passed."); + HDputs("All global heap tests passed."); h5_cleanup(FILENAME, fapl); - return 0; + return EXIT_SUCCESS; + +error: + HDputs("*** TESTS FAILED ***"); + return EXIT_FAILURE; +} /* end main() */ - error: - puts("*** TESTS FAILED ***"); - return 1; -} -- cgit v0.12 From be36958b77eedde1b016bd7e98eafe589541e7fc Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 8 Feb 2016 23:18:53 -0500 Subject: [svn-r29072] test/gheap stack size cleanup. Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial autotools (also w/ Valgrind) --- test/Makefile.am | 2 +- test/gheap.c | 171 ++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 131 insertions(+), 42 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index c3761b7..667c0e7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -129,7 +129,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \ copy_dcpl_newfile.h5 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-4].h5 extern_[1-4][rw].raw gheap[0-4].h5 \ + stab.h5 extern_[1-4].h5 extern_[1-4][rw].raw gheap[0-5].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/gheap.c b/test/gheap.c index c8b27fb..a296feb 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -51,7 +51,7 @@ const char *FILENAME[] = { "gheap2", "gheap3", "gheap4", - "gheapooo", + "gheap5", NULL }; @@ -82,18 +82,28 @@ const char *FILENAME[] = { static int test_monotonic_increasing(hid_t fapl) { - hid_t fid = -1; /* HDF5 file ID */ - H5F_t *f = NULL; /* file object pointer */ - H5HG_t obj[N_GHEAP_OBJS]; /* global heap objects */ - uint8_t in[OBJ_BUF_SIZE]; /* global heap data sent */ - uint8_t out[OBJ_BUF_SIZE]; /* global heap data received */ + char *filename = NULL; /* VFD-dependent filename */ + hid_t fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t *obj = NULL; /* global heap objects */ + uint8_t *in = NULL; /* global heap data sent */ + uint8_t *out = NULL; /* global heap data received */ unsigned i; /* iterator */ - size_t size; /* heap object size */ - int nerrors = 0; /* # of errors encountered */ - char filename[FILENAME_SIZE]; /* VFD-dependent filename */ + size_t size; /* heap object size */ + int nerrors = 0; /* # of errors encountered */ TESTING("monotonically increasing lengths"); + /* allocate memory */ + if(NULL == (filename = (char *)HDcalloc(FILENAME_SIZE, sizeof(char)))) + goto error; + if(NULL == (obj = (H5HG_t *)HDcalloc(N_GHEAP_OBJS, sizeof(H5HG_t)))) + goto error; + if(NULL == (in = (uint8_t *)HDcalloc(OBJ_BUF_SIZE, sizeof(uint8_t)))) + goto error; + if(NULL == (out = (uint8_t *)HDcalloc(OBJ_BUF_SIZE, sizeof(uint8_t)))) + goto error; + /* Open a clean file */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) @@ -142,6 +152,11 @@ test_monotonic_increasing(hid_t fapl) if(H5Fclose(fid) < 0) goto error; if(nerrors) goto error; + HDfree(filename); + HDfree(obj); + HDfree(in); + HDfree(out); + PASSED(); return 0; @@ -149,6 +164,14 @@ error: H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; + if(filename) + HDfree(filename); + if(obj) + HDfree(obj); + if(in) + HDfree(in); + if(out) + HDfree(out); return MAX(1, nerrors); } /* end test_monotonic_increasing() */ @@ -170,18 +193,28 @@ error: static int test_monotonic_decreasing(hid_t fapl) { - hid_t fid = -1; /* HDF5 file ID */ - H5F_t *f = NULL; /* file object pointer */ - H5HG_t obj[N_GHEAP_OBJS]; /* global heap objects */ - uint8_t in[OBJ_BUF_SIZE]; /* global heap data sent */ - uint8_t out[OBJ_BUF_SIZE]; /* global heap data received */ + char *filename = NULL; /* VFD-dependent filename */ + hid_t fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t *obj = NULL; /* global heap objects */ + uint8_t *in = NULL; /* global heap data sent */ + uint8_t *out = NULL; /* global heap data received */ unsigned i; /* iterator */ - size_t size; /* heap object size */ - int nerrors = 0; /* # of errors encountered */ - char filename[FILENAME_SIZE]; /* VFD-dependent filename */ + size_t size; /* heap object size */ + int nerrors = 0; /* # of errors encountered */ TESTING("monotonically decreasing lengths"); + /* allocate memory */ + if(NULL == (filename = (char *)HDcalloc(FILENAME_SIZE, sizeof(char)))) + goto error; + if(NULL == (obj = (H5HG_t *)HDcalloc(N_GHEAP_OBJS, sizeof(H5HG_t)))) + goto error; + if(NULL == (in = (uint8_t *)HDcalloc(OBJ_BUF_SIZE, sizeof(uint8_t)))) + goto error; + if(NULL == (out = (uint8_t *)HDcalloc(OBJ_BUF_SIZE, sizeof(uint8_t)))) + goto error; + /* Open a clean file */ h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) @@ -194,7 +227,7 @@ test_monotonic_decreasing(hid_t fapl) /* Write the objects, monotonically decreasing in length. */ for(i = 0; i < N_GHEAP_OBJS; i++) { - size = 1024 - i; + size = N_GHEAP_OBJS - i; HDmemset(out, 'A' + (int)i % 26, size); H5Eclear2(H5E_DEFAULT); if(H5HG_insert(f, H5AC_dxpl_id, size, out, obj+i) < 0) { @@ -206,7 +239,7 @@ test_monotonic_decreasing(hid_t fapl) /* Now try to read each object back. */ for(i = 0; i < N_GHEAP_OBJS; i++) { - size = OBJ_BUF_SIZE - i; + size = N_GHEAP_OBJS - i; HDmemset(out, 'A' + (int)i % 26, size); H5Eclear2(H5E_DEFAULT); if(NULL == H5HG_read(f, H5AC_dxpl_id, obj+i, in, NULL)) { @@ -222,6 +255,12 @@ test_monotonic_decreasing(hid_t fapl) if(H5Fclose(fid) < 0) goto error; if(nerrors) goto error; + + HDfree(filename); + HDfree(obj); + HDfree(in); + HDfree(out); + PASSED(); return 0; @@ -229,6 +268,14 @@ test_monotonic_decreasing(hid_t fapl) H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; + if(filename) + HDfree(filename); + if(obj) + HDfree(obj); + if(in) + HDfree(in); + if(out) + HDfree(out); return MAX(1, nerrors); } /* end test_monotonic_decreasing() */ @@ -250,17 +297,25 @@ test_monotonic_decreasing(hid_t fapl) static int test_complete_removal(hid_t fapl) { - hid_t fid = -1; /* HDF5 file ID */ - H5F_t *f = NULL; /* file object pointer */ - H5HG_t obj[N_GHEAP_OBJS]; /* global heap objects */ - uint8_t out[OBJ_BUF_SIZE]; /* global heap data received */ + char *filename = NULL; /* VFD-dependent filename */ + hid_t fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t *obj = NULL; /* global heap objects */ + uint8_t *out = NULL; /* global heap data received */ unsigned i; /* iterator */ - size_t size; /* heap object size */ - int nerrors = 0; /* # of errors encountered */ - char filename[FILENAME_SIZE]; /* VFD-dependent filename */ + size_t size; /* heap object size */ + int nerrors = 0; /* # of errors encountered */ TESTING("complete object removal"); + /* allocate memory */ + if(NULL == (filename = (char *)HDcalloc(FILENAME_SIZE, sizeof(char)))) + goto error; + if(NULL == (obj = (H5HG_t *)HDcalloc(N_GHEAP_OBJS, sizeof(H5HG_t)))) + goto error; + if(NULL == (out = (uint8_t *)HDcalloc(OBJ_BUF_SIZE, sizeof(uint8_t)))) + goto error; + /* Open a clean file */ h5_fixname(FILENAME[2], fapl, filename, sizeof(filename)); if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) @@ -272,7 +327,7 @@ test_complete_removal(hid_t fapl) } /* end if */ /* Create some stuff */ - for(i=0; i < N_GHEAP_OBJS; i++) { + for(i = 0; i < N_GHEAP_OBJS; i++) { size = i % 30 + 100; HDmemset(out, 'A' + (int)i % 26, size); H5Eclear2(H5E_DEFAULT); @@ -295,6 +350,10 @@ test_complete_removal(hid_t fapl) if(H5Fclose(fid) < 0) goto error; if(nerrors) goto error; + HDfree(filename); + HDfree(obj); + HDfree(out); + PASSED(); return 0; @@ -302,6 +361,12 @@ test_complete_removal(hid_t fapl) H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; + if(filename) + HDfree(filename); + if(obj) + HDfree(obj); + if(out) + HDfree(out); return MAX(1, nerrors); } /* end test_complete_removal() */ @@ -324,17 +389,25 @@ test_complete_removal(hid_t fapl) static int test_partial_removal(hid_t fapl) { - hid_t fid = -1; /* HDF5 file ID */ - H5F_t *f = NULL; /* file object pointer */ - H5HG_t obj[N_GHEAP_OBJS]; /* global heap objects */ - uint8_t out[OBJ_BUF_SIZE]; /* global heap data received */ + char *filename = NULL; /* VFD-dependent filename */ + hid_t fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t *obj = NULL; /* global heap objects */ + uint8_t *out = NULL; /* global heap data received */ unsigned i; /* iterator */ - size_t size; /* heap object size */ - int nerrors = 0; /* # of errors encountered */ - char filename[FILENAME_SIZE]; /* VFD-dependent filename */ + size_t size; /* heap object size */ + int nerrors = 0; /* # of errors encountered */ TESTING("partial object removal"); + /* allocate memory */ + if(NULL == (filename = (char *)HDcalloc(FILENAME_SIZE, sizeof(char)))) + goto error; + if(NULL == (obj = (H5HG_t *)HDcalloc(N_GHEAP_OBJS, sizeof(H5HG_t)))) + goto error; + if(NULL == (out = (uint8_t *)HDcalloc(OBJ_BUF_SIZE, sizeof(uint8_t)))) + goto error; + /* Open a clean file */ h5_fixname(FILENAME[3], fapl, filename, sizeof(filename)); if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) @@ -375,6 +448,10 @@ test_partial_removal(hid_t fapl) if(H5Fclose(fid) < 0) goto error; if(nerrors) goto error; + HDfree(filename); + HDfree(obj); + HDfree(out); + PASSED(); return 0; @@ -382,6 +459,12 @@ test_partial_removal(hid_t fapl) H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; + if(filename) + HDfree(filename); + if(obj) + HDfree(obj); + if(out) + HDfree(out); return MAX(1, nerrors); } /* end test_partial_removal() */ @@ -405,15 +488,18 @@ test_partial_removal(hid_t fapl) static int test_ooo_indices(hid_t fapl) { - hid_t fid = -1; /* HDF5 file ID */ - H5F_t *f = NULL; /* file object pointer */ - H5HG_t *obj = NULL; /* global heap objects */ - unsigned i, j; /* iterators */ - int nerrors = 0; /* # of errors encountered */ - char filename[FILENAME_SIZE]; /* VFD-dependent filename */ + char *filename = NULL; /* VFD-dependent filename */ + hid_t fid = -1; /* HDF5 file ID */ + H5F_t *f = NULL; /* file object pointer */ + H5HG_t *obj = NULL; /* global heap objects */ + unsigned i, j; /* iterators */ + int nerrors = 0; /* # of errors encountered */ TESTING("out of order indices"); + /* allocate memory */ + if(NULL == (filename = (char *)HDcalloc(FILENAME_SIZE, sizeof(char)))) + goto error; if(NULL == (obj = (H5HG_t *)HDmalloc(2000 * sizeof(*obj)))) goto error; @@ -483,8 +569,9 @@ test_ooo_indices(hid_t fapl) if(H5Fclose(fid) < 0) goto error; if(nerrors) goto error; + HDfree(filename); HDfree(obj); - obj = NULL; + PASSED(); return 0; @@ -492,6 +579,8 @@ error: H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; + if(filename) + HDfree(filename); if(obj) HDfree(obj); return MAX(1, nerrors); -- cgit v0.12 From 745513e2b039515ccec52397cf7d1d807890bc9e Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Tue, 9 Feb 2016 11:51:28 -0500 Subject: [svn-r29074] fixed integer type for H5Sget_simple_extent_ndims_f argument --- fortran/src/H5Sff.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran/src/H5Sff.F90 b/fortran/src/H5Sff.F90 index e9b9b73..cb1388e 100644 --- a/fortran/src/H5Sff.F90 +++ b/fortran/src/H5Sff.F90 @@ -1784,7 +1784,7 @@ CONTAINS INTEGER, INTENT(OUT) :: hdferr !***** TYPE(C_PTR) :: start_c, stride_c, count_c, block_c - INTEGER(C_INT) :: n + INTEGER :: n INTERFACE INTEGER FUNCTION h5sget_regular_hyperslab(space_id, start, stride, count, block) BIND(C,NAME='H5Sget_regular_hyperslab') -- cgit v0.12 From 4da0790886dd7f52d9bd01ef5d9191f7ff729b3e Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 10 Feb 2016 12:54:15 -0500 Subject: [svn-r29076] Description: Normalize against the phdf5_metadata_opt branch, in preparation for merging it to trunk. Tested on: MacOSX/64 10.11.3 (amazon) w/serial, parallel, and production builds h5committest forthcoming --- src/H5ACprivate.h | 4 ++-- src/H5Cmpio.c | 24 ++++++++++++------------ src/H5Ddeprec.c | 4 +--- src/H5L.c | 2 +- src/H5Lexternal.c | 25 +++++++++++++++---------- src/H5O.c | 12 ++++++++---- src/H5Ocopy.c | 7 ++++--- src/H5Oprivate.h | 2 +- src/H5Pdxpl.c | 3 ++- src/H5Pint.c | 30 +++++++++++++++++++----------- src/H5R.c | 13 ++++++------- 11 files changed, 71 insertions(+), 55 deletions(-) diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index f441854..0231aa0 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -198,11 +198,11 @@ typedef H5C_t H5AC_t; H5_DLLVAR hid_t H5AC_dxpl_id; /* DXPL to be used in operations that will not result in I/O calls */ -extern hid_t H5AC_noio_dxpl_id; +H5_DLLVAR hid_t H5AC_noio_dxpl_id; /* DXPL to be used for raw data I/O operations when one is not provided by the user (fill values in H5Dcreate) */ -extern hid_t H5AC_rawdata_dxpl_id; +H5_DLLVAR hid_t H5AC_rawdata_dxpl_id; /* Default cache configuration. */ diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index 6e8d94c..44733c0 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -434,7 +434,7 @@ H5C_apply_candidate_list(H5F_t * f, */ if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't clear entry.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") } /* end if */ /* Else, if this process needs to flush this entry. */ @@ -479,7 +479,7 @@ H5C_apply_candidate_list(H5F_t * f, cache_ptr->last_entry_removed_ptr = NULL; if(H5C__flush_single_entry(f, dxpl_id, flush_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't flush entry.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry.") if ( ( cache_ptr->entries_removed_counter > 1 ) || ( cache_ptr->last_entry_removed_ptr == entry_ptr ) ) @@ -632,12 +632,12 @@ H5C_apply_candidate_list(H5F_t * f, entries_cleared++; #if ( H5C_APPLY_CANDIDATE_LIST__DEBUG > 1 ) - HDfprintf(stdout, "%s:%d: clearing 0x%llx.\n", FUNC, mpi_rank, - (long long)clear_ptr->addr); + HDfprintf(stdout, "%s:%d: clearing 0x%llx.\n", FUNC, mpi_rank, + (long long)clear_ptr->addr); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't clear entry.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") } /* end else-if */ /* Else, if this process needs to independently flush this entry. */ @@ -653,7 +653,7 @@ H5C_apply_candidate_list(H5F_t * f, #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ if(H5C__flush_single_entry(f, dxpl_id, flush_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't clear entry.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") } /* end else-if */ } /* end if */ @@ -694,7 +694,7 @@ H5C_apply_candidate_list(H5F_t * f, } /* end if */ if(H5C__flush_single_entry(f, dxpl_id, delayed_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't flush entry collectively.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry collectively.") entries_flushed_collectively++; entries_flushed_or_cleared_last++; @@ -710,9 +710,9 @@ H5C_apply_candidate_list(H5F_t * f, HDassert((entries_flushed_collectively == entries_to_flush_collectively)); if((entries_flushed != entries_to_flush) || - (entries_cleared != entries_to_clear) || - (entries_flushed_or_cleared_last != entries_to_flush_or_clear_last) || - (entries_flushed_collectively != entries_to_flush_collectively)) + (entries_cleared != entries_to_clear) || + (entries_flushed_or_cleared_last != entries_to_flush_or_clear_last) || + (entries_flushed_collectively != entries_to_flush_collectively)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry count mismatch.") done: @@ -1143,7 +1143,7 @@ H5C_mark_entries_as_clean(H5F_t * f, entries_cleared++; if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't clear entry.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") } else { entry_ptr = entry_ptr->prev; @@ -1171,7 +1171,7 @@ H5C_mark_entries_as_clean(H5F_t * f, entries_cleared++; if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0 ) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't clear entry.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") } else { entry_ptr = entry_ptr->next; diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index c5d6929..82545c1 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -179,8 +179,6 @@ H5Dopen1(hid_t loc_id, const char *name) { H5D_t *dset = NULL; H5G_loc_t loc; /* Object location of group */ - hid_t dapl_id = H5P_DATASET_ACCESS_DEFAULT; /* dapl to use to open dataset */ - hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -193,7 +191,7 @@ H5Dopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, dapl_id, dxpl_id))) + if(NULL == (dset = H5D__open_name(&loc, name, H5P_DATASET_ACCESS_DEFAULT, H5AC_dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") /* Register an atom for the dataset */ diff --git a/src/H5L.c b/src/H5L.c index efe16aa..dd04990 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -717,7 +717,7 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name, udata.idx_type = idx_type; udata.order = order; udata.n = n; - udata.dxpl_id = H5AC_dxpl_id; + udata.dxpl_id = dxpl_id; /* Traverse the group hierarchy to remove the link */ if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK|H5G_TARGET_MOUNT, diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 732eb7b..5d4cb21 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -222,6 +222,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, char *actual_file_name = NULL; /* Parent file's actual name */ H5P_genplist_t *fa_plist; /* File access property list pointer */ H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree for target file */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -245,6 +246,10 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, cur_group, FALSE) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Get the fapl_id set for lapl_id if any */ if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links") @@ -282,7 +287,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, parent_file_name = H5F_OPEN_NAME(loc.oloc->file); /* Query length of parent group name */ - if((group_name_len = H5G_get_name(&loc, NULL, (size_t) 0, NULL, lapl_id, H5AC_dxpl_id)) < 0) + if((group_name_len = H5G_get_name(&loc, NULL, (size_t) 0, NULL, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve length of group name") /* Account for null terminator */ @@ -297,7 +302,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, parent_group_name = local_group_name; /* Get parent group name */ - if(H5G_get_name(&loc, parent_group_name, (size_t) group_name_len, NULL, lapl_id, H5AC_dxpl_id) < 0) + if(H5G_get_name(&loc, parent_group_name, (size_t) group_name_len, NULL, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve group name") /* Make callback */ @@ -328,7 +333,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, /* target file_name is an absolute pathname: see RM for detailed description */ if(H5_CHECK_ABSOLUTE(file_name) || H5_CHECK_ABS_PATH(file_name)) { /* Try opening file */ - if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, file_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { + if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, file_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id))) { char *ptr; H5E_clear_stack(NULL); @@ -347,7 +352,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, } /* end if */ else if(H5_CHECK_ABS_DRIVE(file_name)) { /* Try opening file */ - if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, file_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { + if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, file_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id))) { H5E_clear_stack(NULL); @@ -377,7 +382,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") } /* end if */ - ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id); + ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id); full_name = (char *)H5MM_xfree(full_name); if(ext_file != NULL) break; @@ -395,7 +400,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, if(my_prefix) { if(H5L_build_name(my_prefix, temp_file_name, &full_name/*out*/) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") - if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id))) H5E_clear_stack(NULL); full_name = (char *)H5MM_xfree(full_name); } /* end if */ @@ -408,7 +413,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, if(NULL != (extpath = H5F_EXTPATH(loc.oloc->file))) { if(H5L_build_name(extpath, temp_file_name, &full_name/*out*/) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") - if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id))) H5E_clear_stack(NULL); full_name = (char *)H5MM_xfree(full_name); } /* end if */ @@ -416,7 +421,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, /* try the relative file_name stored in temp_file_name */ if(ext_file == NULL) { - if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, temp_file_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, temp_file_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id))) H5E_clear_stack(NULL); } /* end if */ @@ -443,7 +448,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") /* Try opening with the resolved name */ - if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + if(NULL == (ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, "unable to open external file, external link file name = '%s', temp_file_name = '%s'", file_name, temp_file_name) full_name = (char *)H5MM_xfree(full_name); } /* end if */ @@ -454,7 +459,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file") /* Open the object referenced in the external file */ - if((ext_obj = H5O_open_name(&root_loc, obj_name, lapl_id, FALSE)) < 0) + if((ext_obj = H5O_open_name(&root_loc, obj_name, lapl_id, dxpl_id, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") /* Set return value */ diff --git a/src/H5O.c b/src/H5O.c index b22528a..dfcfee9 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -231,6 +231,7 @@ hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { H5G_loc_t loc; + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) @@ -242,8 +243,12 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Open the object */ - if((ret_value = H5O_open_name(&loc, name, lapl_id, TRUE)) < 0) + if((ret_value = H5O_open_name(&loc, name, lapl_id, dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: @@ -724,7 +729,7 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_found = TRUE; /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, H5AC_dxpl_id, TRUE, oinfo) < 0) + if(H5O_get_info(obj_loc.oloc, dxpl_id, TRUE, oinfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") done: @@ -1345,13 +1350,12 @@ done: *------------------------------------------------------------------------- */ hid_t -H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hbool_t app_ref) +H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) { H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ - hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ hid_t ret_value = FAIL; FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 2bb7a36..0abe69d 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -216,6 +216,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, htri_t dst_exists; /* Does destination name exist already? */ hbool_t loc_found = FALSE; /* Location at 'name' found */ hbool_t obj_open = FALSE; /* Entry at 'name' found */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -233,7 +234,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") /* check if destination name already exists */ - if((dst_exists = H5L_exists_tolerant(&dst_loc, dst_name, H5P_DEFAULT, H5AC_dxpl_id)) < 0) + if((dst_exists = H5L_exists_tolerant(&dst_loc, dst_name, H5P_DEFAULT, dxpl_id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check if destination name exists") if(TRUE == dst_exists) HGOTO_ERROR(H5E_OHDR, H5E_EXISTS, FAIL, "destination object already exists") @@ -244,7 +245,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, H5G_loc_reset(&src_loc); /* Find the source object to copy */ - if(H5G_loc_find(&loc, src_name, &src_loc/*out*/, H5P_DEFAULT, H5AC_dxpl_id) < 0) + if(H5G_loc_find(&loc, src_name, &src_loc/*out*/, H5P_DEFAULT, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found") loc_found = TRUE; @@ -270,7 +271,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list") /* Do the actual copying of the object */ - if(H5O_copy_obj(&src_loc, &dst_loc, dst_name, ocpypl_id, lcpl_id, H5AC_dxpl_id) < 0) + if(H5O_copy_obj(&src_loc, &dst_loc, dst_name, ocpypl_id, lcpl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 9235d6c..4ce8e59 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -763,7 +763,7 @@ H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, hid_t dxpl_id, hbool_t want_ih H5O_info_t *oinfo); H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id); H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, struct H5P_genplist_t *oc_plist); -H5_DLL hid_t H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hbool_t app_ref); +H5_DLL hid_t H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref); H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *nlinks); H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id); H5_DLL haddr_t H5O_get_oh_addr(const H5O_t *oh); diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index 89dcd16..3ff71dc 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -485,11 +485,12 @@ H5P__dxfr_reg_prop(H5P_genclass_t *pclass) NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the ring property */ + /* Register the ring property (private) */ if(H5P_register_real(pclass, H5AC_RING_NAME, H5AC_XFER_RING_SIZE, &H5D_ring_g, NULL, NULL, NULL, H5AC_XFER_RING_ENC, H5AC_XFER_RING_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + #ifdef H5_DEBUG_BUILD /* Register the dxpl IO type property */ if(H5P_register_real(pclass, H5FD_DXPL_TYPE_NAME, H5FD_DXPL_TYPE_SIZE, &H5D_dxpl_type_g, diff --git a/src/H5Pint.c b/src/H5Pint.c index b3d1976..4818021 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -5450,8 +5450,16 @@ H5P_get_class(const H5P_genplist_t *plist) *------------------------------------------------------------------------- */ herr_t -H5P_verify_apl_and_dxpl(hid_t *acspl_id, const H5P_libclass_t *libclass, - hid_t *dxpl_id, hid_t loc_id, hbool_t is_collective) +H5P_verify_apl_and_dxpl(hid_t *acspl_id, const H5P_libclass_t *libclass, hid_t *dxpl_id, + hid_t +#ifndef H5_HAVE_PARALLEL + H5_ATTR_UNUSED +#endif /* H5_HAVE_PARALLEL */ + loc_id, hbool_t +#ifndef H5_HAVE_PARALLEL + H5_ATTR_UNUSED +#endif /* H5_HAVE_PARALLEL */ + is_collective) { herr_t ret_value = SUCCEED; /* Return value */ @@ -5462,15 +5470,6 @@ H5P_verify_apl_and_dxpl(hid_t *acspl_id, const H5P_libclass_t *libclass, HDassert(libclass); HDassert(dxpl_id); - /* Set access plist to the default property list of the appropriate class if it's the generic default */ - if(H5P_DEFAULT == *acspl_id) - *acspl_id = *libclass->def_plist_id; - else { - /* Sanity check the access property list class */ - if(TRUE != H5P_isa_class(*acspl_id, *libclass->class_id)) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not the required access property list") - } /* end else */ - #ifdef H5_HAVE_PARALLEL /* If parallel is enabled and the file driver used in the MPI-IO VFD, issue an MPI barrier for easier debugging if the API function @@ -5490,6 +5489,15 @@ H5P_verify_apl_and_dxpl(hid_t *acspl_id, const H5P_libclass_t *libclass, } #endif /* H5_HAVE_PARALLEL */ + /* Set access plist to the default property list of the appropriate class if it's the generic default */ + if(H5P_DEFAULT == *acspl_id) + *acspl_id = *libclass->def_plist_id; + else { + /* Sanity check the access property list class */ + if(TRUE != H5P_isa_class(*acspl_id, *libclass->class_id)) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not the required access property list") + } /* end else */ + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_verify_apl_and_dxpl() */ diff --git a/src/H5R.c b/src/H5R.c index 04d61cd..bc49364 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -541,12 +541,6 @@ H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, { H5D_t *dset; /* Pointer to dataset to open */ - /* Get correct property list */ - if(H5P_DEFAULT == oapl_id) - oapl_id = H5P_DATASET_ACCESS_DEFAULT; - else if(TRUE != H5P_isa_class(oapl_id, H5P_DATASET_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") - /* Open the dataset */ if(NULL == (dset = H5D_open(&loc, oapl_id, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") @@ -602,6 +596,7 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r { H5G_loc_t loc; /* Group location */ H5F_t *file = NULL; /* File object */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -617,11 +612,15 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&oapl_id, H5P_CLS_DACC, &dxpl_id, obj_id, FALSE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Get the file pointer from the entry */ file = loc.oloc->file; /* Create reference */ - if((ret_value = H5R_dereference(file, oapl_id, H5AC_dxpl_id, ref_type, _ref, TRUE)) < 0) + if((ret_value = H5R_dereference(file, oapl_id, dxpl_id, ref_type, _ref, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object") done: -- cgit v0.12