diff options
Diffstat (limited to 'test/ohdr.c')
-rw-r--r-- | test/ohdr.c | 299 |
1 files changed, 143 insertions, 156 deletions
diff --git a/test/ohdr.c b/test/ohdr.c index 3b11539..8dbe05e 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -72,13 +72,15 @@ test_cont(char *filename, hid_t fapl) HDmemset(&oh_locB, 0, sizeof(oh_locB)); /* Create the file to operate on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR if (H5AC_ignore_tags(f) < 0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } + H5_FAILED(); + H5Eprint2(H5E_DEFAULT, stdout); + goto error; + } /* end if */ if(H5O_create(f, H5AC_ind_read_dxpl_id, (size_t)H5O_MIN_SIZE, (size_t)0, H5P_GROUP_CREATE_DEFAULT, &oh_locA/*out*/) < 0) FAIL_STACK_ERROR @@ -89,58 +91,58 @@ test_cont(char *filename, hid_t fapl) time_new = 11111111; if(H5O_msg_create(&oh_locA, H5O_NAME_ID, 0, 0, &long_name, H5AC_ind_read_dxpl_id) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new, H5AC_ind_read_dxpl_id) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new, H5AC_ind_read_dxpl_id) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new, H5AC_ind_read_dxpl_id) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5O_msg_create(&oh_locA, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5AC_ind_read_dxpl_id) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new, H5AC_ind_read_dxpl_id) < 0) FAIL_STACK_ERROR if(H5O_msg_create(&oh_locA, H5O_NAME_ID, 0, 0, &short_name, H5AC_ind_read_dxpl_id) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(1 != H5O_link(&oh_locA, 1, H5AC_ind_read_dxpl_id)) FAIL_STACK_ERROR if(1 != H5O_link(&oh_locB, 1, H5AC_ind_read_dxpl_id)) FAIL_STACK_ERROR if(H5AC_flush(f, H5AC_ind_read_dxpl_id) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5O_expunge_chunks_test(&oh_locA, H5AC_ind_read_dxpl_id) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5O_get_hdr_info(&oh_locA, H5AC_ind_read_dxpl_id, &hdr_info) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR nchunks = hdr_info.nchunks; /* remove the 1st H5O_NAME_ID message */ if(H5O_msg_remove(&oh_locA, H5O_NAME_ID, 0, FALSE, H5AC_ind_read_dxpl_id) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5O_get_hdr_info(&oh_locA, H5AC_ind_read_dxpl_id, &hdr_info) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(hdr_info.nchunks >= nchunks) - TEST_ERROR + TEST_ERROR if(H5O_close(&oh_locA) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5O_close(&oh_locB) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -149,8 +151,8 @@ error: H5Fclose(file); } H5E_END_TRY; - return -1; -} /* test_cont() */ + return FAIL; +} /* end test_cont() */ /* * Verify that object headers are held in the cache until they are linked @@ -199,7 +201,7 @@ test_ohdr_cache(char *filename, hid_t fapl) if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) FAIL_STACK_ERROR if(H5Pclose(my_fapl) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR if(H5AC_ignore_tags(f) < 0) @@ -279,20 +281,20 @@ test_ohdr_cache(char *filename, hid_t fapl) FAIL_STACK_ERROR if(H5Pclose(my_dxpl) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Fclose(file) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Fclose(file); } H5E_END_TRY; - return -1; + return FAIL; } /* test_ohdr_cache() */ /* @@ -326,34 +328,34 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Open filename */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Open FILE_BOGUS */ if((fid_bogus = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ if(bogus_id == H5O_BOGUS_INVALID_ID) { - /* Open "group" in FILE_BOGUS */ - if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - loc_bogus = gid_bogus; + /* Open "group" in FILE_BOGUS */ + if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + loc_bogus = gid_bogus; - /* Create "group" in filename */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - loc = gid; + /* Create "group" in filename */ + if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + loc = gid; } else { /* H5O_BOGUS_VALID_ID */ - loc_bogus = fid_bogus; - loc = fid; - } + loc_bogus = fid_bogus; + loc = fid; + } /* end else */ /* Open the dataset with the unknown header message, but no extra flags */ if((did = H5Dopen2(loc_bogus, "Dataset1", H5P_DEFAULT)) < 0) - TEST_ERROR + FAIL_STACK_ERROR if(H5Dclose(did) < 0) - TEST_ERROR + FAIL_STACK_ERROR PASSED(); @@ -361,9 +363,9 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Open the dataset with the unknown header message, and "fail if unknown and open for write" flag */ if((did = H5Dopen2(loc_bogus, "Dataset2", H5P_DEFAULT)) < 0) - TEST_ERROR + FAIL_STACK_ERROR if(H5Dclose(did) < 0) - TEST_ERROR + FAIL_STACK_ERROR PASSED(); @@ -371,11 +373,11 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Attempt to open the dataset with the unknown header message, and "fail if unknown always" flag */ H5E_BEGIN_TRY { - did = H5Dopen2(loc_bogus, "Dataset3", H5P_DEFAULT); + did = H5Dopen2(loc_bogus, "Dataset3", H5P_DEFAULT); } H5E_END_TRY; if(did >= 0) { - H5Dclose(did); - TEST_ERROR + H5Dclose(did); + TEST_ERROR } /* end if */ PASSED(); @@ -384,163 +386,158 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Copy object with "mark if unknown" flag on message into file (FILENAME[0]) that can be modified */ if(H5Ocopy(loc_bogus, "Dataset4", loc, "Dataset4", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Closing: filename */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { - if(H5Gclose(gid) < 0) - FAIL_STACK_ERROR - } + if(bogus_id == H5O_BOGUS_INVALID_ID) + if(H5Gclose(gid) < 0) + FAIL_STACK_ERROR if(H5Fclose(fid) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Re-open filename, with read-only permissions */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ if(bogus_id == H5O_BOGUS_INVALID_ID) { - /* Open "group" in filename */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - loc = gid; + /* Open "group" in filename */ + if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + loc = gid; } else - loc = fid; + loc = fid; /* Open the dataset with the "mark if unknown" message */ if((did = H5Dopen2(loc, "Dataset4", H5P_DEFAULT)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Check that the "unknown" message was _NOT_ marked */ if(H5O_check_msg_marked_test(did, FALSE) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Close the dataset */ if(H5Dclose(did) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Close "group" in filename depending on bogus_id */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { - if(H5Gclose(gid) < 0) - FAIL_STACK_ERROR - } + if(bogus_id == H5O_BOGUS_INVALID_ID) + if(H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close filename (to flush change to object header) */ if(H5Fclose(fid) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Re-open filename */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ if(bogus_id == H5O_BOGUS_INVALID_ID) { - /* Open "group" in filename */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - loc = gid; + /* Open "group" in filename */ + if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + loc = gid; } else - loc = fid; + loc = fid; /* Open the dataset with the "mark if unknown" message */ if((did = H5Dopen2(loc, "Dataset4", H5P_DEFAULT)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Create data space */ if((sid = H5Screate(H5S_SCALAR)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Create an attribute, to get the object header into write access */ if((aid = H5Acreate2(did, "Attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Close dataspace */ if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Close attribute */ if(H5Aclose(aid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Close the dataset */ if(H5Dclose(did) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Close "group" in filename depending on bogus_id */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { - if(H5Gclose(gid) < 0) - FAIL_STACK_ERROR - } + if(bogus_id == H5O_BOGUS_INVALID_ID) + if(H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close filename (to flush change to object header) */ if(H5Fclose(fid) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Re-open filename */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ if(bogus_id == H5O_BOGUS_INVALID_ID) { - /* Open "group" in filename */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - loc = gid; + /* Open "group" in filename */ + if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + loc = gid; } else - loc = fid; + loc = fid; /* Re-open the dataset with the "mark if unknown" message */ if((did = H5Dopen2(loc, "Dataset4", H5P_DEFAULT)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Check that the "unknown" message was marked */ if(H5O_check_msg_marked_test(did, TRUE) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Close the dataset */ if(H5Dclose(did) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Closing: filename */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { - if(H5Gclose(gid) < 0) - TEST_ERROR - } + if(bogus_id == H5O_BOGUS_INVALID_ID) + if(H5Gclose(gid) < 0) + FAIL_STACK_ERROR if(H5Fclose(fid) < 0) - TEST_ERROR + FAIL_STACK_ERROR PASSED(); /* Closing: FILE_BOGUS */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { - if(H5Gclose(gid_bogus) < 0) - TEST_ERROR - } + if(bogus_id == H5O_BOGUS_INVALID_ID) + if(H5Gclose(gid_bogus) < 0) + FAIL_STACK_ERROR if(H5Fclose(fid_bogus) < 0) - TEST_ERROR + FAIL_STACK_ERROR TESTING("object in r/w file with unknown header message & 'fail if unknown and open for write' flag set"); /* Open FILE_BOGUS with RW intent this time */ if((fid_bogus = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - TEST_ERROR + FAIL_STACK_ERROR /* Set up location ID */ if(bogus_id == H5O_BOGUS_INVALID_ID) { - /* Open "group" in FILE_BOGUS */ - if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - loc_bogus = gid_bogus; + /* Open "group" in FILE_BOGUS */ + if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + loc_bogus = gid_bogus; } else - loc_bogus = fid_bogus; + loc_bogus = fid_bogus; /* Attempt to open the dataset with the unknown header message, and "fail if unknown and open for write" flag */ H5E_BEGIN_TRY { - did = H5Dopen2(loc_bogus, "Dataset2", H5P_DEFAULT); + did = H5Dopen2(loc_bogus, "Dataset2", H5P_DEFAULT); } H5E_END_TRY; if(did >= 0) { - H5Dclose(did); - TEST_ERROR + H5Dclose(did); + TEST_ERROR } /* end if */ PASSED(); @@ -549,38 +546,36 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) /* Attempt to open the dataset with the unknown header message, and "fail if unknown always" flag */ H5E_BEGIN_TRY { - did = H5Dopen2(loc_bogus, "Dataset3", H5P_DEFAULT); + did = H5Dopen2(loc_bogus, "Dataset3", H5P_DEFAULT); } H5E_END_TRY; if(did >= 0) { - H5Dclose(did); + H5Dclose(did); TEST_ERROR } /* end if */ /* Closing: FILE_BOGUS */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { - if(H5Gclose(gid_bogus) < 0) - TEST_ERROR - } + if(bogus_id == H5O_BOGUS_INVALID_ID) + if(H5Gclose(gid_bogus) < 0) + FAIL_STACK_ERROR if(H5Fclose(fid_bogus) < 0) - TEST_ERROR - + FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Fclose(fid); - H5Gclose(gid); + H5Gclose(gid); H5Fclose(fid_bogus); - H5Gclose(gid_bogus); - H5Dclose(did); - H5Sclose(sid); - H5Aclose(aid); + H5Gclose(gid_bogus); + H5Dclose(did); + H5Sclose(sid); + H5Aclose(aid); } H5E_END_TRY; - return -1; + return FAIL; } /* test_unknown() */ @@ -629,21 +624,20 @@ main(void) if(H5Pset_libver_bounds(fapl, (b ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST), H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR - /* test on object continuation block */ - if(test_cont(filename, fapl) < 0) - FAIL_STACK_ERROR + /* test on object continuation block */ + if(test_cont(filename, fapl) < 0) + TEST_ERROR /* Create the file to operate on */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + FAIL_STACK_ERROR if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - if (H5AC_ignore_tags(f) < 0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - + if(H5AC_ignore_tags(f) < 0) { + H5_FAILED(); + H5Eprint2(H5E_DEFAULT, stdout); + goto error; + } /* end if */ /* * Test object header creation @@ -655,7 +649,6 @@ main(void) FAIL_STACK_ERROR PASSED(); - /* create a new message */ TESTING("message creation"); time_new = 11111111; @@ -673,7 +666,6 @@ main(void) TEST_ERROR PASSED(); - /* * Test modification of an existing message. */ @@ -959,27 +951,22 @@ main(void) /* Test reading datasets with undefined object header messages * and the various "fail/mark if unknown" object header message flags */ - HDputs("Accessing objects with unknown header messages: H5O_BOGUS_VALID_ID"); - { - if(test_unknown(H5O_BOGUS_VALID_ID, filename, fapl) < 0) - TEST_ERROR - } - + HDputs("Accessing objects with unknown header messages: H5O_BOGUS_VALID_ID"); + if(test_unknown(H5O_BOGUS_VALID_ID, filename, fapl) < 0) + TEST_ERROR HDputs("Accessing objects with unknown header messages: H5O_BOGUS_INVALID_ID"); - { - if(test_unknown(H5O_BOGUS_INVALID_ID, filename, fapl) < 0) - TEST_ERROR - } - - /* Test object header creation metadata cache issues */ - if(test_ohdr_cache(filename, fapl) < 0) - TEST_ERROR + if(test_unknown(H5O_BOGUS_INVALID_ID, filename, fapl) < 0) + TEST_ERROR + + /* Test object header creation metadata cache issues */ + if(test_ohdr_cache(filename, fapl) < 0) + TEST_ERROR } /* end for */ /* Verify symbol table messages are cached */ if(h5_verify_cached_stabs(FILENAME, fapl) < 0) TEST_ERROR - puts("All object header tests passed."); + HDputs("All object header tests passed."); h5_cleanup(FILENAME, fapl); return 0; |