diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2023-07-28 14:08:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-28 14:08:44 (GMT) |
commit | 9ef2f993cfc7173712729fb40b34d1edae8509d9 (patch) | |
tree | 937a98f4d50cf0cca08fa105ae37589aedb8975c /test/vfd.c | |
parent | f563c2b926445f7a975553bc7742a38f42d3b6f4 (diff) | |
download | hdf5-9ef2f993cfc7173712729fb40b34d1edae8509d9.zip hdf5-9ef2f993cfc7173712729fb40b34d1edae8509d9.tar.gz hdf5-9ef2f993cfc7173712729fb40b34d1edae8509d9.tar.bz2 |
Sync test dir w/ develop (#3303)
Diffstat (limited to 'test/vfd.c')
-rw-r--r-- | test/vfd.c | 155 |
1 files changed, 81 insertions, 74 deletions
@@ -44,23 +44,23 @@ #define DSET2_DIM 4 #endif /* H5_HAVE_DIRECT */ -const char *FILENAME[] = {"sec2_file", /*0*/ - "core_file", /*1*/ - "family_file", /*2*/ - "new_family_v16", /*3*/ - "multi_file", /*4*/ - "direct_file", /*5*/ - "log_file", /*6*/ - "stdio_file", /*7*/ - "windows_file", /*8*/ - "new_multi_file_v16", /*9*/ - "ro_s3_file", /*10*/ - "splitter_rw_file", /*11*/ - "splitter_wo_file", /*12*/ - "splitter.log", /*13*/ - "ctl_file", /*14*/ - "ctl_splitter_wo_file", /*15*/ - NULL}; +static const char *FILENAME[] = {"sec2_file", /*0*/ + "core_file", /*1*/ + "family_file", /*2*/ + "new_family_v16", /*3*/ + "multi_file", /*4*/ + "direct_file", /*5*/ + "log_file", /*6*/ + "stdio_file", /*7*/ + "windows_file", /*8*/ + "new_multi_file_v16", /*9*/ + "ro_s3_file", /*10*/ + "splitter_rw_file", /*11*/ + "splitter_wo_file", /*12*/ + "splitter.log", /*13*/ + "ctl_file", /*14*/ + "ctl_splitter_wo_file", /*15*/ + NULL}; #define LOG_FILENAME "log_vfd_out.log" @@ -75,12 +75,14 @@ const char *FILENAME[] = {"sec2_file", /*0*/ */ static int __k; #define HEXPRINT(size, buf) \ - for (__k = 0; __k < (size); __k++) { \ - if (__k % 16 == 0) { \ - printf("\n%04x", __k); \ + do { \ + for (__k = 0; __k < (size); __k++) { \ + if (__k % 16 == 0) { \ + printf("\n%04x", __k); \ + } \ + printf((__k % 4 == 0) ? " %02X" : " %02X", (unsigned char)(buf)[__k]); \ } \ - printf((__k % 4 == 0) ? " %02X" : " %02X", (unsigned char)(buf)[__k]); \ - } /* end #define HEXPRINT() */ + } while (0) /* end #define HEXPRINT() */ /* Macro SET_SIZE() * @@ -284,7 +286,7 @@ error: H5Pclose(fapl_id_out); H5Fclose(fid); } - H5E_END_TRY; + H5E_END_TRY return -1; } /* end test_sec2() */ @@ -667,7 +669,7 @@ error: H5Pclose(fapl_id); H5Fclose(fid); } - H5E_END_TRY; + H5E_END_TRY if (data_w) free(data_w); @@ -735,7 +737,7 @@ test_direct(void) { file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); } - H5E_END_TRY; + H5E_END_TRY if (file < 0) { H5Pclose(fapl); SKIPPED(); @@ -774,10 +776,10 @@ test_direct(void) /* Allocate aligned memory for data set 1. For data set 1, everything is aligned including * memory address, size of data, and file address. */ - if (0 != HDposix_memalign(&proto_points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) + if (0 != posix_memalign(&proto_points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; points = proto_points; - if (0 != HDposix_memalign(&proto_check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) + if (0 != posix_memalign(&proto_check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; check = proto_check; @@ -891,7 +893,7 @@ error: H5Dclose(dset2); H5Fclose(file); } - H5E_END_TRY; + H5E_END_TRY if (proto_points) free(proto_points); @@ -935,7 +937,7 @@ test_family_opens(char *fname, hid_t fa_pl) { file = H5Fopen(first_name, H5F_ACC_RDWR, H5P_DEFAULT); } - H5E_END_TRY; + H5E_END_TRY if (file >= 0) TEST_ERROR; @@ -944,7 +946,7 @@ test_family_opens(char *fname, hid_t fa_pl) { file = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); } - H5E_END_TRY; + H5E_END_TRY if (file >= 0) TEST_ERROR; @@ -956,7 +958,7 @@ test_family_opens(char *fname, hid_t fa_pl) { file = H5Fopen(fname, H5F_ACC_RDWR, fa_pl); } - H5E_END_TRY; + H5E_END_TRY if (file >= 0) TEST_ERROR; @@ -975,7 +977,7 @@ test_family_opens(char *fname, hid_t fa_pl) { file = H5Fopen(wrong_name, H5F_ACC_RDWR, fa_pl); } - H5E_END_TRY; + H5E_END_TRY if (file >= 0) TEST_ERROR; @@ -1175,7 +1177,7 @@ error: H5Pclose(fapl2); H5Fclose(file); } - H5E_END_TRY; + H5E_END_TRY free(buf); free(buf_data); @@ -1286,7 +1288,7 @@ error: H5Fclose(file); H5Pclose(fapl); } - H5E_END_TRY; + H5E_END_TRY return -1; } /* end test_family_compat() */ @@ -1400,7 +1402,7 @@ error: H5Pclose(fapl_id); H5Fclose(file); } - H5E_END_TRY; + H5E_END_TRY free(buf); free(buf_data); @@ -1440,7 +1442,7 @@ test_multi_opens(char *fname) { fid = H5Fopen(sf_name, H5F_ACC_RDWR, H5P_DEFAULT); } - H5E_END_TRY; + H5E_END_TRY return (fid >= 0 ? FAIL : SUCCEED); } /* end test_multi_opens() */ @@ -1686,7 +1688,7 @@ error: H5Fclose(file); H5Aclose(attr); } - H5E_END_TRY; + H5E_END_TRY free(buf); free(buf_data); @@ -1875,7 +1877,7 @@ error: H5Pclose(fapl); H5Fclose(file); } - H5E_END_TRY; + H5E_END_TRY free(buf); free(buf_data); @@ -1918,7 +1920,7 @@ test_log(void) { ret = H5Pset_fapl_log(H5I_INVALID_HID, LOG_FILENAME, 0, 0); } - H5E_END_TRY; + H5E_END_TRY if (SUCCEED == ret) TEST_ERROR; @@ -2002,7 +2004,7 @@ error: H5Pclose(fapl); H5Fclose(file); } - H5E_END_TRY; + H5E_END_TRY return -1; } @@ -2106,7 +2108,7 @@ error: H5Pclose(fapl); H5Fclose(file); } - H5E_END_TRY; + H5E_END_TRY return -1; } @@ -2226,7 +2228,7 @@ error: H5Pclose(fapl); H5Fclose(file); } - H5E_END_TRY; + H5E_END_TRY return -1; #endif /* H5_HAVE_WINDOWS */ @@ -2321,7 +2323,7 @@ error: H5Pclose(fapl_id_out); H5Fclose(fid); } - H5E_END_TRY; + H5E_END_TRY return -1; #endif /* H5_HAVE_ROS3_VFD */ } /* end test_ros3() */ @@ -2336,7 +2338,7 @@ error: * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #define SPLITTER_TEST_FAULT(mesg) \ - { \ + do { \ H5_FAILED(); \ AT(); \ fprintf(stderr, mesg); \ @@ -2344,7 +2346,7 @@ error: fflush(stderr); \ ret_value = -1; \ goto done; \ - } + } while (0) /*------------------------------------------------------------------------- * Function: compare_splitter_config_info @@ -2570,11 +2572,11 @@ done: H5Pclose(fapl_id); H5Fclose(file_id); } - H5E_END_TRY; + H5E_END_TRY } if (logfile != NULL) - HDfclose(logfile); + fclose(logfile); free(vfd_config); free(filename_rw); @@ -2624,7 +2626,7 @@ driver_is_splitter_compatible(hid_t fapl_id) { ret = H5Pset_fapl_splitter(split_fapl_id, vfd_config); } - H5E_END_TRY; + H5E_END_TRY if (SUCCEED == ret) { ret_value = -1; } @@ -2643,7 +2645,7 @@ error: { H5Pclose(split_fapl_id); } - H5E_END_TRY; + H5E_END_TRY free(vfd_config); @@ -2707,7 +2709,7 @@ splitter_RO_test(const struct splitter_dataset_def *data, hid_t child_fapl_id) { file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (file_id >= 0) { SPLITTER_TEST_FAULT("R/O open on nonexistent files unexpectedly successful\n"); } @@ -2723,7 +2725,7 @@ splitter_RO_test(const struct splitter_dataset_def *data, hid_t child_fapl_id) { file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (file_id >= 0) { SPLITTER_TEST_FAULT("R/O open with extant W/O file unexpectedly successful\n"); } @@ -2740,7 +2742,7 @@ splitter_RO_test(const struct splitter_dataset_def *data, hid_t child_fapl_id) { file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (file_id >= 0) { SPLITTER_TEST_FAULT("R/O open with extant R/W file unexpectedly successful\n"); } @@ -2778,7 +2780,7 @@ done: H5Pclose(fapl_id); H5Fclose(file_id); } - H5E_END_TRY; + H5E_END_TRY } free(vfd_config); @@ -2917,7 +2919,7 @@ done: H5Sclose(space_id); H5Fclose(file_id); } - H5E_END_TRY; + H5E_END_TRY } /* end if error */ return ret_value; } /* end splitter_create_single_file_at() */ @@ -2978,7 +2980,7 @@ done: { H5Dclose(dset_id); } - H5E_END_TRY; + H5E_END_TRY } return ret_value; } /* end splitter_compare_expected_data() */ @@ -3079,7 +3081,7 @@ splitter_tentative_open_test(hid_t child_fapl_id) { file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (file_id != H5I_INVALID_HID) { SPLITTER_TEST_FAULT("open with both nonexistent files unexpectedly succeeded\n"); } @@ -3103,7 +3105,7 @@ splitter_tentative_open_test(hid_t child_fapl_id) { file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (file_id != H5I_INVALID_HID) { SPLITTER_TEST_FAULT("open with nonexistent R/W file unexpectedly succeeded\n"); } @@ -3131,7 +3133,7 @@ splitter_tentative_open_test(hid_t child_fapl_id) { file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (file_id != H5I_INVALID_HID) { SPLITTER_TEST_FAULT("open with nonexistent W/O unexpectedly succeeded\n"); } @@ -3269,7 +3271,7 @@ done: H5Pclose(fapl_id); H5Fclose(file_id); } - H5E_END_TRY; + H5E_END_TRY } free(vfd_config); @@ -3300,7 +3302,7 @@ file_exists(const char *filename, hid_t fapl_id) { file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (file_id != H5I_INVALID_HID) { ret_value = 1; if (H5Fclose(file_id) < 0) { @@ -3315,7 +3317,7 @@ error: { H5Fclose(file_id); } - H5E_END_TRY; + H5E_END_TRY return ret_value; } /* end file_exists() */ @@ -3648,7 +3650,7 @@ run_ctl_test(uint64_t op_code, uint64_t flags, ctl_test_opc_type opc_type, hid_t { ctl_result = H5FDctl(file_drv_ptr, op_code, flags, NULL, NULL); } - H5E_END_TRY; + H5E_END_TRY } else ctl_result = H5FDctl(file_drv_ptr, op_code, flags, NULL, NULL); @@ -3675,7 +3677,7 @@ error: { H5FDclose(file_drv_ptr); } - H5E_END_TRY; + H5E_END_TRY return -1; } @@ -3974,7 +3976,7 @@ error: H5Pclose(sub_fapl_id); H5Pclose(fapl_id); } - H5E_END_TRY; + H5E_END_TRY return -1; } @@ -4877,7 +4879,7 @@ error: H5Pclose(fapl_id); H5FDclose(lf); } - H5E_END_TRY; + H5E_END_TRY return -1; } /* end test_vector_io() */ @@ -4889,10 +4891,6 @@ error: * * Return: Success: TRUE * Failure: FALSE - * - * Programmer: Neil Fortner - * 7/1/21 - * *------------------------------------------------------------------------- */ /* Array dimensions, used for all selection I/O tests. Currently both must be @@ -4904,23 +4902,32 @@ static herr_t test_selection_io_write(H5FD_t *lf, H5FD_mem_t type, uint32_t count, hid_t mem_spaces[], hid_t file_spaces[], haddr_t offsets[], size_t element_sizes[], int *wbufs[]) { - int i; - int j; + const void **bufs; /* Avoids cast/const warnings */ + int i; + int j; + + if (NULL == (bufs = calloc(count, sizeof(void *)))) + TEST_ERROR; /* Update write buffer */ - for (i = 0; i < (int)count; i++) + for (i = 0; i < (int)count; i++) { if (wbufs[i] && (i == 0 || wbufs[i] != wbufs[i - 1])) for (j = 0; j < SEL_IO_DIM0 * SEL_IO_DIM1; j++) wbufs[i][j] += 2 * SEL_IO_DIM0 * SEL_IO_DIM1; + bufs[i] = wbufs[i]; + } /* Issue write call */ if (H5FDwrite_selection(lf, type, H5P_DEFAULT, count, mem_spaces, file_spaces, offsets, element_sizes, - (const void **)wbufs) < 0) + bufs) < 0) TEST_ERROR; + free(bufs); + return 0; error: + free(bufs); return -1; } /* end test_selection_io_write() */ @@ -5847,7 +5854,7 @@ error: H5Sclose(file_spaces[i]); } } - H5E_END_TRY; + H5E_END_TRY return -1; } /* end test_selection_io() */ |