diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/dangle.c | 100 |
1 files changed, 95 insertions, 5 deletions
diff --git a/test/dangle.c b/test/dangle.c index c80d1a9..5086937 100644 --- a/test/dangle.c +++ b/test/dangle.c @@ -225,7 +225,7 @@ error: /*------------------------------------------------------------------------- - * Function: test_dangle_datatype + * Function: test_dangle_datatype1 * * Purpose: Check for dangling datatype IDs causing problems on library * shutdown @@ -241,7 +241,7 @@ error: *------------------------------------------------------------------------- */ static int -test_dangle_datatype(H5F_close_degree_t degree) +test_dangle_datatype1(H5F_close_degree_t degree) { char filename[1024]; hid_t fid; /* File ID */ @@ -322,6 +322,93 @@ error: /*------------------------------------------------------------------------- + * Function: test_dangle_datatype2 + * + * Purpose: Check for dangling datatype IDs causing problems on library + * shutdown + * + * Return: Success: zero + * Failure: non-zero + * + * Programmer: Quincey Koziol + * Thursday, August 25, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_dangle_datatype2(H5F_close_degree_t degree) +{ + char filename[1024]; + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + + TESTING(" dangling named datatype ID used by dataset"); + + if(H5open()<0) + TEST_ERROR; + + /* Create file access property list */ + if((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) + TEST_ERROR; + + /* Set file close degree */ + if(H5Pset_fclose_degree(fapl,degree)<0) + TEST_ERROR; + + h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); + if((fid = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + TEST_ERROR; + + if((tid = H5Tcopy (H5T_NATIVE_INT))<0) + TEST_ERROR; + + if(H5Tcommit(fid,TYPENAME,tid)<0) + TEST_ERROR; + + /* Create a dataset that uses the named datatype & leave it open */ + if((sid = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR; + if((did = H5Dcreate(fid, DSETNAME, tid, sid, H5P_DEFAULT)) < 0) + TEST_ERROR; + if(H5Sclose(sid)<0) + TEST_ERROR; + + if(degree==H5F_CLOSE_SEMI) { + H5E_BEGIN_TRY { + if(H5Fclose(fid)>=0) + TEST_ERROR; + } H5E_END_TRY; + } /* end if */ + else + if(H5Fclose(fid)<0) + TEST_ERROR; + + if(H5Pclose(fapl)<0) + TEST_ERROR; + + if(H5close()<0) + TEST_ERROR; + + if(h5_get_file_size(filename)==0) + TEST_ERROR; + + /* Clean up temporary file */ + HDremove(filename); + + PASSED(); + return 0; + +error: + return 1; +} + + +/*------------------------------------------------------------------------- * Function: test_dangle_attribute * * Purpose: Check for dangling attribute IDs causing problems on library @@ -453,21 +540,24 @@ main(void) puts("Testing dangling objects with weak file close:"); nerrors += test_dangle_dataset(H5F_CLOSE_WEAK); nerrors += test_dangle_group(H5F_CLOSE_WEAK); - nerrors += test_dangle_datatype(H5F_CLOSE_WEAK); + nerrors += test_dangle_datatype1(H5F_CLOSE_WEAK); + nerrors += test_dangle_datatype2(H5F_CLOSE_WEAK); nerrors += test_dangle_attribute(H5F_CLOSE_WEAK); /* Run tests w/semi file close */ puts("Testing dangling objects with semi file close:"); nerrors += test_dangle_dataset(H5F_CLOSE_SEMI); nerrors += test_dangle_group(H5F_CLOSE_SEMI); - nerrors += test_dangle_datatype(H5F_CLOSE_SEMI); + nerrors += test_dangle_datatype1(H5F_CLOSE_SEMI); + nerrors += test_dangle_datatype2(H5F_CLOSE_SEMI); nerrors += test_dangle_attribute(H5F_CLOSE_SEMI); /* Run tests w/strong file close */ puts("Testing dangling objects with strong file close:"); nerrors += test_dangle_dataset(H5F_CLOSE_STRONG); nerrors += test_dangle_group(H5F_CLOSE_STRONG); - nerrors += test_dangle_datatype(H5F_CLOSE_STRONG); + nerrors += test_dangle_datatype1(H5F_CLOSE_STRONG); + nerrors += test_dangle_datatype2(H5F_CLOSE_STRONG); nerrors += test_dangle_attribute(H5F_CLOSE_STRONG); /* Check for errors */ |