diff options
Diffstat (limited to 'test/getname.c')
-rw-r--r-- | test/getname.c | 91 |
1 files changed, 59 insertions, 32 deletions
diff --git a/test/getname.c b/test/getname.c index 685bfbf..22abb79 100644 --- a/test/getname.c +++ b/test/getname.c @@ -65,11 +65,11 @@ check_name(hid_t id, const char *chk_name, const char *chk_user_path) /* Get name */ *name = '\0'; - if(H5Iget_name(id, name, NAME_BUF_SIZE) < 0) goto error; + if(H5Iget_name(id, name, NAME_BUF_SIZE) < 0) TEST_ERROR /* Get user path */ *user_path = '\0'; - if(H5G_user_path_test(id, user_path, &user_path_len, &user_path_hidden) < 0) goto error; + if(H5G_user_path_test(id, user_path, &user_path_len, &user_path_hidden) < 0) TEST_ERROR /* Check on name from H5Iget_name() */ if(HDstrcmp(name, chk_name)) goto error; @@ -78,7 +78,7 @@ check_name(hid_t id, const char *chk_name, const char *chk_user_path) if(HDstrcmp(user_path, chk_user_path)) goto error; /* Check that if user path is hidden, the name from H5Iget_name() and the user path should be different */ - if(user_path_hidden && !HDstrcmp(chk_name, chk_user_path)) goto error; + if(user_path_hidden && !HDstrcmp(chk_name, chk_user_path)) TEST_ERROR /* Everything matches */ return 0; @@ -713,10 +713,10 @@ test_main(hid_t file_id, hid_t fapl) PASSED(); -/*------------------------------------------------------------------------- - * Test H5Iget_name with H5Fmount; long name - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Fmount; long name + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Fmount; long name"); @@ -726,9 +726,9 @@ test_main(hid_t file_id, hid_t fapl) if((group3_id = H5Gcreate2(file_id, "/g13/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close */ - H5Gclose(group_id); - H5Gclose(group2_id); - H5Gclose(group3_id); + if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR + if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR /* Create second file and group "g" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); @@ -1144,6 +1144,7 @@ test_main(hid_t file_id, hid_t fapl) char name2[SMALL_NAME_BUF_SIZE]; /* Get name */ + *name2 = '\0'; name_len=H5Iget_name(group_id, name2, SMALL_NAME_BUF_SIZE); /* Check that name is longer */ @@ -1182,6 +1183,7 @@ test_main(hid_t file_id, hid_t fapl) if(!name3) TEST_ERROR /* Get name with dynamic buffer */ + *name3 = '\0'; if(H5Iget_name(group_id, name3, name_len + 1) < 0) TEST_ERROR /* Verify */ @@ -1189,6 +1191,7 @@ test_main(hid_t file_id, hid_t fapl) *name3 = '\0'; /* Get name with smaller buffer */ + *name3 = '\0'; if(H5Iget_name(group_id, name3, 3) < 0) TEST_ERROR /* Verify */ @@ -2513,80 +2516,96 @@ test_obj_ref(hid_t fapl) TESTING("getting path to normal dataset in root group"); if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[0])) < 0) FAIL_STACK_ERROR - i = H5Iget_name(dataset2,(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR if(!((HDstrcmp(buf, "/Dataset3") == 0) &&(i == 9))) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Dataset3") == 0) &&(i == 9))) TEST_ERROR PASSED() HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in /Group1"); if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[1])) < 0) FAIL_STACK_ERROR - i = H5Iget_name(dataset2,(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) &&(i == 16))) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) &&(i == 16))) TEST_ERROR PASSED() HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to /Group1"); if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[2])) < 0) FAIL_STACK_ERROR - i = H5Iget_name(group,(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Iget_name(group, (char*)buf, sizeof(buf)); if(H5Gclose(group) < 0) FAIL_STACK_ERROR if(!((HDstrcmp(buf, "/Group1") == 0) &&(i == 7))) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[2],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[2], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1") == 0) &&(i == 7))) TEST_ERROR PASSED() HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to datatype in /Group1"); if((tid1 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[3])) < 0) FAIL_STACK_ERROR - i = H5Iget_name(tid1,(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Iget_name(tid1, (char*)buf, sizeof(buf)); if(H5Tclose(tid1) < 0) FAIL_STACK_ERROR if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) &&(i == 17))) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[3],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[3], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) &&(i == 17))) TEST_ERROR PASSED() HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in nested group"); if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[4])) < 0) FAIL_STACK_ERROR - i = H5Iget_name(dataset2,(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) &&(i == 23))) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) &&(i == 23))) TEST_ERROR PASSED() HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to nested group"); if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[5])) < 0) FAIL_STACK_ERROR - i = H5Iget_name(group,(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Iget_name(group, (char*)buf, sizeof(buf)); if(H5Gclose(group) < 0) FAIL_STACK_ERROR if(!((HDstrcmp(buf, "/Group1/Group2") == 0) &&(i == 14))) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[5],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[5], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Group2") == 0) &&(i == 14))) TEST_ERROR PASSED() HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset created via hard link"); if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[6])) < 0) FAIL_STACK_ERROR - i = H5Iget_name(dataset2,(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) &&(i == 16))) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[6],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[6], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) &&(i == 16))) TEST_ERROR PASSED() HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to root group"); if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[7])) < 0) FAIL_STACK_ERROR - i = H5Iget_name(group,(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Iget_name(group, (char*)buf, sizeof(buf)); if(H5Gclose(group) < 0) FAIL_STACK_ERROR if(!((HDstrcmp(buf, "/") == 0) &&(i == 1))) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[7],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[7], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/") == 0) &&(i == 1))) TEST_ERROR PASSED() @@ -2596,10 +2615,12 @@ test_obj_ref(hid_t fapl) TESTING("getting path to dataset hidden by a mounted file"); if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[4])) < 0) FAIL_STACK_ERROR + *buf = '\0'; i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR if(i != 0) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf)); if(i != 0) TEST_ERROR PASSED() @@ -2610,10 +2631,12 @@ test_obj_ref(hid_t fapl) FAIL_STACK_ERROR TESTING("getting path to dataset that has been unlinked"); + *buf = '\0'; i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR if(i != 0) TEST_ERROR - i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1],(char*)buf, sizeof(buf)); + *buf = '\0'; + i = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf)); if(i != 0) TEST_ERROR PASSED() @@ -2735,7 +2758,8 @@ test_reg_ref(hid_t fapl) /* Get name of the dataset the first region reference points to using H5Rget_name */ TESTING("H5Rget_name to get name from region reference(hyperslab)"); - name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0],(char*)buf1, NAME_BUF_SIZE); + *buf1 = '\0'; + name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char*)buf1, NAME_BUF_SIZE); if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR PASSED() @@ -2745,7 +2769,8 @@ test_reg_ref(hid_t fapl) dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[0]); /* Get name of the dataset the first region reference points using H5Iget_name */ - name_size2 = H5Iget_name(dsetv_id,(char*)buf2, NAME_BUF_SIZE); + *buf2 = '\0'; + name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE); if(!((HDstrcmp(buf2, "/MATRIX") == 0) &&(name_size2 == 7))) TEST_ERROR if((status = H5Dclose(dsetv_id)) < 0) TEST_ERROR @@ -2754,7 +2779,8 @@ test_reg_ref(hid_t fapl) /* Get name of the dataset the second region reference points to using H5Rget_name */ TESTING("H5Rget_name to get name from region reference(pnt selec)"); - name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[1],(char*)buf1, NAME_BUF_SIZE); + *buf1 = '\0'; + name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[1], (char*)buf1, NAME_BUF_SIZE); if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR PASSED() @@ -2764,7 +2790,8 @@ test_reg_ref(hid_t fapl) if((dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[1])) < 0) TEST_ERROR /* Get name of the dataset the first region reference points using H5Iget_name */ - name_size2 = H5Iget_name(dsetv_id,(char*)buf2, NAME_BUF_SIZE); + *buf2 = '\0'; + name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE); if(!((HDstrcmp(buf2, "/MATRIX") == 0) &&(name_size2 == 7))) TEST_ERROR if((status = H5Dclose(dsetv_id)) < 0) TEST_ERROR |