summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/accum.c59
-rw-r--r--test/accum_swmr_reader.c18
-rw-r--r--test/btree2.c16
-rw-r--r--test/cache_common.c8
-rw-r--r--test/cache_tagging.c16
-rw-r--r--test/dsets.c12
-rw-r--r--test/earray.c16
-rw-r--r--test/efc.c16
-rw-r--r--test/farray.c16
-rw-r--r--test/fheap.c17
-rw-r--r--test/freespace.c60
-rw-r--r--test/gheap.c48
-rw-r--r--test/lheap.c25
-rw-r--r--test/mf.c18
-rw-r--r--test/ohdr.c23
-rw-r--r--test/page_buffer.c37
-rw-r--r--test/unregister.c19
17 files changed, 218 insertions, 206 deletions
diff --git a/test/accum.c b/test/accum.c
index 76e7656..19006b6 100644
--- a/test/accum.c
+++ b/test/accum.c
@@ -88,7 +88,7 @@ int
main(void)
{
unsigned nerrors = 0; /* track errors */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
hid_t fid = -1;
H5F_t * f = NULL; /* File for all tests */
@@ -98,8 +98,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create a test file */
if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Get H5F_t * to internal file structure */
if(NULL == (f = (H5F_t *)H5I_object(fid))) FAIL_STACK_ERROR
@@ -124,8 +126,10 @@ api_ctx_pushed = TRUE;
nerrors += test_free(f);
nerrors += test_big(f);
nerrors += test_random_write(f);
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
/* End of test code, close and delete file */
if(H5Fclose(fid) < 0) TEST_ERROR
@@ -142,7 +146,8 @@ api_ctx_pushed = FALSE;
return 0;
error:
-if(api_ctx_pushed) H5CX_pop();
+ if(api_ctx_pushed) H5CX_pop();
+
puts("*** TESTS FAILED ***");
return 1;
} /* end main() */
@@ -1822,7 +1827,7 @@ test_swmr_write_big(hbool_t newest_format)
int status; /* Status returned from child process */
char *new_argv[] = {NULL};
char *driver = NULL; /* VFD string (from env variable) */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
if(newest_format)
TESTING("SWMR write of large metadata: with latest format")
@@ -1870,8 +1875,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Open the file with SWMR_WRITE */
if((fid = H5Fopen(SWMR_FILENAME, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Get H5F_t * to internal file structure */
if(NULL == (rf = (H5F_t *)H5I_object(fid))) FAIL_STACK_ERROR
@@ -1957,19 +1964,22 @@ api_ctx_pushed = TRUE;
/* Check if child process terminates normally and its return value */
if(WIFEXITED(status) && !WEXITSTATUS(status)) {
- /* Flush the accumulator */
- if(accum_reset(rf) < 0)
- FAIL_STACK_ERROR;
- /* Close the property list */
- if(H5Pclose(fapl) < 0)
- FAIL_STACK_ERROR;
-
- /* Close and remove the file */
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
- HDremove(SWMR_FILENAME);
+ /* Flush the accumulator */
+ if(accum_reset(rf) < 0)
+ FAIL_STACK_ERROR;
+ /* Close the property list */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Close and remove the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
+ HDremove(SWMR_FILENAME);
/* Release memory */
if(wbuf2)
@@ -1984,8 +1994,11 @@ error:
/* Closing and remove the file */
H5Pclose(fapl);
H5Fclose(fid);
-if(api_ctx_pushed) H5CX_pop();
+
+ if(api_ctx_pushed) H5CX_pop();
+
HDremove(SWMR_FILENAME);
+
/* Release memory */
if(wbuf2)
HDfree(wbuf2);
diff --git a/test/accum_swmr_reader.c b/test/accum_swmr_reader.c
index 9005b99..5bda46a 100644
--- a/test/accum_swmr_reader.c
+++ b/test/accum_swmr_reader.c
@@ -50,7 +50,7 @@ main(void)
uint8_t rbuf[1024]; /* Buffer for reading */
uint8_t buf[1024]; /* Buffer for holding the expected data */
char *driver = NULL; /* VFD string (from env variable) */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Skip this test if SWMR I/O is not supported for the VFD specified
* by the environment variable.
@@ -72,8 +72,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Open the file with SWMR_READ */
if((fid = H5Fopen(SWMR_FILENAME, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Get H5F_t * to internal file structure */
if(NULL == (f = (H5F_t *)H5I_object(fid)))
@@ -92,14 +94,18 @@ api_ctx_pushed = TRUE;
FAIL_STACK_ERROR;
if(H5Fclose(fid) < 0)
FAIL_STACK_ERROR;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
return EXIT_SUCCESS;
error:
H5Fclose(fid);
-if(api_ctx_pushed) H5CX_pop();
+
+ if(api_ctx_pushed) H5CX_pop();
+
return EXIT_FAILURE;
} /* end main() */
diff --git a/test/btree2.c b/test/btree2.c
index fb0156c..e2874b7 100644
--- a/test/btree2.c
+++ b/test/btree2.c
@@ -9947,7 +9947,7 @@ main(void)
unsigned reopen; /* Whether to reopen B-tree during tests */
int ExpressMode;
const char *envval = NULL;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
envval = HDgetenv("HDF5_DRIVER");
if(envval == NULL)
@@ -9962,8 +9962,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Initialize v2 B-tree creation parameters */
init_cparam(&cparam, &cparam2);
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Loop over re-opening B-tree during tests */
for(reopen = FALSE; reopen <= TRUE; reopen++) {
@@ -10052,8 +10054,10 @@ api_ctx_pushed = TRUE;
/* Verify symbol table messages are cached */
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
if(nerrors)
goto error;
@@ -10071,6 +10075,8 @@ error:
H5Pclose(fapl);
} H5E_END_TRY;
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
} /* end main() */
diff --git a/test/cache_common.c b/test/cache_common.c
index 78e2253..5596601 100644
--- a/test/cache_common.c
+++ b/test/cache_common.c
@@ -3267,7 +3267,9 @@ setup_cache(size_t max_cache_size,
HDfprintf(stdout, "%s: H5Fcreate() failed.\n", FUNC);
} /* end if */
} /* end if */
-H5CX_push();
+
+ /* Push API context */
+ H5CX_push();
if(show_progress) /* 4 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -3497,7 +3499,9 @@ takedown_cache(H5F_t * file_ptr,
saved_fid = -1;
}
-H5CX_pop();
+
+ /* Pop API context */
+ H5CX_pop();
if ( ( ! try_core_file_driver ) || ( core_file_driver_failed ) ) {
diff --git a/test/cache_tagging.c b/test/cache_tagging.c
index 15ce6c2..7a2bb49 100644
--- a/test/cache_tagging.c
+++ b/test/cache_tagging.c
@@ -3638,7 +3638,7 @@ check_invalid_tag_application(void)
hid_t fid = -1;
haddr_t addr;
H5HL_t * lheap = NULL;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
#endif /* H5C_DO_TAGGING_SANITY_CHECKS */
/* Testing Macro */
@@ -3647,8 +3647,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
#if H5C_DO_TAGGING_SANITY_CHECKS
/* Create a test file */
if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR;
-if(H5CX_push() < 0) TEST_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) TEST_ERROR
+ api_ctx_pushed = TRUE;
/* Get internal file pointer*/
if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR;
@@ -3678,8 +3680,10 @@ api_ctx_pushed = TRUE;
/* Now unprotect the heap, as we're done with the test. */
if ( H5HL_unprotect(lheap) < 0 ) TEST_ERROR;
-if(api_ctx_pushed && H5CX_pop() < 0) TEST_ERROR
-api_ctx_pushed = FALSE;
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) TEST_ERROR
+ api_ctx_pushed = FALSE;
/* Close open objects and file */
if ( H5Fclose(fid) < 0 ) TEST_ERROR;
@@ -3695,7 +3699,7 @@ api_ctx_pushed = FALSE;
error:
#if H5C_DO_TAGGING_SANITY_CHECKS
-if(api_ctx_pushed) H5CX_pop();
+ if(api_ctx_pushed) H5CX_pop();
#endif /* H5C_DO_TAGGING_SANITY_CHECKS */
return 1;
diff --git a/test/dsets.c b/test/dsets.c
index 0e0b9d9..ca1e3d5 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -28,6 +28,7 @@
#include "H5srcdir.h"
#include "H5Bprivate.h"
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Iprivate.h"
#include "H5Pprivate.h"
@@ -2533,6 +2534,7 @@ test_missing_filter(hid_t file)
size_t i,j; /* Local index variables */
herr_t ret; /* Generic return value */
const char *testfile = H5_get_srcdir_filename(FILE_DEFLATE_NAME); /* Corrected test file name */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("dataset access with missing filter");
@@ -2545,6 +2547,10 @@ test_missing_filter(hid_t file)
goto error;
} /* end if */
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
+
/* Unregister deflate filter */
/* (Use private routine, to avoid range checking on filter ID) */
if(H5Z__unregister(H5Z_FILTER_DEFLATE) < 0) {
@@ -2740,10 +2746,16 @@ test_missing_filter(hid_t file)
} /* end if */
#endif /* H5_HAVE_FILTER_DEFLATE */
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
PASSED();
return 0;
error:
+ if(api_ctx_pushed) H5CX_pop();
+
return -1;
}
diff --git a/test/earray.c b/test/earray.c
index 0605605..d72b3f5 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -2429,7 +2429,7 @@ main(void)
unsigned nerrors = 0; /* Cumulative error count */
time_t curr_time; /* Current time, for seeding random number generator */
int ExpressMode; /* Test express value */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Reset library */
h5_reset();
@@ -2440,8 +2440,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g));
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Seed random #'s */
curr_time = HDtime(NULL);
@@ -2588,8 +2590,10 @@ api_ctx_pushed = TRUE;
/* Verify symbol table messages are cached */
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
if(nerrors)
goto error;
@@ -2607,6 +2611,8 @@ error:
H5Pclose(fapl);
} H5E_END_TRY;
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
} /* end main() */
diff --git a/test/efc.c b/test/efc.c
index 30ecdb5..d40d4a2 100644
--- a/test/efc.c
+++ b/test/efc.c
@@ -2891,7 +2891,7 @@ int
main(void)
{
unsigned nerrors = 0; /* track errors */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Test Setup */
puts("Testing the external file cache");
@@ -2907,8 +2907,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_fixname(FILENAME[3], fapl_id, filename[3], sizeof(filename[3]));
h5_fixname(FILENAME[4], fapl_id, filename[4], sizeof(filename[4]));
h5_fixname(FILENAME[5], fapl_id, filename[5], sizeof(filename[5]));
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Test Functions */
nerrors += test_single();
@@ -2921,8 +2923,10 @@ api_ctx_pushed = TRUE;
/* Verify symbol table messages are cached */
nerrors += (h5_verify_cached_stabs(FILENAME, fapl_id) < 0 ? 1 : 0);
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
if(nerrors)
goto error;
@@ -2940,6 +2944,8 @@ error:
H5Pclose(fapl_id);
} H5E_END_TRY
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
} /* end main() */
diff --git a/test/farray.c b/test/farray.c
index 5ff950e..383cb32 100644
--- a/test/farray.c
+++ b/test/farray.c
@@ -1659,7 +1659,7 @@ main(void)
unsigned nerrors = 0; /* Cumulative error count */
time_t curr_time; /* Current time, for seeding random number generator */
int ExpressMode; /* Test express value */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Reset library */
h5_reset();
@@ -1670,8 +1670,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g));
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Seed random #'s */
curr_time = HDtime(NULL);
@@ -1791,8 +1793,10 @@ api_ctx_pushed = TRUE;
/* Verify symbol table messages are cached */
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
if(nerrors)
goto error;
@@ -1810,6 +1814,8 @@ error:
H5Pclose(fapl);
} H5E_END_TRY;
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
} /* end main() */
diff --git a/test/fheap.c b/test/fheap.c
index 3a4fea3..e38d263 100644
--- a/test/fheap.c
+++ b/test/fheap.c
@@ -16288,7 +16288,7 @@ main(void)
int ExpressMode; /* Express testing level */
const char *envval; /* Environment variable */
hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Don't run this test using certain file drivers */
envval = HDgetenv("HDF5_DRIVER");
@@ -16327,8 +16327,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Initialize heap creation parameters */
init_small_cparam(&small_cparam);
init_large_cparam(&large_cparam);
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Allocate space for the shared objects */
shared_obj_size_g = large_cparam.max_man_size + 256;
@@ -16777,8 +16779,6 @@ api_ctx_pushed = TRUE;
/* Verify symbol table messages are cached */
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
if(nerrors)
goto error;
@@ -16794,6 +16794,10 @@ api_ctx_pushed = FALSE;
if(H5Pclose(def_fcpl) < 0) TEST_ERROR
if(H5Pclose(pb_fapl) < 0) TEST_ERROR
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
/* Clean up file used */
h5_cleanup(FILENAME, def_fapl);
@@ -16812,6 +16816,9 @@ error:
H5Pclose(def_fcpl);
H5Pclose(fcpl);
} H5E_END_TRY;
+
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
} /* end main() */
diff --git a/test/freespace.c b/test/freespace.c
index ebc7840..33a6f89 100644
--- a/test/freespace.c
+++ b/test/freespace.c
@@ -457,7 +457,6 @@ test_fs_create(hid_t fapl)
H5FS_create_t cparam, test_cparam; /* creation parameters */
uint16_t nclasses;
unsigned init_flags=0;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("the creation/close/reopen/deletion of the free-space manager");
@@ -479,8 +478,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Re-open the file */
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file)))
@@ -548,8 +545,6 @@ api_ctx_pushed = TRUE;
/* Verify the file is the correct size */
if(file_size != empty_size)
TEST_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED()
@@ -560,7 +555,6 @@ error:
if(frsp)
H5FS_close(f, frsp);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return 1;
} /* test_fs_create() */
@@ -606,7 +600,6 @@ test_fs_sect_add(hid_t fapl)
unsigned init_flags=0;
h5_stat_size_t file_size=0, tmp_file_size=0, fr_meta_size=0;
unsigned can_shrink=FALSE;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("adding a section via H5FS_sect_add() to free-space: test 1");
@@ -627,8 +620,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Re-open the file */
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file)))
@@ -891,8 +882,6 @@ api_ctx_pushed = TRUE;
/* Close the file and dxpl */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED()
@@ -905,7 +894,6 @@ error:
if(frsp)
H5FS_close(f, frsp);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return 1;
} /* test_fs_sect_add() */
@@ -947,7 +935,6 @@ test_fs_sect_find(hid_t fapl)
TEST_free_section_t *node;
htri_t node_found = FALSE;
unsigned init_flags=0;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("H5FS_sect_find(): free-space is empty");
@@ -957,8 +944,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to work on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file)))
@@ -1266,8 +1251,6 @@ api_ctx_pushed = TRUE;
/* Close the file and dxpl */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED()
@@ -1284,7 +1267,6 @@ error:
if(frsp)
H5FS_close(f, frsp);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return 1;
} /* test_fs_sect_find() */
@@ -1338,7 +1320,6 @@ test_fs_sect_merge(hid_t fapl)
unsigned init_flags=0;
htri_t node_found = FALSE;
TEST_free_section_t *node;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("the merge of sections when H5FS_sect_add() to free-space: test 1");
@@ -1351,8 +1332,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to work on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file)))
@@ -1742,8 +1721,6 @@ api_ctx_pushed = TRUE;
/* Close the file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED()
@@ -1758,7 +1735,6 @@ error:
if(frsp)
H5FS_close(f, frsp);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return 1;
} /* test_fs_sect_merge() */
@@ -1814,7 +1790,6 @@ test_fs_sect_shrink(hid_t fapl)
unsigned can_shrink=FALSE;
htri_t node_found = FALSE;
TEST_free_section_t *node;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 1");
@@ -1824,8 +1799,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to work on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file)))
@@ -2112,8 +2085,6 @@ api_ctx_pushed = TRUE;
/* Close the file and dxpl */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED()
@@ -2124,7 +2095,6 @@ error:
if(frsp)
H5FS_close(f, frsp);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return 1;
} /* test_sect_shrink() */
@@ -2161,7 +2131,6 @@ test_fs_sect_change_class(hid_t fapl)
TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL, *sect_node3=NULL;
unsigned init_flags=0;
TEST_free_section_t *node;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("the change of section class via H5FS_sect_change_class() in free-space: Test 1");
@@ -2171,8 +2140,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to work on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file)))
@@ -2393,8 +2360,6 @@ api_ctx_pushed = TRUE;
/* Close the file and dxpl */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED()
@@ -2409,7 +2374,6 @@ error:
if(frsp)
H5FS_close(f, frsp);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return 1;
} /* test_sect_change_class() */
@@ -2459,7 +2423,6 @@ test_fs_sect_extend(hid_t fapl)
TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL;
unsigned init_flags=0;
htri_t status; /* Status of 'try' calls */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("a block's extension by requested-size which is = adjoining free section's size: Test 1");
@@ -2468,8 +2431,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to work on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file)))
@@ -2778,8 +2739,6 @@ api_ctx_pushed = TRUE;
/* Close the file and dxpl */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
return 0;
@@ -2788,7 +2747,6 @@ error:
if(frsp)
H5FS_close(f, frsp);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return 1;
} /* test_sect_extend() */
@@ -2818,7 +2776,6 @@ test_fs_sect_iterate(hid_t fapl)
TEST_iter_ud_t udata;
int i;
hsize_t tot_space, nsects;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("iteration of sections in the free-space manager");
@@ -2828,8 +2785,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to work on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file)))
@@ -2886,8 +2841,6 @@ api_ctx_pushed = TRUE;
/* Close the file and dxpl */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED()
@@ -2898,7 +2851,6 @@ error:
if(frsp)
H5FS_close(f, frsp);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return 1;
} /* test_fs_sect_iterate() */
@@ -2910,6 +2862,7 @@ main(void)
hid_t fapl = -1; /* File access property list for data files */
unsigned nerrors = 0; /* Cumulative error count */
const char *env_h5_drvr = NULL; /* File Driver value from environment */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Get the VFD to use */
env_h5_drvr = HDgetenv("HDF5_DRIVER");
@@ -2923,6 +2876,10 @@ main(void)
PUTS_ERROR("Can't get VFD-dependent fapl")
} /* end if */
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
+
/* make sure alignment is not set for tests to succeed */
if(H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0) {
nerrors++;
@@ -2945,6 +2902,10 @@ main(void)
goto error;
HDputs("All free-space tests passed.");
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
h5_cleanup(FILENAME, fapl);
HDexit(EXIT_SUCCESS);
@@ -2953,6 +2914,9 @@ error:
H5E_BEGIN_TRY {
H5Pclose(fapl);
} H5E_END_TRY;
+
+ if(api_ctx_pushed) H5CX_pop();
+
HDexit(EXIT_FAILURE);
} /* main() */
diff --git a/test/gheap.c b/test/gheap.c
index 716c34a..bf0f18a 100644
--- a/test/gheap.c
+++ b/test/gheap.c
@@ -87,7 +87,6 @@ test_1 (hid_t fapl)
herr_t status;
int nerrors = 0;
char filename[1024];
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("monotonically increasing lengths");
@@ -99,8 +98,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
-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");
@@ -151,8 +148,6 @@ api_ctx_pushed = TRUE;
obj = NULL;
if(H5Fclose(file) < 0) goto error;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
if(nerrors) goto error;
PASSED();
@@ -161,7 +156,6 @@ api_ctx_pushed = FALSE;
error:
H5E_BEGIN_TRY {
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
if(obj)
HDfree(obj);
@@ -198,7 +192,6 @@ test_2 (hid_t fapl)
size_t size;
int nerrors = 0;
char filename[1024];
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("monotonically decreasing lengths");
@@ -210,8 +203,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
-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");
@@ -255,8 +246,6 @@ api_ctx_pushed = TRUE;
obj = NULL;
if (H5Fclose(file)<0) goto error;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
if (nerrors) goto error;
PASSED();
@@ -265,7 +254,6 @@ api_ctx_pushed = FALSE;
error:
H5E_BEGIN_TRY {
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
if(obj)
HDfree(obj);
@@ -302,7 +290,6 @@ test_3 (hid_t fapl)
herr_t status;
int nerrors = 0;
char filename[1024];
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("complete object removal");
@@ -314,8 +301,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
-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");
@@ -350,8 +335,6 @@ api_ctx_pushed = TRUE;
obj = NULL;
if (H5Fclose(file)<0) goto error;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
if (nerrors) goto error;
PASSED();
@@ -360,7 +343,6 @@ api_ctx_pushed = FALSE;
error:
H5E_BEGIN_TRY {
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
if(obj)
HDfree(obj);
@@ -398,7 +380,6 @@ test_4 (hid_t fapl)
herr_t status;
int nerrors = 0;
char filename[1024];
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("partial object removal");
@@ -410,8 +391,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_fixname(FILENAME[3], fapl, filename, sizeof filename);
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
-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");
@@ -452,8 +431,6 @@ api_ctx_pushed = TRUE;
obj = NULL;
if (H5Fclose(file)<0) goto error;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
if (nerrors) goto error;
PASSED();
@@ -462,7 +439,6 @@ api_ctx_pushed = FALSE;
error:
H5E_BEGIN_TRY {
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
if(obj)
HDfree(obj);
@@ -499,7 +475,6 @@ test_ooo_indices(hid_t fapl)
herr_t status;
int nerrors=0;
char filename[1024];
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("out of order indices");
@@ -510,8 +485,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_fixname(FILENAME[4], fapl, filename, sizeof filename);
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
-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");
@@ -571,8 +544,6 @@ api_ctx_pushed = TRUE;
} /* end for */
if (H5Fclose(file)<0) goto error;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
if (nerrors) goto error;
HDfree(obj);
@@ -584,7 +555,6 @@ api_ctx_pushed = FALSE;
error:
H5E_BEGIN_TRY {
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
if(obj)
HDfree(obj);
@@ -613,10 +583,15 @@ main (void)
{
int nerrors=0;
hid_t fapl;
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_reset();
fapl = h5_fileaccess();
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
+
nerrors += test_1(fapl);
nerrors += test_2(fapl);
nerrors += test_3(fapl);
@@ -626,13 +601,22 @@ main (void)
/* 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.");
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
h5_cleanup(FILENAME, fapl);
return 0;
error:
puts("*** TESTS FAILED ***");
+
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
}
+
diff --git a/test/lheap.c b/test/lheap.c
index dd8110e..4f09b6e 100644
--- a/test/lheap.c
+++ b/test/lheap.c
@@ -63,12 +63,15 @@ main(void)
int i, j; /* miscellaneous counters */
char buf[1024]; /* the value to store */
const char *s; /* value to read */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Reset library */
h5_reset();
fapl = h5_fileaccess();
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/*
* Test writing to the heap...
@@ -77,8 +80,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if(FAIL == (file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)))
goto error;
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file))) {
H5_FAILED();
H5Eprint2(H5E_DEFAULT, stdout);
@@ -119,8 +120,6 @@ api_ctx_pushed = TRUE;
}
if (FAIL == H5Fclose(file))
goto error;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED();
/*
@@ -131,8 +130,6 @@ api_ctx_pushed = FALSE;
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if(FAIL == (file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)))
goto error;
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file))) {
H5_FAILED();
H5Eprint2(H5E_DEFAULT, stdout);
@@ -179,8 +176,6 @@ api_ctx_pushed = TRUE;
if (FAIL == H5Fclose(file))
goto error;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED();
/* Check opening existing file non-default sizes of lengths and addresses */
@@ -189,8 +184,6 @@ api_ctx_pushed = FALSE;
const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */
hid_t dset = -1;
file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
if(file >= 0){
if((dset = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0)
TEST_ERROR
@@ -206,13 +199,15 @@ api_ctx_pushed = TRUE;
goto error;
} /* end else */
}
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
PASSED();
/* Verify symbol table messages are cached */
if(h5_verify_cached_stabs(FILENAME, fapl) < 0) TEST_ERROR
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
HDputs("All local heap tests passed.");
h5_cleanup(FILENAME, fapl);
@@ -222,8 +217,10 @@ api_ctx_pushed = FALSE;
HDputs("*** TESTS FAILED ***");
H5E_BEGIN_TRY {
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
+
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
}
diff --git a/test/mf.c b/test/mf.c
index 846cf90..a537679 100644
--- a/test/mf.c
+++ b/test/mf.c
@@ -8868,7 +8868,7 @@ main(void)
unsigned nerrors = 0; /* Cumulative error count */
test_type_t curr_test; /* Current test being worked on */
const char *env_h5_drvr; /* File Driver value from environment */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Get the VFD to use */
env_h5_drvr = HDgetenv("HDF5_DRIVER");
@@ -8878,8 +8878,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_reset();
fapl = h5_fileaccess();
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Make a copy of the FAPL before adjusting the alignment */
if((new_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR
@@ -8993,8 +8995,10 @@ api_ctx_pushed = TRUE;
if(H5Pclose(new_fapl) < 0)
FAIL_STACK_ERROR
h5_cleanup(FILENAME, fapl);
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
if(nerrors)
goto error;
@@ -9007,8 +9011,10 @@ error:
H5E_BEGIN_TRY {
H5Pclose(fapl);
H5Pclose(new_fapl);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
+
+ if(api_ctx_pushed) H5CX_pop();
+
return(1);
} /* main() */
diff --git a/test/ohdr.c b/test/ohdr.c
index 5821357..d0f6966 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -69,7 +69,6 @@ test_cont(char *filename, hid_t fapl)
const char *short_name = "T";
const char *long_name = "This is the message";
size_t nchunks;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("object header continuation block");
@@ -79,8 +78,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to operate on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
if (H5AC_ignore_tags(f) < 0) {
@@ -145,11 +142,9 @@ api_ctx_pushed = TRUE;
FAIL_STACK_ERROR
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
PASSED();
-
return SUCCEED;
error:
@@ -157,7 +152,6 @@ error:
H5O_close(&oh_locA, NULL);
H5O_close(&oh_locB, NULL);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return FAIL;
@@ -808,7 +802,7 @@ main(void)
time_t time_new, ro;
char msg[80]; /* Message for file format version */
int i; /* Local index variable */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret; /* Generic return value */
/* Reset library */
@@ -816,6 +810,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
+
/* Loop through all the combinations of low/high library format bounds */
for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
@@ -846,8 +844,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to operate on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
if(H5AC_ignore_tags(f) < 0) {
@@ -1037,8 +1033,6 @@ api_ctx_pushed = TRUE;
if(test_ohdr_cache(filename, fapl) < 0)
TEST_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
} /* high */
} /* low */
@@ -1049,6 +1043,10 @@ api_ctx_pushed = FALSE;
if(test_ohdr_swmr(TRUE) < 0) TEST_ERROR
if(test_ohdr_swmr(FALSE) < 0) TEST_ERROR
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
HDputs("All object header tests passed.");
h5_cleanup(FILENAME, fapl);
return 0;
@@ -1057,9 +1055,10 @@ error:
puts("*** TESTS FAILED ***");
H5E_BEGIN_TRY {
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
} /* end main() */
diff --git a/test/page_buffer.c b/test/page_buffer.c
index 9901304..a6e85ee 100644
--- a/test/page_buffer.c
+++ b/test/page_buffer.c
@@ -577,7 +577,6 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr)
haddr_t addr = HADDR_UNDEF;
int *data = NULL;
H5F_t *f = NULL;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("Raw Data Handling");
@@ -603,8 +602,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
FAIL_STACK_ERROR;
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file_id)))
@@ -797,8 +794,6 @@ api_ctx_pushed = TRUE;
FAIL_STACK_ERROR;
if(H5Pclose(fapl) < 0)
FAIL_STACK_ERROR;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
HDfree(data);
PASSED()
@@ -809,7 +804,6 @@ error:
H5Pclose(fapl);
H5Pclose(fcpl);
H5Fclose(file_id);
-if(api_ctx_pushed) H5CX_pop();
if(data)
HDfree(data);
} H5E_END_TRY;
@@ -862,7 +856,6 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr)
haddr_t search_addr = HADDR_UNDEF;
int *data = NULL;
H5F_t *f = NULL;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("LRU Processing");
@@ -896,8 +889,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file_id)))
FAIL_STACK_ERROR;
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* opening the file inserts one or more pages into the page buffer.
* Get the number of pages inserted, and verify that it is the
@@ -1056,8 +1047,6 @@ api_ctx_pushed = TRUE;
FAIL_STACK_ERROR;
if(H5Pclose(fapl) < 0)
FAIL_STACK_ERROR;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
HDfree(data);
PASSED()
@@ -1068,7 +1057,6 @@ error:
H5Pclose(fapl);
H5Pclose(fcpl);
H5Fclose(file_id);
-if(api_ctx_pushed) H5CX_pop();
if(data)
HDfree(data);
} H5E_END_TRY;
@@ -1124,7 +1112,6 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr)
haddr_t raw_addr = HADDR_UNDEF;
int *data = NULL;
H5F_t *f = NULL;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("Minimum Metadata threshold Processing");
HDprintf("\n");
@@ -1157,8 +1144,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* create the file */
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
FAIL_STACK_ERROR;
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file_id)))
@@ -1693,8 +1678,6 @@ api_ctx_pushed = TRUE;
if(H5Pclose(fapl) < 0)
FAIL_STACK_ERROR;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
HDfree(data);
@@ -1708,7 +1691,6 @@ error:
H5Pclose(fapl);
H5Pclose(fcpl);
H5Fclose(file_id);
-if(api_ctx_pushed) H5CX_pop();
if(data)
HDfree(data);
} H5E_END_TRY;
@@ -1763,7 +1745,6 @@ test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr)
haddr_t raw_addr = HADDR_UNDEF;
int *data = NULL;
H5F_t *f = NULL;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("Statistics Collection");
@@ -1793,8 +1774,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
FAIL_STACK_ERROR;
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
/* Get a pointer to the internal file object */
if(NULL == (f = (H5F_t *)H5I_object(file_id)))
@@ -2005,8 +1984,6 @@ api_ctx_pushed = TRUE;
FAIL_STACK_ERROR;
if(H5Pclose(fapl) < 0)
FAIL_STACK_ERROR;
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
HDfree(data);
@@ -2018,7 +1995,6 @@ error:
H5Pclose(fapl);
H5Pclose(fcpl);
H5Fclose(file_id);
-if(api_ctx_pushed) H5CX_pop();
if(data)
HDfree(data);
} H5E_END_TRY;
@@ -2161,6 +2137,7 @@ main(void)
hid_t fapl = -1; /* File access property list for data files */
unsigned nerrors = 0; /* Cumulative error count */
const char *env_h5_drvr = NULL; /* File Driver value from environment */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
h5_reset();
@@ -2186,6 +2163,10 @@ main(void)
PUTS_ERROR("Can't get VFD-dependent fapl")
} /* end if */
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
+
#ifdef H5_HAVE_PARALLEL
HDputs("Page Buffering is disabled for parallel.");
@@ -2206,12 +2187,15 @@ main(void)
if(nerrors)
goto error;
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
HDputs("All Page Buffering tests passed.");
HDexit(EXIT_SUCCESS);
error:
-
HDprintf("***** %d Page Buffering TEST%s FAILED! *****\n",
nerrors, nerrors > 1 ? "S" : "");
@@ -2219,7 +2203,8 @@ error:
H5Pclose(fapl);
} H5E_END_TRY;
- HDexit(EXIT_FAILURE);
+ if(api_ctx_pushed) H5CX_pop();
+ HDexit(EXIT_FAILURE);
} /* main() */
diff --git a/test/unregister.c b/test/unregister.c
index 4d7c902..dbf6293 100644
--- a/test/unregister.c
+++ b/test/unregister.c
@@ -231,13 +231,15 @@ main(void)
{
hid_t fapl;
int nerrors = 0;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Testing setup */
h5_reset();
fapl = h5_fileaccess();
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Test unregistering filter in its own file */
nerrors += (test_unregister_filters(fapl) < 0 ? 1 : 0);
@@ -245,9 +247,12 @@ api_ctx_pushed = TRUE;
if(nerrors)
goto error;
printf("All filter unregistration tests passed.\n");
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
h5_cleanup(FILENAME, fapl);
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
return 0;
@@ -255,7 +260,9 @@ error:
nerrors = MAX(1, nerrors);
printf("***** %d FILTER UNREGISTRATION TEST%s FAILED! *****\n",
nerrors, 1 == nerrors ? "" : "S");
-if(api_ctx_pushed) H5CX_pop();
+
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
}