From 603ebb01024f10d6d5a96dc2035714718f4e706c Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Wed, 3 Jul 2024 10:40:06 -0500 Subject: [PATCH 1/3] Reworked cleaning up test files, only removing test files if present to account for skipped tests --- test/API/H5_api_async_test.c | 5 +++-- test/API/H5_api_link_test.c | 4 ++-- test/API/H5_api_object_test.c | 30 ++++++++++++++++++++---------- test/API/H5_api_test.c | 4 +++- test/API/H5_api_test_util.c | 10 ++++++---- 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/test/API/H5_api_async_test.c b/test/API/H5_api_async_test.c index 6bcbe8d1105..56fb0cc2e0b 100644 --- a/test/API/H5_api_async_test.c +++ b/test/API/H5_api_async_test.c @@ -2674,10 +2674,11 @@ cleanup_files(void) char file_name[64]; int i; - H5Fdelete(ASYNC_API_TEST_FILE, H5P_DEFAULT); + remove_test_file(NULL, ASYNC_API_TEST_FILE); + for (i = 0; i <= max_printf_file; i++) { snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); - H5Fdelete(file_name, H5P_DEFAULT); + remove_test_file(NULL, file_name); } /* end for */ } diff --git a/test/API/H5_api_link_test.c b/test/API/H5_api_link_test.c index 65527709904..dec8387bfb6 100644 --- a/test/API/H5_api_link_test.c +++ b/test/API/H5_api_link_test.c @@ -27270,8 +27270,8 @@ link_visit_0_links_cb(hid_t group_id, const char *name, const H5L_info2_t *info, static void cleanup_files(void) { - H5Fdelete(EXTERNAL_LINK_TEST_FILE_NAME, H5P_DEFAULT); - H5Fdelete(EXTERNAL_LINK_INVALID_PARAMS_TEST_FILE_NAME, H5P_DEFAULT); + remove_test_file(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME); + remove_test_file(test_path_prefix, EXTERNAL_LINK_INVALID_PARAMS_TEST_FILE_NAME); } int diff --git a/test/API/H5_api_object_test.c b/test/API/H5_api_object_test.c index 7d3de346c33..3a19eff20e4 100644 --- a/test/API/H5_api_object_test.c +++ b/test/API/H5_api_object_test.c @@ -4750,10 +4750,6 @@ test_object_copy_between_files(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; - snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix, - OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME); - if (H5Fdelete(filename, H5P_DEFAULT) < 0) - TEST_ERROR; PASSED(); @@ -5714,12 +5710,6 @@ test_object_visit(void) TEST_ERROR; if (H5Fclose(file_id2) < 0) TEST_ERROR; - snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix, - OBJECT_VISIT_TEST_FILE_NAME); - if (H5Fdelete(filename, H5P_DEFAULT) < 0) - TEST_ERROR; - if (H5Fdelete(visit_filename, H5P_DEFAULT) < 0) - TEST_ERROR; PASSED(); @@ -7375,6 +7365,23 @@ object_visit_noop_callback(hid_t o_id, const char *name, const H5O_info2_t *obje return 0; } +/* + * Cleanup temporary test files + */ +static void +cleanup_files(void) +{ + char filename[H5_API_TEST_FILENAME_MAX_LENGTH]; + + snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix, + OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME); + remove_test_file(NULL, filename); + + snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix, + OBJECT_VISIT_TEST_FILE_NAME); + remove_test_file(NULL, filename); +} + int H5_api_object_test(void) { @@ -7393,5 +7400,8 @@ H5_api_object_test(void) printf("\n"); + printf("Cleaning up testing files\n"); + cleanup_files(); + return nerrors; } diff --git a/test/API/H5_api_test.c b/test/API/H5_api_test.c index 63dd095fa0f..b4248e0ae38 100644 --- a/test/API/H5_api_test.c +++ b/test/API/H5_api_test.c @@ -263,7 +263,9 @@ main(int argc, char **argv) H5_api_test_run(); printf("Cleaning up testing files\n"); - H5Fdelete(H5_api_test_filename, fapl_id); + if (HDaccess(H5_api_test_filename, F_OK) != -1) { + H5Fdelete(H5_api_test_filename, fapl_id); + } if (n_tests_run_g > 0) { printf("%zu/%zu (%.2f%%) API tests passed with VOL connector '%s'\n", n_tests_passed_g, n_tests_run_g, diff --git a/test/API/H5_api_test_util.c b/test/API/H5_api_test_util.c index 41640b4da53..2e28e859b92 100644 --- a/test/API/H5_api_test_util.c +++ b/test/API/H5_api_test_util.c @@ -788,10 +788,12 @@ remove_test_file(const char *prefix, const char *filename) else test_file = filename; - if (H5Fdelete(test_file, H5P_DEFAULT) < 0) { - printf(" couldn't remove file '%s'\n", test_file); - ret_value = FAIL; - goto done; + if (HDaccess(test_file, F_OK) != -1) { + if (H5Fdelete(test_file, H5P_DEFAULT) < 0) { + printf(" couldn't remove file '%s'\n", test_file); + ret_value = FAIL; + goto done; + } } done: From 201921f483c9d88598d02c8d6ef5e8b90268fe95 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Wed, 3 Jul 2024 11:38:06 -0500 Subject: [PATCH 2/3] changed to using H5Fis_accessible --- test/API/H5_api_test.c | 9 +++++++-- test/API/H5_api_test_util.c | 14 +++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/API/H5_api_test.c b/test/API/H5_api_test.c index b4248e0ae38..df489a3c69d 100644 --- a/test/API/H5_api_test.c +++ b/test/API/H5_api_test.c @@ -263,9 +263,14 @@ main(int argc, char **argv) H5_api_test_run(); printf("Cleaning up testing files\n"); - if (HDaccess(H5_api_test_filename, F_OK) != -1) { - H5Fdelete(H5_api_test_filename, fapl_id); + + H5E_BEGIN_TRY + { + if (H5Fis_accessible(H5_api_test_filename, H5P_DEFAULT) > 0) { + H5Fdelete(H5_api_test_filename, fapl_id); + } } + H5E_END_TRY if (n_tests_run_g > 0) { printf("%zu/%zu (%.2f%%) API tests passed with VOL connector '%s'\n", n_tests_passed_g, n_tests_run_g, diff --git a/test/API/H5_api_test_util.c b/test/API/H5_api_test_util.c index 2e28e859b92..48b77d36b2c 100644 --- a/test/API/H5_api_test_util.c +++ b/test/API/H5_api_test_util.c @@ -788,13 +788,17 @@ remove_test_file(const char *prefix, const char *filename) else test_file = filename; - if (HDaccess(test_file, F_OK) != -1) { - if (H5Fdelete(test_file, H5P_DEFAULT) < 0) { - printf(" couldn't remove file '%s'\n", test_file); - ret_value = FAIL; - goto done; + H5E_BEGIN_TRY + { + if (H5Fis_accessible(test_file, H5P_DEFAULT) > 0) { + if (H5Fdelete(test_file, H5P_DEFAULT) < 0) { + printf(" couldn't remove file '%s'\n", test_file); + ret_value = FAIL; + goto done; + } } } + H5E_END_TRY done: free(prefixed_filename); From df2f0daf69ae36e8399f770dbd9c8e5c133ab2a8 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Wed, 3 Jul 2024 13:43:38 -0500 Subject: [PATCH 3/3] update to full use of remove_test_file --- test/API/H5_api_object_test.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/test/API/H5_api_object_test.c b/test/API/H5_api_object_test.c index 3a19eff20e4..26977bf18dc 100644 --- a/test/API/H5_api_object_test.c +++ b/test/API/H5_api_object_test.c @@ -4196,7 +4196,6 @@ test_object_copy_between_files(void) hid_t attr_space_id = H5I_INVALID_HID; hid_t space_id = H5I_INVALID_HID; hid_t ocpypl_id = H5I_INVALID_HID; - char filename[H5_API_TEST_FILENAME_MAX_LENGTH]; TESTING_MULTIPART("object copying between files"); @@ -5068,7 +5067,6 @@ test_object_visit(void) hssize_t num_elems = 0; size_t elem_size = 0; char visit_filename[H5_API_TEST_FILENAME_MAX_LENGTH]; - char filename[H5_API_TEST_FILENAME_MAX_LENGTH]; TESTING_MULTIPART("object visiting"); @@ -7371,15 +7369,8 @@ object_visit_noop_callback(hid_t o_id, const char *name, const H5O_info2_t *obje static void cleanup_files(void) { - char filename[H5_API_TEST_FILENAME_MAX_LENGTH]; - - snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix, - OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME); - remove_test_file(NULL, filename); - - snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix, - OBJECT_VISIT_TEST_FILE_NAME); - remove_test_file(NULL, filename); + remove_test_file(test_path_prefix, OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME); + remove_test_file(test_path_prefix, OBJECT_VISIT_TEST_FILE_NAME); } int