summaryrefslogtreecommitdiffstats
path: root/test/external_env.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/external_env.c')
-rw-r--r--test/external_env.c117
1 files changed, 61 insertions, 56 deletions
diff --git a/test/external_env.c b/test/external_env.c
index 262cde2..940bf82 100644
--- a/test/external_env.c
+++ b/test/external_env.c
@@ -16,11 +16,7 @@
*/
#include "external_common.h"
-static const char *EXT_ENV_FNAME[] = {
- "extern_env_dir/env_file_1",
- NULL
-};
-
+static const char *EXT_ENV_FNAME[] = {"extern_env_dir/env_file_1", NULL};
/*-------------------------------------------------------------------------
* Function: test_path_env
@@ -46,87 +42,93 @@ static const char *EXT_ENV_FNAME[] = {
static int
test_path_env(hid_t fapl)
{
- hid_t file = -1; /* file to write to */
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dapl = -1; /* dataset access property list */
- hid_t dset = -1; /* dataset */
- size_t i; /* miscellaneous counters */
- char filename[1024]; /* file name */
- int part[PART_SIZE]; /* raw data buffer (partial) */
- int whole[TOTAL_SIZE]; /* raw data buffer (total) */
- hsize_t cur_size; /* current data space size */
- char buffer[1024]; /* buffer to read efile_prefix */
+ hid_t file = -1; /* file to write to */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dapl = -1; /* dataset access property list */
+ hid_t dset = -1; /* dataset */
+ size_t i; /* miscellaneous counters */
+ char filename[1024]; /* file name */
+ int part[PART_SIZE]; /* raw data buffer (partial) */
+ int whole[TOTAL_SIZE]; /* raw data buffer (total) */
+ hsize_t cur_size; /* current data space size */
+ char buffer[1024]; /* buffer to read efile_prefix */
TESTING("prefix in HDF5_EXTFILE_PREFIX");
- if(HDmkdir("extern_env_dir", (mode_t)0755) < 0 && errno != EEXIST)
+ if (HDmkdir("extern_env_dir", (mode_t)0755) < 0 && errno != EEXIST)
TEST_ERROR;
h5_fixname(EXT_ENV_FNAME[0], fapl, filename, sizeof(filename));
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
/* Reset the raw data files */
- if(reset_raw_data_files(TRUE) < 0)
+ if (reset_raw_data_files(TRUE) < 0)
TEST_ERROR
/* Create the dataset */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
- for(i = 0; i < N_EXT_FILES; i++) {
- HDsnprintf(filename, sizeof(filename), "..%sextern_env_%dr.raw", H5_DIR_SEPS, (int) i + 1);
- if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0)
+ for (i = 0; i < N_EXT_FILES; i++) {
+ HDsnprintf(filename, sizeof(filename), "..%sextern_env_%dr.raw", H5_DIR_SEPS, (int)i + 1);
+ if (H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0)
FAIL_STACK_ERROR
} /* end for */
cur_size = TOTAL_SIZE;
- if((space = H5Screate_simple(1, &cur_size, NULL)) < 0)
+ if ((space = H5Screate_simple(1, &cur_size, NULL)) < 0)
FAIL_STACK_ERROR
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
FAIL_STACK_ERROR
/* Set prefix to a nonexistent directory, will be overwritten by environment variable */
- if(H5Pset_efile_prefix(dapl, "someprefix") < 0)
+ if (H5Pset_efile_prefix(dapl, "someprefix") < 0)
FAIL_STACK_ERROR
- if(H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0)
+ if (H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0)
FAIL_STACK_ERROR
- if(HDstrcmp(buffer, "someprefix") != 0)
+ if (HDstrcmp(buffer, "someprefix") != 0)
FAIL_PUTS_ERROR("efile prefix not set correctly");
/* Create dataset */
- if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0)
+ if ((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0)
FAIL_STACK_ERROR
/* Read the entire dataset and compare with the original */
HDmemset(whole, 0, sizeof(whole));
- if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0)
+ if (H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0)
FAIL_STACK_ERROR
- for(i = 0; i < TOTAL_SIZE; i++)
- if(whole[i] != (signed)i)
+ for (i = 0; i < TOTAL_SIZE; i++)
+ if (whole[i] != (signed)i)
FAIL_PUTS_ERROR("Incorrect value(s) read.");
- if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
- if(H5Pclose(dapl) < 0) FAIL_STACK_ERROR
- if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
- if(H5Sclose(space) < 0) FAIL_STACK_ERROR
- if(H5Fclose(file) < 0) FAIL_STACK_ERROR
+ if (H5Dclose(dset) < 0)
+ FAIL_STACK_ERROR
+ if (H5Pclose(dapl) < 0)
+ FAIL_STACK_ERROR
+ if (H5Pclose(dcpl) < 0)
+ FAIL_STACK_ERROR
+ if (H5Sclose(space) < 0)
+ FAIL_STACK_ERROR
+ if (H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dapl);
H5Dclose(dset);
H5Pclose(dcpl);
H5Sclose(space);
H5Fclose(file);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
} /* end test_path_env() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -142,12 +144,12 @@ error:
int
main(void)
{
- hid_t fapl_id_old = -1; /* file access properties (old format) */
- hid_t fapl_id_new = -1; /* file access properties (new format) */
- hid_t fid = -1; /* file for test_1* functions */
- hid_t gid = -1; /* group to emit diagnostics */
- unsigned latest_format; /* default or latest file format */
- int nerrors = 0; /* number of errors */
+ hid_t fapl_id_old = -1; /* file access properties (old format) */
+ hid_t fapl_id_new = -1; /* file access properties (new format) */
+ hid_t fid = -1; /* file for test_1* functions */
+ hid_t gid = -1; /* group to emit diagnostics */
+ unsigned latest_format; /* default or latest file format */
+ int nerrors = 0; /* number of errors */
h5_reset();
@@ -155,17 +157,17 @@ main(void)
fapl_id_old = h5_fileaccess();
/* Copy and set up a fapl for the latest file format */
- if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0)
+ if ((fapl_id_new = H5Pcopy(fapl_id_old)) < 0)
FAIL_STACK_ERROR
- if(H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ if (H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
FAIL_STACK_ERROR
/* Test with old & new format groups */
- for(latest_format = FALSE; latest_format <= TRUE; latest_format++) {
+ for (latest_format = FALSE; latest_format <= TRUE; latest_format++) {
hid_t current_fapl_id = -1;
/* Set the fapl for different file formats */
- if(latest_format) {
+ if (latest_format) {
HDputs("\nTesting with the latest file format:");
current_fapl_id = fapl_id_new;
} /* end if */
@@ -177,15 +179,17 @@ main(void)
nerrors += test_path_env(current_fapl_id);
} /* end for */
- if(nerrors > 0) goto error;
+ if (nerrors > 0)
+ goto error;
/* Close the new ff fapl. h5_cleanup will take care of the old ff fapl */
- if(H5Pclose(fapl_id_new) < 0) FAIL_STACK_ERROR
+ if (H5Pclose(fapl_id_new) < 0)
+ FAIL_STACK_ERROR
HDputs("All external storage tests passed.");
/* Clean up files used by file set tests */
- if(h5_cleanup(EXT_ENV_FNAME, fapl_id_old)) {
+ if (h5_cleanup(EXT_ENV_FNAME, fapl_id_old)) {
HDremove("extern_env_1r.raw");
HDremove("extern_env_2r.raw");
HDremove("extern_env_3r.raw");
@@ -202,14 +206,15 @@ main(void)
return EXIT_SUCCESS;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Fclose(fid);
H5Pclose(fapl_id_old);
H5Pclose(fapl_id_new);
H5Gclose(gid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
nerrors = MAX(1, nerrors);
HDprintf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s");
return EXIT_FAILURE;
} /* end main() */
-