summaryrefslogtreecommitdiffstats
path: root/test/vfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/vfd.c')
-rw-r--r--test/vfd.c230
1 files changed, 131 insertions, 99 deletions
diff --git a/test/vfd.c b/test/vfd.c
index 1de7fd5..e88d9bb 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -562,6 +562,7 @@ test_direct(void)
size_t mbound;
size_t fbsize;
size_t cbsize;
+ void *proto_points = NULL, *proto_check = NULL;
int *points = NULL, *check = NULL, *p1 = NULL, *p2 = NULL;
int wdata2[DSET2_DIM] = {11,12,13,14};
int rdata2[DSET2_DIM];
@@ -633,10 +634,12 @@ test_direct(void)
/* Allocate aligned memory for data set 1. For data set 1, everything is aligned including
* memory address, size of data, and file address. */
- if(0 != HDposix_memalign(&points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
+ if(0 != HDposix_memalign(&proto_points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
TEST_ERROR;
- if(0 != HDposix_memalign(&check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
+ points = proto_points;
+ if(0 != HDposix_memalign(&proto_check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
TEST_ERROR;
+ check = proto_check;
/* Initialize the dset1 */
p1 = points;
@@ -746,10 +749,10 @@ error:
H5Fclose(file);
} H5E_END_TRY;
- if(points)
- HDfree(points);
- if(check)
- HDfree(check);
+ if(proto_points)
+ HDfree(proto_points);
+ if(proto_check)
+ HDfree(proto_check);
return -1;
#endif /*H5_HAVE_DIRECT*/
@@ -776,8 +779,7 @@ error:
* 'first_name' in the code below, but early (4.4.7, at least) gcc only
* allows diagnostic pragmas to be toggled outside of functions.
*/
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+H5_GCC_DIAG_OFF(format-nonliteral)
static herr_t
test_family_opens(char *fname, hid_t fa_pl)
{
@@ -834,7 +836,7 @@ test_family_opens(char *fname, hid_t fa_pl)
error:
return -1;
} /* end test_family_opens() */
-#pragma GCC diagnostic pop
+H5_GCC_DIAG_ON(format-nonliteral)
/*-------------------------------------------------------------------------
@@ -842,8 +844,7 @@ error:
*
* Purpose: Tests the file handle interface for FAMILY driver
*
- * Return: Success: 0
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
* Programmer: Raymond Lu
* Tuesday, Sept 24, 2002
@@ -861,12 +862,21 @@ test_family(void)
char dname[]="dataset";
unsigned int i, j;
int *fhandle=NULL, *fhandle2=NULL;
- int buf[FAMILY_NUMBER][FAMILY_SIZE];
+ int **buf = NULL;
+ int *buf_data = NULL;
hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE};
hsize_t file_size;
TESTING("FAMILY file driver");
+ /* Set up data array */
+ if(NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int))))
+ TEST_ERROR;
+ if(NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data))))
+ TEST_ERROR;
+ for (i = 0; i < FAMILY_NUMBER; i++)
+ buf[i] = buf_data + (i * FAMILY_SIZE);
+
/* Set property list and file name for FAMILY driver */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
TEST_ERROR;
@@ -890,7 +900,7 @@ test_family(void)
| H5FD_FEAT_AGGREGATE_SMALLDATA))
TEST_ERROR
- if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
TEST_ERROR;
if(H5Fclose(file) < 0)
@@ -905,7 +915,7 @@ test_family(void)
if(H5Pset_fapl_family(fapl, (hsize_t)H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0)
TEST_ERROR;
- if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
TEST_ERROR;
/* Check file size API */
@@ -917,7 +927,7 @@ test_family(void)
TEST_ERROR;
/* Create and write dataset */
- if((space=H5Screate_simple(2, dims, NULL)) < 0)
+ if((space = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR;
/* Retrieve the access property list... */
@@ -932,14 +942,14 @@ test_family(void)
if (H5Pclose(access_fapl) < 0)
TEST_ERROR;
- if((dset=H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
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, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0)
TEST_ERROR;
/* check file handle API */
@@ -1004,8 +1014,11 @@ test_family(void)
if(H5Pclose(fapl) < 0)
TEST_ERROR;
+ HDfree(buf);
+ HDfree(buf_data);
+
PASSED();
- return 0;
+ return SUCCEED;
error:
H5E_BEGIN_TRY {
@@ -1015,8 +1028,12 @@ error:
H5Pclose(fapl2);
H5Fclose(file);
} H5E_END_TRY;
- return -1;
-}
+
+ HDfree(buf);
+ HDfree(buf_data);
+
+ return FAIL;
+} /* end test_family() */
/*-------------------------------------------------------------------------
@@ -1043,8 +1060,7 @@ error:
* 'newname_individual', etc. in the code below, but early (4.4.7, at least) gcc only
* allows diagnostic pragmas to be toggled outside of functions.
*/
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+H5_GCC_DIAG_OFF(format-nonliteral)
static herr_t
test_family_compat(void)
{
@@ -1128,7 +1144,7 @@ error:
return -1;
} /* end test_family_compat() */
-#pragma GCC diagnostic pop
+H5_GCC_DIAG_ON(format-nonliteral)
/*-------------------------------------------------------------------------
@@ -1136,8 +1152,7 @@ error:
*
* Purpose: Actually use the member fapl input to the member vfd.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
* Programmer: Jacob Smith
* 21 May 2019
@@ -1147,108 +1162,91 @@ error:
static herr_t
test_family_member_fapl(void)
{
- 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;
+ 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 = 0;
- unsigned j = 0;
- int buf[FAMILY_NUMBER][FAMILY_SIZE];
- hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE};
+ char dname[] = "dataset";
+ unsigned i = 0;
+ unsigned j = 0;
+ int **buf = NULL;
+ int *buf_data = NULL;
+ hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE};
TESTING("Family member FAPL");
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (H5I_INVALID_HID == fapl_id) {
+ /* Set up data array */
+ if(NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int))))
TEST_ERROR;
- }
- memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (H5I_INVALID_HID == memb_fapl_id) {
+ if(NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data))))
TEST_ERROR;
- }
- if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) {
+ for (i = 0; i < FAMILY_NUMBER; i++)
+ buf[i] = buf_data + (i * FAMILY_SIZE);
+
+ if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID)
TEST_ERROR;
- }
- if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) {
+
+ if((memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID)
TEST_ERROR;
- }
+
+ if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL)
+ TEST_ERROR;
+ 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((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) == H5I_INVALID_HID)
TEST_ERROR;
- }
- space = H5Screate_simple(2, dims, NULL);
- if (H5I_INVALID_HID == space) {
+ if((space = H5Screate_simple(2, dims, NULL)) == H5I_INVALID_HID)
TEST_ERROR;
- }
/* Create and write to dataset, then close file.
*/
- dset = H5Dcreate2(
- file,
- dname,
- H5T_NATIVE_INT,
- space,
- H5P_DEFAULT,
- H5P_DEFAULT,
- H5P_DEFAULT);
- if (H5I_INVALID_HID == dset) {
+ if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) == H5I_INVALID_HID)
TEST_ERROR;
- }
+
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,
- H5S_ALL,
- H5P_DEFAULT,
- buf)
- == FAIL)
- {
+
+ if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) == FAIL)
TEST_ERROR;
- }
- if (H5Dclose(dset) == FAIL) {
+
+ if (H5Dclose(dset) == FAIL)
TEST_ERROR;
- }
- if (H5Sclose(space) == FAIL) {
+ if (H5Sclose(space) == FAIL)
TEST_ERROR;
- }
- if (H5Fclose(file) == FAIL) {
+ 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 ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) == H5I_INVALID_HID)
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;
- }
+
+ HDfree(buf);
+ HDfree(buf_data);
PASSED();
- return 0;
+ return SUCCEED;
error:
H5E_BEGIN_TRY {
@@ -1259,7 +1257,10 @@ error:
H5Fclose(file);
} H5E_END_TRY;
- return -1;
+ HDfree(buf);
+ HDfree(buf_data);
+
+ return FAIL;
} /* end test_family_member_fapl() */
@@ -1282,8 +1283,7 @@ error:
* 'sf_name' in the code below, but early (4.4.7, at least) gcc only
* allows diagnostic pragmas to be toggled outside of functions.
*/
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+H5_GCC_DIAG_OFF(format-nonliteral)
static herr_t
test_multi_opens(char *fname)
{
@@ -1301,7 +1301,7 @@ test_multi_opens(char *fname)
return(fid >= 0 ? FAIL : SUCCEED);
} /* end test_multi_opens() */
-#pragma GCC diagnostic pop
+H5_GCC_DIAG_ON(format-nonliteral)
/*-------------------------------------------------------------------------
@@ -1337,10 +1337,19 @@ test_multi(void)
char dname[]="dataset";
char meta[] = "this is some metadata on this file";
int i, j;
- int buf[MULTI_SIZE][MULTI_SIZE];
+ int **buf = NULL;
+ int *buf_data = NULL;
TESTING("MULTI file driver");
+ /* Set up data array */
+ if(NULL == (buf_data = (int *)HDcalloc(MULTI_SIZE * MULTI_SIZE, sizeof(int))))
+ TEST_ERROR;
+ if(NULL == (buf = (int **)HDcalloc(MULTI_SIZE, sizeof(buf_data))))
+ TEST_ERROR;
+ for (i = 0; i < MULTI_SIZE; i++)
+ buf[i] = buf_data + (i * MULTI_SIZE);
+
/* Set file access property list for MULTI driver */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
TEST_ERROR;
@@ -1351,7 +1360,7 @@ test_multi(void)
HDmemset(memb_addr, 0, sizeof(memb_addr));
HDmemset(sv, 0, sizeof(sv));
- for(mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
+ for(mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
memb_fapl[mt] = H5P_DEFAULT;
memb_map[mt] = H5FD_MEM_SUPER;
}
@@ -1443,7 +1452,7 @@ test_multi(void)
for(i=0; i<MULTI_SIZE; i++)
for(j=0; j<MULTI_SIZE; j++)
buf[i][j] = i*10000+j;
- if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0)
TEST_ERROR;
if((fapl2=H5Pcreate(H5P_FILE_ACCESS)) < 0)
@@ -1521,6 +1530,9 @@ test_multi(void)
if(H5Pclose(fapl) < 0)
TEST_ERROR;
+ HDfree(buf);
+ HDfree(buf_data);
+
PASSED();
return SUCCEED;
@@ -1534,6 +1546,10 @@ error:
H5Fclose(file);
H5Aclose(attr);
} H5E_END_TRY;
+
+ HDfree(buf);
+ HDfree(buf_data);
+
return FAIL;
} /* end test_multi() */
@@ -1572,10 +1588,19 @@ test_multi_compat(void)
char sv[H5FD_MEM_NTYPES][32];
hsize_t dims[2]={MULTI_SIZE, MULTI_SIZE};
int i, j;
- int buf[MULTI_SIZE][MULTI_SIZE];
+ int **buf = NULL;
+ int *buf_data = NULL;
TESTING("MULTI file driver backward compatibility");
+ /* Set up data array */
+ if(NULL == (buf_data = (int *)HDcalloc(MULTI_SIZE * MULTI_SIZE, sizeof(int))))
+ TEST_ERROR;
+ if(NULL == (buf = (int **)HDcalloc(MULTI_SIZE, sizeof(buf_data))))
+ TEST_ERROR;
+ for (i = 0; i < MULTI_SIZE; i++)
+ buf[i] = buf_data + (i * MULTI_SIZE);
+
/* Set file access property list for MULTI driver */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
TEST_ERROR;
@@ -1586,7 +1611,7 @@ test_multi_compat(void)
HDmemset(memb_addr, 0, sizeof memb_addr);
HDmemset(sv, 0, sizeof sv);
- for(mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt))
+ for(mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++)
memb_map[mt] = H5FD_MEM_SUPER;
memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW;
@@ -1659,7 +1684,7 @@ test_multi_compat(void)
for(i=0; i<MULTI_SIZE; i++)
for(j=0; j<MULTI_SIZE; j++)
buf[i][j] = i*10000+j;
- if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0)
TEST_ERROR;
if(H5Dclose(dset) < 0)
@@ -1697,9 +1722,12 @@ test_multi_compat(void)
if(H5Pclose(fapl) < 0)
TEST_ERROR;
+ HDfree(buf);
+ HDfree(buf_data);
+
PASSED();
- return 0;
+ return SUCCEED;
error:
H5E_BEGIN_TRY {
@@ -1708,8 +1736,12 @@ error:
H5Pclose(fapl);
H5Fclose(file);
} H5E_END_TRY;
- return -1;
-}
+
+ HDfree(buf);
+ HDfree(buf_data);
+
+ return FAIL;
+} /* end test_multi_compat() */
/*-------------------------------------------------------------------------