summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/external.c121
-rw-r--r--test/vfd.c85
2 files changed, 100 insertions, 106 deletions
diff --git a/test/external.c b/test/external.c
index 619ca62..09e1e20 100644
--- a/test/external.c
+++ b/test/external.c
@@ -38,17 +38,15 @@ files_have_same_contents(const char *name1, const char *name2)
{
int fd1 = 0;
int fd2 = 0;
- ssize_t n1;
- ssize_t n2;
+ ssize_t n1 = 0;
+ ssize_t n2 = 0;
char buf1[1024];
char buf2[1024];
hbool_t ret = FALSE; /* not equal until proven otherwise */
- fd1 = HDopen(name1, O_RDONLY);
- if(fd1 < 0)
+ if ((fd1 = HDopen(name1, O_RDONLY)) < 0)
goto out;
- fd2 = HDopen(name2, O_RDONLY);
- if(fd2 < 0)
+ if ((fd2 = HDopen(name2, O_RDONLY)) < 0)
goto out;
/* Loop until files are empty or we encounter a problem */
@@ -101,29 +99,26 @@ out:
static int
test_non_extendible(hid_t file)
{
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dset = -1; /* dataset */
- hsize_t cur_size[1] = {100}; /* data space current size */
- hsize_t max_size[1] = {100}; /* data space maximum size */
- int n; /* number of external files */
- off_t file_offset; /* external file offset */
- hsize_t file_size; /* sizeof external file segment */
- haddr_t dset_addr; /* address of dataset */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dset = -1; /* dataset */
+ hsize_t cur_size[1] = {100}; /* data space current size */
+ hsize_t max_size[1] = {100}; /* data space maximum size */
+ int n = 0; /* number of external files */
+ off_t file_offset = 0; /* external file offset */
+ hsize_t file_size = 0; /* sizeof external file segment */
+ haddr_t dset_addr = HADDR_UNDEF; /* address of dataset */
TESTING("fixed-size data space, exact storage");
/* Create the dataset and close */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- if(dcpl < 0)
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0)
FAIL_STACK_ERROR
- space = H5Screate_simple(1, cur_size, max_size);
- if(space < 0)
+ if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
- dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- if(dset < 0)
+ if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
if(H5Dclose(dset) < 0)
FAIL_STACK_ERROR
@@ -133,8 +128,7 @@ test_non_extendible(hid_t file)
FAIL_STACK_ERROR
/* Read dataset creation information */
- dset = H5Dopen2(file, "dset1", H5P_DEFAULT);
- if(dset < 0)
+ if((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
/* Test dataset address. Should be undefined. */
@@ -145,11 +139,9 @@ test_non_extendible(hid_t file)
FAIL_STACK_ERROR
/* Check external count */
- dcpl = H5Dget_create_plist(dset);
- if(dcpl < 0)
+ if((dcpl = H5Dget_create_plist(dset)) < 0)
FAIL_STACK_ERROR
- n = H5Pget_external_count(dcpl);
- if(n < 0)
+ if((n = H5Pget_external_count(dcpl)) < 0)
FAIL_STACK_ERROR
if(1 != n) {
H5_FAILED();
@@ -215,13 +207,11 @@ test_too_small(hid_t file)
TESTING("external storage is too small");
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- if(dcpl < 0)
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */
FAIL_STACK_ERROR
- space = H5Screate_simple(1, cur_size, max_size);
- if(space < 0)
+ if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
H5E_BEGIN_TRY {
@@ -273,16 +263,13 @@ test_large_enough_current_eventual(hid_t file)
TESTING("extendible dataspace, exact external size");
- dcpl = H5Pcreate (H5P_DATASET_CREATE);
- if(dcpl < 0)
+ if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0)
FAIL_STACK_ERROR
- space = H5Screate_simple(1, cur_size, max_size);
- if(space < 0)
+ if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
- dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- if(dset < 0)
+ if((dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
@@ -327,13 +314,11 @@ test_large_enough_current_not_eventual(hid_t file)
TESTING("extendible dataspace, external storage is too small");
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- if(dcpl < 0)
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */
FAIL_STACK_ERROR
- space = H5Screate_simple(1, cur_size, max_size);
- if(space < 0)
+ if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
H5E_BEGIN_TRY {
@@ -387,16 +372,13 @@ test_unlimited(hid_t file)
TESTING("unlimited dataspace, unlimited external storage");
/* Create dataset */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- if(dcpl < 0)
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0)
FAIL_STACK_ERROR
- space = H5Screate_simple(1, cur_size, max_size);
- if(space < 0)
+ if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
- dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- if(dset < 0)
+ if((dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
@@ -404,14 +386,11 @@ test_unlimited(hid_t file)
if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
/* Read dataset creation information */
- dset = H5Dopen2(file, "dset5", H5P_DEFAULT);
- if(dset < 0)
+ if((dset = H5Dopen2(file, "dset5", H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
- dcpl = H5Dget_create_plist(dset);
- if(dcpl < 0)
+ if((dcpl = H5Dget_create_plist(dset)) < 0)
FAIL_STACK_ERROR
- n = H5Pget_external_count(dcpl);
- if(n < 0)
+ if((n = H5Pget_external_count(dcpl)) < 0)
FAIL_STACK_ERROR
if(1 != n) {
H5_FAILED();
@@ -493,12 +472,10 @@ test_multiple_files(hid_t file)
}
}
- space = H5Screate_simple(1, cur_size, max_size);
- if(space < 0)
+ if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
- dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- if(dset < 0)
+ if((dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
@@ -508,8 +485,7 @@ test_multiple_files(hid_t file)
/* ----------------------------------------------
* Verify that too-small external files will fail
*/
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- if(dcpl < 0)
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
max_ext_size -= 1;
@@ -522,7 +498,7 @@ test_multiple_files(hid_t file)
fflush(stderr);
FAIL_STACK_ERROR
}
- }
+ } /* end for each external file */
H5E_BEGIN_TRY {
dset = H5Dcreate2(file, "dset7", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -564,13 +540,12 @@ static int
test_add_to_unlimited(void)
{
hid_t dcpl = -1; /* dataset creation properties */
- herr_t status; /* function return status */
- int n; /* number of external files */
+ herr_t status = FAIL; /* function return status */
+ int n = 0; /* number of external files */
TESTING("external file following unlimited file");
- dcpl = H5Pcreate (H5P_DATASET_CREATE);
- if(dcpl < 0)
+ if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0)
FAIL_STACK_ERROR
@@ -581,8 +556,7 @@ test_add_to_unlimited(void)
if(status >= 0)
FAIL_PUTS_ERROR(" H5Pset_external() succeeded when it should have failed.");
- n = H5Pget_external_count(dcpl);
- if(n < 0)
+ if((n = H5Pget_external_count(dcpl)) < 0)
FAIL_STACK_ERROR
if(1 != n)
FAIL_PUTS_ERROR(" Wrong external file count returned.");
@@ -617,12 +591,11 @@ static int
test_overflow(void)
{
hid_t dcpl = -1; /* dataset creation properties */
- herr_t status; /* return status */
+ herr_t status = FAIL; /* return status */
TESTING("address overflow in external files");
- dcpl = H5Pcreate (H5P_DATASET_CREATE);
- if(dcpl < 0)
+ if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1) < 0)
FAIL_STACK_ERROR
@@ -667,7 +640,7 @@ test_read_file_set(hid_t fapl)
hid_t space = -1; /* data space */
hid_t dset = -1; /* dataset */
hid_t grp = -1; /* group to emit diagnostics */
- size_t i; /* miscellaneous counter */
+ size_t i = 0; /* miscellaneous counter */
char filename[1024]; /* file names */
int part[PART_SIZE]; /* raw data buffer (partial) */
int whole[TOTAL_SIZE]; /* raw data buffer (total) */
@@ -785,7 +758,7 @@ test_write_file_set(hid_t fapl)
hid_t mem_space = -1; /* memory data space */
hid_t file_space = -1; /* file data space */
hid_t dset = -1; /* dataset */
- unsigned i; /* miscellaneous counter */
+ unsigned i = 0; /* miscellaneous counter */
int part[PART_SIZE]; /* raw data buffer (partial) */
int whole[TOTAL_SIZE]; /* raw data buffer (total) */
hsize_t cur_size = 100; /* current data space size */
@@ -909,7 +882,7 @@ test_path_absolute(hid_t fapl)
hid_t dcpl = -1; /* dataset creation properties */
hid_t space = -1; /* data space */
hid_t dset = -1; /* dataset */
- size_t i; /* miscellaneous counter */
+ size_t i = 0; /* miscellaneous counter */
char cwdpath[1024]; /* working directory */
char filename[1024]; /* file name */
int part[PART_SIZE]; /* raw data buffer (partial) */
@@ -999,7 +972,7 @@ test_path_relative(hid_t fapl)
hid_t dcpl = -1; /* dataset creation properties */
hid_t space = -1; /* data space */
hid_t dset = -1; /* dataset */
- size_t i; /* miscellaneous counters */
+ size_t i = 0; /* miscellaneous counters */
char cwdpath[1024]; /* working directory */
char filename[1024]; /* file name */
int part[PART_SIZE]; /* raw data buffer (partial) */
@@ -1093,7 +1066,7 @@ test_path_relative_cwd(hid_t fapl)
hid_t dset = -1; /* dataset */
hid_t dset2 = -1; /* dataset, opened a second time */
hid_t dset3 = -1; /* dataset, opened with different prefix */
- size_t i; /* miscellaneous counters */
+ size_t i = 0; /* miscellaneous counters */
char cwdpath[1024]; /* working directory */
char filename[1024]; /* file name */
int part[PART_SIZE]; /* raw data buffer (partial) */
diff --git a/test/vfd.c b/test/vfd.c
index 7c1d9d5..e7c133b 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -1113,54 +1113,60 @@ error:
/*-------------------------------------------------------------------------
- * Function: test_family_member_fapl
+ * Function: test_family_member_fapl
*
- * Purpose: Actually use the member fapl input to the member vfd.
+ * Purpose: Actually use the member fapl input to the member vfd.
*
- * Return: 0 - success
- * -1 - failure
+ * Return: Success: 0
+ * Failure: -1
*
- * Programmer: Jacob Smith
- * 21 May 2019
+ * Programmer: Jacob Smith
+ * 21 May 2019
*
*-------------------------------------------------------------------------
*/
static herr_t
test_family_member_fapl(void)
{
- hid_t file;
- hid_t fapl_id;
- hid_t memb_fapl_id;
- hid_t space;
- hid_t dset;
+ hid_t file = H5I_INVALID_HID;
+ hid_t fapl_id = H5I_INVALID_HID;
+ hid_t memb_fapl_id = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
+ hid_t dset = H5I_INVALID_HID;
char filename[1024];
- char dname[] = "dataset";
- unsigned i;
- unsigned j;
+ char dname[] = "dataset";
+ unsigned i = 0;
+ unsigned j = 0;
int buf[FAMILY_NUMBER][FAMILY_SIZE];
- hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE};
+ hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE};
TESTING("Family member FAPL");
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (H5I_INVALID_HID == fapl_id)
+ if (H5I_INVALID_HID == fapl_id) {
TEST_ERROR;
+ }
memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (H5I_INVALID_HID == memb_fapl_id)
+ if (H5I_INVALID_HID == memb_fapl_id) {
TEST_ERROR;
- if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL)
+ }
+ if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) {
TEST_ERROR;
- if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL)
+ }
+ if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) {
TEST_ERROR;
+ }
h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename));
file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
- if (H5I_INVALID_HID == file)
+ if (H5I_INVALID_HID == file) {
TEST_ERROR;
+ }
space = H5Screate_simple(2, dims, NULL);
- if (H5I_INVALID_HID == space)
+ if (H5I_INVALID_HID == space) {
TEST_ERROR;
+ }
/* Create and write to dataset, then close file.
*/
@@ -1172,11 +1178,14 @@ test_family_member_fapl(void)
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
- if (H5I_INVALID_HID == dset)
+ if (H5I_INVALID_HID == dset) {
TEST_ERROR;
- for (i = 0; i < FAMILY_NUMBER; i++)
- for (j = 0; j < FAMILY_SIZE; j++)
+ }
+ for (i = 0; i < FAMILY_NUMBER; i++) {
+ for (j = 0; j < FAMILY_SIZE; j++) {
buf[i][j] = (int)((i * 10000) + j);
+ }
+ }
if (H5Dwrite(dset,
H5T_NATIVE_INT,
H5S_ALL,
@@ -1184,34 +1193,46 @@ test_family_member_fapl(void)
H5P_DEFAULT,
buf)
== FAIL)
+ {
TEST_ERROR;
- if (H5Dclose(dset) == FAIL) TEST_ERROR;
- if (H5Sclose(space) == FAIL) TEST_ERROR;
- if (H5Fclose(file) == FAIL) TEST_ERROR;
+ }
+ if (H5Dclose(dset) == FAIL) {
+ TEST_ERROR;
+ }
+ if (H5Sclose(space) == FAIL) {
+ TEST_ERROR;
+ }
+ if (H5Fclose(file) == FAIL) {
+ TEST_ERROR;
+ }
/* "Close" member FAPL at top level and re-open file.
* Should succeed, with library managing reference count properly
*/
- if (H5Pclose(memb_fapl_id) == FAIL)
+ if (H5Pclose(memb_fapl_id) == FAIL) {
TEST_ERROR;
+ }
file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id);
- if (H5I_INVALID_HID == file)
+ if (H5I_INVALID_HID == file) {
TEST_ERROR;
+ }
- if (H5Fclose(file) == FAIL)
+ if (H5Fclose(file) == FAIL) {
TEST_ERROR;
+ }
h5_delete_test_file(FILENAME[2], fapl_id);
- if (H5Pclose(fapl_id) == FAIL)
+ if (H5Pclose(fapl_id) == FAIL) {
TEST_ERROR;
+ }
PASSED();
return 0;
error:
- H5E_BEGIN_TRY{
+ H5E_BEGIN_TRY {
H5Sclose(space);
H5Dclose(dset);
H5Pclose(memb_fapl_id);