summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2016-08-19 16:30:05 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2016-08-19 16:30:05 (GMT)
commitc58ca9e28be060b7053b0c91431479bceed45452 (patch)
tree621fb2691512e8ea3e00dd56c2d080670839e392 /test
parent00c508dc682d76328f0374fbbd5414c18fb620e6 (diff)
downloadhdf5-c58ca9e28be060b7053b0c91431479bceed45452.zip
hdf5-c58ca9e28be060b7053b0c91431479bceed45452.tar.gz
hdf5-c58ca9e28be060b7053b0c91431479bceed45452.tar.bz2
[svn-r30306] Updated vfd test to be better about fapls and h5_reset().
Prevents the test from segfaulting in other sub-tests when a previous test fails. Tested on: 64-bit Ubuntu Linux 16.04 LTS w/ gcc 5.4.0 Autotools serial + direct VFD (vfd test only) Also tested with a forced error to ensure that the test no longer segfaults and confirmed that all test files are cleaned up.
Diffstat (limited to 'test')
-rw-r--r--test/vfd.c182
1 files changed, 110 insertions, 72 deletions
diff --git a/test/vfd.c b/test/vfd.c
index a6d979e..c19e0d0 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -94,8 +94,6 @@ test_sec2(void)
TESTING("SEC2 file driver");
- h5_reset();
-
/* Set property list and file name for SEC2 driver. */
if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
TEST_ERROR;
@@ -137,11 +135,15 @@ test_sec2(void)
if(file_size < 1 * KB || file_size > 4 * KB)
FAIL_PUTS_ERROR("suspicious file size obtained from H5Fget_filesize");
- /* Close the file */
+ /* Close and delete the file */
if(H5Fclose(fid) < 0)
TEST_ERROR;
+ h5_delete_test_file(FILENAME[0], fapl_id);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl_id) < 0)
+ TEST_ERROR;
- h5_cleanup(FILENAME, fapl_id);
PASSED();
return 0;
@@ -194,8 +196,6 @@ test_core(void)
TESTING("CORE file driver");
- h5_reset();
-
/* Get a file access property list and fix up the file name */
if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
TEST_ERROR;
@@ -453,13 +453,18 @@ test_core(void)
TEST_ERROR;
if(H5Dclose(did) < 0)
TEST_ERROR;
- if(H5Fclose(fid) < 0)
- TEST_ERROR;
HDfree(data_w);
HDfree(data_r);
- h5_cleanup(FILENAME, fapl_id);
+ /* Close and delete the file */
+ if(H5Fclose(fid) < 0)
+ TEST_ERROR;
+ h5_delete_test_file(FILENAME[1], fapl_id);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl_id) < 0)
+ TEST_ERROR;
PASSED();
return 0;
@@ -499,7 +504,7 @@ static herr_t
test_direct(void)
{
#ifdef H5_HAVE_DIRECT
- hid_t file=(-1), fapl, access_fapl = -1;
+ hid_t file=-1, fapl=-1, access_fapl = -1;
hid_t dset1=-1, dset2=-1, space1=-1, space2=-1;
char filename[1024];
int *fhandle=NULL;
@@ -508,7 +513,7 @@ test_direct(void)
size_t mbound;
size_t fbsize;
size_t cbsize;
- int *points = NULL, *check = NULL, *p1, *p2;
+ int *points = NULL, *check = NULL, *p1 = NULL, *p2 = NULL;
int wdata2[DSET2_DIM] = {11,12,13,14};
int rdata2[DSET2_DIM];
int i, j, n;
@@ -521,11 +526,10 @@ test_direct(void)
return 0;
#else /*H5_HAVE_DIRECT*/
- h5_reset();
-
/* Set property list and file name for Direct driver. Set memory alignment boundary
* and file block size to 512 which is the minimum for Linux 2.6. */
- fapl = h5_fileaccess();
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
if(H5Pset_fapl_direct(fapl, MBOUNDARY, FBSIZE, CBSIZE) < 0)
TEST_ERROR;
h5_fixname(FILENAME[5], fapl, filename, sizeof filename);
@@ -667,14 +671,19 @@ test_direct(void)
TEST_ERROR;
if(H5Dclose(dset2) < 0)
TEST_ERROR;
- if(H5Fclose(file) < 0)
- TEST_ERROR;
- HDassert(points);
+
HDfree(points);
- HDassert(check);
HDfree(check);
- h5_cleanup(FILENAME, fapl);
+ /* Close and delete the file */
+ if(H5Fclose(file) < 0)
+ TEST_ERROR;
+ h5_delete_test_file(FILENAME[5], fapl);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
+
PASSED();
return 0;
@@ -715,7 +724,7 @@ error:
static herr_t
test_family_opens(char *fname, hid_t fa_pl)
{
- hid_t file;
+ hid_t file=-1;
char first_name[1024];
char wrong_name[1024];
int i;
@@ -786,7 +795,7 @@ error:
static herr_t
test_family(void)
{
- hid_t file=(-1), fapl, fapl2=(-1), space=(-1), dset=(-1);
+ hid_t file=-1, fapl=-1, fapl2=-1, space=-1, dset=-1;
hid_t access_fapl = -1;
char filename[1024];
char dname[]="dataset";
@@ -798,14 +807,12 @@ test_family(void)
TESTING("FAMILY file driver");
- h5_reset();
-
/* Set property list and file name for FAMILY driver */
- fapl = h5_fileaccess();
-
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0)
TEST_ERROR;
- h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[2], fapl, filename, sizeof(filename));
if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
TEST_ERROR;
@@ -912,10 +919,15 @@ test_family(void)
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
TEST_ERROR;
+ /* Close and delete the file */
if(H5Fclose(file) < 0)
TEST_ERROR;
+ h5_delete_test_file(FILENAME[2], fapl);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
- h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -923,7 +935,8 @@ error:
H5E_BEGIN_TRY {
H5Sclose(space);
H5Dclose(dset);
- H5Pclose (fapl2);
+ H5Pclose(fapl);
+ H5Pclose(fapl2);
H5Fclose(file);
} H5E_END_TRY;
return -1;
@@ -951,8 +964,8 @@ error:
static herr_t
test_family_compat(void)
{
- hid_t file = (-1), fapl;
- hid_t dset;
+ hid_t file = -1, fapl = -1;
+ hid_t dset = -1;
char dname[]="dataset";
char filename[1024];
char pathname[1024], pathname_individual[1024];
@@ -961,16 +974,14 @@ test_family_compat(void)
TESTING("FAMILY file driver backward compatibility");
- h5_reset();
-
/* Set property list and file name for FAMILY driver */
- fapl = h5_fileaccess();
-
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE2, H5P_DEFAULT) < 0)
TEST_ERROR;
- h5_fixname(COMPAT_BASENAME, fapl, filename, sizeof filename);
- h5_fixname(FILENAME[3], fapl, newname, sizeof newname);
+ h5_fixname(COMPAT_BASENAME, fapl, filename, sizeof(filename));
+ h5_fixname(FILENAME[3], fapl, newname, sizeof(newname));
pathname[0] = '\0';
HDstrcat(pathname, filename);
@@ -1012,10 +1023,14 @@ test_family_compat(void)
if(H5Dclose(dset) < 0)
TEST_ERROR;
+ /* Close and delete the file */
if(H5Fclose(file) < 0)
TEST_ERROR;
+ h5_delete_test_file(FILENAME[3], fapl);
- h5_cleanup(FILENAME, fapl);
+ /* Close the fapl */
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
PASSED();
@@ -1048,7 +1063,7 @@ error:
static herr_t
test_multi_opens(char *fname)
{
- hid_t file;
+ hid_t file=-1;
char super_name[1024]; /*name string "%%s-s.h5"*/
char sf_name[1024]; /*name string "multi_file-s.h5"*/
@@ -1080,8 +1095,8 @@ test_multi_opens(char *fname)
static herr_t
test_multi(void)
{
- hid_t file=(-1), fapl, fapl2=(-1), dset=(-1), space=(-1);
- hid_t root, attr, aspace, atype;
+ hid_t file=-1, fapl=-1, fapl2=-1, dset=-1, space=-1;
+ hid_t root=-1, attr=-1, aspace=-1, atype=-1;
hid_t access_fapl = -1;
char filename[1024];
int *fhandle2=NULL, *fhandle=NULL;
@@ -1100,16 +1115,15 @@ test_multi(void)
TESTING("MULTI file driver");
- h5_reset();
-
/* Set file access property list for MULTI driver */
- fapl = h5_fileaccess();
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
- HDmemset(memb_map, 0, sizeof memb_map);
- HDmemset(memb_fapl, 0, sizeof memb_fapl);
- HDmemset(memb_name, 0, sizeof memb_name);
- HDmemset(memb_addr, 0, sizeof memb_addr);
- HDmemset(sv, 0, sizeof sv);
+ HDmemset(memb_map, 0, sizeof(memb_map));
+ HDmemset(memb_fapl, 0, sizeof(memb_fapl));
+ HDmemset(memb_name, 0, sizeof(memb_name));
+ 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)) {
memb_fapl[mt] = H5P_DEFAULT;
@@ -1256,10 +1270,15 @@ test_multi(void)
if(H5Aclose(attr) < 0)
TEST_ERROR;
+ /* Close and delete the file */
if(H5Fclose(file) < 0)
TEST_ERROR;
+ h5_delete_test_file(FILENAME[4], fapl);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
- h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -1299,7 +1318,7 @@ error:
static herr_t
test_multi_compat(void)
{
- hid_t file=(-1), fapl, dset=(-1), space=(-1);
+ hid_t file=-1, fapl=-1, dset=-1, space=-1;
char newname[1024];
char filename_s[1024], newname_s[1024];
char filename_r[1024], newname_r[1024];
@@ -1314,10 +1333,9 @@ test_multi_compat(void)
TESTING("MULTI file driver backward compatibility");
- h5_reset();
-
/* Set file access property list for MULTI driver */
- fapl = h5_fileaccess();
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
HDmemset(memb_map, 0, sizeof memb_map);
HDmemset(memb_fapl, 0, sizeof memb_fapl);
@@ -1425,10 +1443,15 @@ test_multi_compat(void)
if(H5Dclose(dset) < 0)
TEST_ERROR;
+ /* Close and delete the file */
if(H5Fclose(file) < 0)
TEST_ERROR;
+ h5_delete_test_file(FILENAME[9], fapl);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
- h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -1471,10 +1494,9 @@ test_log(void)
TESTING("LOG file driver");
- h5_reset();
-
/* Set property list and file name for log driver. */
- fapl = h5_fileaccess();
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
if(H5Pset_fapl_log(fapl, LOG_FILENAME, flags, buf_size) < 0)
TEST_ERROR;
h5_fixname(FILENAME[6], fapl, filename, sizeof filename);
@@ -1511,10 +1533,15 @@ test_log(void)
if(file_size < 1 * KB || file_size > 4 * KB)
TEST_ERROR;
+ /* Close and delete the file */
if(H5Fclose(file) < 0)
TEST_ERROR;
+ h5_delete_test_file(FILENAME[6], fapl);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
- h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -1552,10 +1579,9 @@ test_stdio(void)
TESTING("STDIO file driver");
- h5_reset();
-
/* Set property list and file name for STDIO driver. */
- fapl = h5_fileaccess();
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
if(H5Pset_fapl_stdio(fapl) < 0)
TEST_ERROR;
h5_fixname(FILENAME[7], fapl, filename, sizeof filename);
@@ -1591,10 +1617,15 @@ test_stdio(void)
if(file_size < 1 * KB || file_size > 4 * KB)
TEST_ERROR;
+ /* Close and delete the file */
if(H5Fclose(file) < 0)
TEST_ERROR;
+ h5_delete_test_file(FILENAME[7], fapl);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
- h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -1644,10 +1675,9 @@ test_windows(void)
#else /* H5_HAVE_WINDOWS */
- h5_reset();
-
/* Set property list and file name for WINDOWS driver. */
- fapl = h5_fileaccess();
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
if(H5Pset_fapl_windows(fapl) < 0)
TEST_ERROR;
h5_fixname(FILENAME[8], fapl, filename, sizeof filename);
@@ -1683,10 +1713,15 @@ test_windows(void)
if(file_size < 1 * KB || file_size > 4 * KB)
TEST_ERROR;
+ /* Close and delete the file */
if(H5Fclose(file) < 0)
TEST_ERROR;
+ h5_delete_test_file(FILENAME[8], fapl);
+
+ /* Close the fapl */
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
- h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -1698,7 +1733,7 @@ error:
return -1;
#endif /* H5_HAVE_WINDOWS */
-}
+} /* end test_windows() */
@@ -1720,7 +1755,9 @@ main(void)
{
int nerrors = 0;
- printf("Testing basic Virtual File Driver functionality.\n");
+ h5_reset();
+
+ HDprintf("Testing basic Virtual File Driver functionality.\n");
nerrors += test_sec2() < 0 ? 1 : 0;
nerrors += test_core() < 0 ? 1 : 0;
@@ -1734,12 +1771,13 @@ main(void)
nerrors += test_windows() < 0 ? 1 : 0;
if(nerrors) {
- printf("***** %d Virtual File Driver TEST%s FAILED! *****\n",
+ HDprintf("***** %d Virtual File Driver TEST%s FAILED! *****\n",
nerrors, nerrors > 1 ? "S" : "");
return 1;
- }
+ } /* end if */
+
+ HDprintf("All Virtual File Driver tests passed.\n");
- printf("All Virtual File Driver tests passed.\n");
return 0;
-}
+} /* end main() */