diff --git a/test/API/H5_api_async_test.c b/test/API/H5_api_async_test.c index 4ce9ecd7f62..26f699dcd13 100644 --- a/test/API/H5_api_async_test.c +++ b/test/API/H5_api_async_test.c @@ -12,40 +12,39 @@ #include "H5_api_async_test.h" -#ifdef H5ESpublic_H - -static int test_one_dataset_io(void); -static int test_multi_dataset_io(void); -static int test_multi_file_dataset_io(void); -static int test_multi_file_grp_dset_io(void); -static int test_set_extent(void); -static int test_attribute_exists(void); -static int test_attribute_io(void); -static int test_attribute_io_tconv(void); -static int test_attribute_io_compound(void); -static int test_group(void); -static int test_link(void); -static int test_ocopy_orefresh(void); -static int test_file_reopen(void); +static void print_async_test_header(void); -/* - * The array of async tests to be performed. - */ -static int (*async_tests[])(void) = { - test_one_dataset_io, - test_multi_dataset_io, - test_multi_file_dataset_io, - test_multi_file_grp_dset_io, - test_set_extent, - test_attribute_exists, - test_attribute_io, - test_attribute_io_tconv, - test_attribute_io_compound, - test_group, - test_link, - test_ocopy_orefresh, - test_file_reopen, -}; +static void +print_async_test_header(void) +{ + printf("\n"); + printf("**********************************************\n"); + printf("* *\n"); + printf("* API Async Tests *\n"); + printf("* *\n"); + printf("**********************************************\n\n"); + +#ifndef H5_API_TEST_HAVE_ASYNC + printf("SKIPPED due to no async support\n"); +#endif +} + +#ifdef H5_API_TEST_HAVE_ASYNC + +static void test_one_dataset_io(void); +static void test_multi_dataset_io(void); +static void test_multi_file_dataset_io(void); +static void test_multi_file_grp_dset_io(void); +static void test_set_extent(void); +static void test_attribute_exists(void); +static void test_attribute_io(void); +static void test_attribute_io_tconv(void); +static void test_attribute_io_compound(void); +static void test_group(void); +static void test_link(void); +static void test_ocopy_orefresh(void); +static void test_file_reopen(void); +static void test_file_cleanup(void); /* Highest "printf" file created (starting at 0) */ int max_printf_file = -1; @@ -53,7 +52,7 @@ int max_printf_file = -1; /* * Create file and dataset, write to dataset */ -static int +static void test_one_dataset_io(void) { hid_t file_id = H5I_INVALID_HID; @@ -62,7 +61,7 @@ test_one_dataset_io(void) hid_t es_id = H5I_INVALID_HID; hsize_t dims[2] = {6, 10}; size_t num_in_progress; - hbool_t op_failed; + bool op_failed; int wbuf[6][10]; int rbuf[6][10]; int i, j; @@ -70,11 +69,12 @@ test_one_dataset_io(void) TESTING_MULTIPART("single dataset I/O"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH)) { SKIPPED(); printf(" API functions for basic file, dataset, or flush aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -300,7 +300,7 @@ test_one_dataset_io(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -313,13 +313,13 @@ test_one_dataset_io(void) } H5E_END_TRY - return 1; + return; } /* end test_one_dataset_io() */ /* * Create file and multiple datasets, write to them and read from them */ -static int +static void test_multi_dataset_io(void) { hid_t file_id = H5I_INVALID_HID; @@ -328,21 +328,21 @@ test_multi_dataset_io(void) hid_t es_id = H5I_INVALID_HID; hsize_t dims[2] = {6, 10}; size_t num_in_progress; - hbool_t op_failed; - char dset_name[ASYNC_API_TEST_FILENAME_SIZE]; + bool op_failed; + char dset_name[32]; int wbuf[5][6][10]; int rbuf[5][6][10]; int i, j, k; - int chars_written; TESTING_MULTIPART("multi dataset I/O"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH)) { SKIPPED(); printf(" API functions for basic file, dataset, or flush aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -370,9 +370,7 @@ test_multi_dataset_io(void) /* Loop over datasets */ for (i = 0; i < 5; i++) { /* Set dataset name */ - if ((chars_written = snprintf(dset_name, ASYNC_API_TEST_FILENAME_SIZE, "dset%d", i)) < 0 || - chars_written >= ASYNC_API_TEST_FILENAME_SIZE) - PART_TEST_ERROR(multi_dset_open); + snprintf(dset_name, sizeof(dset_name), "dset%d", i); /* Create the dataset asynchronously */ if ((dset_id[i] = H5Dcreate_async(file_id, dset_name, H5T_NATIVE_INT, space_id, H5P_DEFAULT, @@ -453,9 +451,7 @@ test_multi_dataset_io(void) /* Loop over datasets */ for (i = 0; i < 5; i++) { /* Set dataset name */ - if ((chars_written = snprintf(dset_name, ASYNC_API_TEST_FILENAME_SIZE, "dset%d", i)) < 0 || - chars_written >= ASYNC_API_TEST_FILENAME_SIZE) - PART_TEST_ERROR(multi_dset_close); + snprintf(dset_name, sizeof(dset_name), "dset%d", i); /* Open the dataset asynchronously */ if ((dset_id[0] = H5Dopen_async(file_id, dset_name, H5P_DEFAULT, es_id)) < 0) @@ -484,9 +480,7 @@ test_multi_dataset_io(void) /* Loop over datasets */ for (i = 0; i < 5; i++) { /* Set dataset name */ - if ((chars_written = snprintf(dset_name, ASYNC_API_TEST_FILENAME_SIZE, "dset%d", i)) < 0 || - chars_written >= ASYNC_API_TEST_FILENAME_SIZE) - PART_TEST_ERROR(multi_dset_close); + snprintf(dset_name, sizeof(dset_name), "dset%d", i); /* Open the dataset asynchronously */ if ((dset_id[0] = H5Dopen_async(file_id, dset_name, H5P_DEFAULT, es_id)) < 0) @@ -559,7 +553,7 @@ test_multi_dataset_io(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -573,14 +567,14 @@ test_multi_dataset_io(void) } H5E_END_TRY - return 1; + return; } /* end test_multi_dataset_io() */ /* * Create multiple files, each with a single dataset, write to them and read * from them */ -static int +static void test_multi_file_dataset_io(void) { hid_t file_id[5] = {H5I_INVALID_HID, H5I_INVALID_HID, H5I_INVALID_HID, H5I_INVALID_HID, H5I_INVALID_HID}; @@ -589,21 +583,21 @@ test_multi_file_dataset_io(void) hid_t es_id = H5I_INVALID_HID; hsize_t dims[2] = {6, 10}; size_t num_in_progress; - hbool_t op_failed; - char file_name[ASYNC_API_TEST_FILENAME_SIZE]; + bool op_failed; + char file_name[32]; int wbuf[5][6][10]; int rbuf[5][6][10]; int i, j, k; - int chars_written; TESTING_MULTIPART("multi file dataset I/O"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH)) { SKIPPED(); printf(" API functions for basic file, dataset, or flush aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -627,9 +621,7 @@ test_multi_file_dataset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - if ((chars_written = snprintf(file_name, ASYNC_API_TEST_FILENAME_SIZE, ASYNC_API_TEST_FILE_PRINTF, i)) < 0 || - chars_written >= ASYNC_API_TEST_FILENAME_SIZE) - PART_TEST_ERROR(multi_file_dset_open); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Create file asynchronously */ if ((file_id[i] = @@ -771,9 +763,7 @@ test_multi_file_dataset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - if ((chars_written = snprintf(file_name, ASYNC_API_TEST_FILENAME_SIZE, ASYNC_API_TEST_FILE_PRINTF, i)) < 0 || - chars_written >= ASYNC_API_TEST_FILENAME_SIZE) - PART_TEST_ERROR(multi_file_dset_fclose); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Open the file asynchronously */ if ((file_id[0] = H5Fopen_async(file_name, H5F_ACC_RDWR, H5P_DEFAULT, es_id)) < 0) @@ -811,9 +801,7 @@ test_multi_file_dataset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - if ((chars_written = snprintf(file_name, ASYNC_API_TEST_FILENAME_SIZE, ASYNC_API_TEST_FILE_PRINTF, i)) < 0 || - chars_written >= ASYNC_API_TEST_FILENAME_SIZE) - PART_TEST_ERROR(multi_file_dset_fclose); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Open the file asynchronously */ if ((file_id[0] = H5Fopen_async(file_name, H5F_ACC_RDONLY, H5P_DEFAULT, es_id)) < 0) @@ -874,7 +862,7 @@ test_multi_file_dataset_io(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -889,14 +877,14 @@ test_multi_file_dataset_io(void) } H5E_END_TRY - return 1; + return; } /* end test_multi_file_dataset_io() */ /* * Create multiple files, each with a single group and dataset, write to them * and read from them */ -static int +static void test_multi_file_grp_dset_io(void) { hid_t file_id = H5I_INVALID_HID; @@ -906,21 +894,20 @@ test_multi_file_grp_dset_io(void) hid_t es_id = H5I_INVALID_HID; hsize_t dims[2] = {6, 10}; size_t num_in_progress; - hbool_t op_failed; - char file_name[ASYNC_API_TEST_FILENAME_SIZE]; + bool op_failed; + char file_name[32]; int wbuf[5][6][10]; int rbuf[5][6][10]; int i, j, k; - int chars_written; TESTING_MULTIPART("multi file dataset I/O with groups"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -944,9 +931,7 @@ test_multi_file_grp_dset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - if ((chars_written = snprintf(file_name, ASYNC_API_TEST_FILENAME_SIZE, ASYNC_API_TEST_FILE_PRINTF, i)) < 0 || - (chars_written >= ASYNC_API_TEST_FILENAME_SIZE)) - PART_TEST_ERROR(multi_file_grp_dset_no_kick); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Create file asynchronously */ if ((file_id = H5Fcreate_async(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT, es_id)) < @@ -998,9 +983,7 @@ test_multi_file_grp_dset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - if ((chars_written = snprintf(file_name, ASYNC_API_TEST_FILENAME_SIZE, ASYNC_API_TEST_FILE_PRINTF, i)) < 0 || - chars_written >= ASYNC_API_TEST_FILENAME_SIZE) - PART_TEST_ERROR(multi_file_grp_dset_no_kick); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Open the file asynchronously */ if ((file_id = H5Fopen_async(file_name, H5F_ACC_RDONLY, H5P_DEFAULT, es_id)) < 0) @@ -1058,9 +1041,7 @@ test_multi_file_grp_dset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - if ((chars_written = snprintf(file_name, ASYNC_API_TEST_FILENAME_SIZE, ASYNC_API_TEST_FILE_PRINTF, i)) < 0 || - chars_written >= ASYNC_API_TEST_FILENAME_SIZE) - PART_TEST_ERROR(multi_file_grp_dset_kick); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Create file asynchronously */ if ((file_id = H5Fcreate_async(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT, es_id)) < @@ -1117,9 +1098,7 @@ test_multi_file_grp_dset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - if ((chars_written = snprintf(file_name, ASYNC_API_TEST_FILENAME_SIZE, ASYNC_API_TEST_FILE_PRINTF, i)) < 0 || - chars_written >= ASYNC_API_TEST_FILENAME_SIZE) - PART_TEST_ERROR(multi_file_grp_dset_kick); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Open the file asynchronously */ if ((file_id = H5Fopen_async(file_name, H5F_ACC_RDONLY, H5P_DEFAULT, es_id)) < 0) @@ -1193,7 +1172,7 @@ test_multi_file_grp_dset_io(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1207,13 +1186,13 @@ test_multi_file_grp_dset_io(void) } H5E_END_TRY - return 1; + return; } /* end test_multi_file_grp_dset_io() */ /* * Create file and dataset, write to dataset */ -static int +static void test_set_extent(void) { hid_t file_id = H5I_INVALID_HID; @@ -1231,7 +1210,7 @@ test_set_extent(void) hsize_t start[2] = {0, 0}; hsize_t count[2] = {1, 10}; size_t num_in_progress; - hbool_t op_failed; + bool op_failed; htri_t tri_ret; int wbuf[6][10]; int rbuf[6][10]; @@ -1240,12 +1219,13 @@ test_set_extent(void) TESTING("H5Dset_extent() and H5Dget_space()"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { SKIPPED(); printf(" API functions for basic file, dataset, dataset more, or flush aren't supported with " "this connector\n"); - return 0; + return; } /* Create file dataspace */ @@ -1403,7 +1383,7 @@ test_set_extent(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1421,13 +1401,13 @@ test_set_extent(void) } H5E_END_TRY - return 1; + return; } /* end test_set_extent() */ /* * Test H5Aexists() */ -static int +static void test_attribute_exists(void) { hid_t file_id = H5I_INVALID_HID; @@ -1436,20 +1416,21 @@ test_attribute_exists(void) hid_t space_id = H5I_INVALID_HID; hid_t es_id = H5I_INVALID_HID; hsize_t dims[2] = {6, 10}; - hbool_t exists1; - hbool_t exists2; + bool exists1; + bool exists2; size_t num_in_progress; - hbool_t op_failed; + bool op_failed; TESTING("H5Aexists()"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { SKIPPED(); printf(" API functions for basic file, dataset, dataset more, attribute, or flush aren't " "supported with this connector\n"); - return 0; + return; } /* Create dataspace */ @@ -1502,9 +1483,9 @@ test_attribute_exists(void) /* Check if H5Aexists returned the correct values */ if (exists1) - FAIL_PUTS_ERROR(" H5Aexists returned TRUE for an attribute that should not exist"); + FAIL_PUTS_ERROR(" H5Aexists returned true for an attribute that should not exist"); if (!exists2) - FAIL_PUTS_ERROR(" H5Aexists returned FALSE for an attribute that should exist"); + FAIL_PUTS_ERROR(" H5Aexists returned false for an attribute that should exist"); /* Close */ if (H5Aclose_async(attr_id, es_id) < 0) @@ -1527,7 +1508,7 @@ test_attribute_exists(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1541,13 +1522,13 @@ test_attribute_exists(void) } H5E_END_TRY - return 1; + return; } /* end test_attribute_io() */ /* * Create file, dataset, and attribute, write to attribute */ -static int +static void test_attribute_io(void) { hid_t file_id = H5I_INVALID_HID; @@ -1557,7 +1538,7 @@ test_attribute_io(void) hid_t es_id = H5I_INVALID_HID; hsize_t dims[2] = {6, 10}; size_t num_in_progress; - hbool_t op_failed; + bool op_failed; int wbuf[6][10]; int rbuf[6][10]; int i, j; @@ -1565,12 +1546,13 @@ test_attribute_io(void) TESTING("attribute I/O"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { SKIPPED(); printf(" API functions for basic file, dataset, dataset more, attribute, or flush aren't " "supported with this connector\n"); - return 0; + return; } /* Create dataspace */ @@ -1670,7 +1652,7 @@ test_attribute_io(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1684,13 +1666,13 @@ test_attribute_io(void) } H5E_END_TRY - return 1; + return; } /* end test_attribute_io() */ /* * Create file, dataset, and attribute, write to attribute with type conversion */ -static int +static void test_attribute_io_tconv(void) { hid_t file_id = H5I_INVALID_HID; @@ -1699,7 +1681,7 @@ test_attribute_io_tconv(void) hid_t es_id = H5I_INVALID_HID; hsize_t dims[2] = {6, 10}; size_t num_in_progress; - hbool_t op_failed; + bool op_failed; int wbuf[6][10]; int rbuf[6][10]; int i, j; @@ -1707,12 +1689,12 @@ test_attribute_io_tconv(void) TESTING("attribute I/O with type conversion"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { SKIPPED(); printf( " API functions for basic file, attribute, or flush aren't supported with this connector\n"); - return 0; + return; } /* Create dataspace */ @@ -1806,7 +1788,7 @@ test_attribute_io_tconv(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1819,7 +1801,7 @@ test_attribute_io_tconv(void) } H5E_END_TRY - return 1; + return; } /* end test_attribute_io_tconv() */ /* @@ -1831,7 +1813,7 @@ typedef struct tattr_cmpd_t { int b; } tattr_cmpd_t; -static int +static void test_attribute_io_compound(void) { hid_t file_id = H5I_INVALID_HID; @@ -1844,7 +1826,7 @@ test_attribute_io_compound(void) hid_t es_id = H5I_INVALID_HID; hsize_t dims[2] = {6, 10}; size_t num_in_progress; - hbool_t op_failed; + bool op_failed; tattr_cmpd_t wbuf[6][10]; tattr_cmpd_t rbuf[6][10]; tattr_cmpd_t fbuf[6][10]; @@ -1853,12 +1835,12 @@ test_attribute_io_compound(void) TESTING("attribute I/O with compound type conversion"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { SKIPPED(); printf( " API functions for basic file, attribute, or flush aren't supported with this connector\n"); - return 0; + return; } /* Create datatype */ @@ -2118,7 +2100,7 @@ test_attribute_io_compound(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2135,13 +2117,13 @@ test_attribute_io_compound(void) } H5E_END_TRY - return 1; + return; } /* end test_attribute_io_compound() */ /* * Test group interfaces */ -static int +static void test_group(void) { hid_t file_id = H5I_INVALID_HID; @@ -2154,17 +2136,18 @@ test_group(void) H5G_info_t info2; H5G_info_t info3; size_t num_in_progress; - hbool_t op_failed; + bool op_failed; TESTING("group operations"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_MORE) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_MORE) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH)) { SKIPPED(); printf(" API functions for basic file, group, or group more aren't supported " "with this connector\n"); - return 0; + return; } /* Create GCPL */ @@ -2287,7 +2270,7 @@ test_group(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2302,40 +2285,40 @@ test_group(void) } H5E_END_TRY - return 1; + return; } /* end test_group() */ /* * Test link interfaces */ -static int +static void test_link(void) { - hid_t file_id = H5I_INVALID_HID; - hid_t parent_group_id = H5I_INVALID_HID; - hid_t group_id = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - hid_t es_id = H5I_INVALID_HID; - hbool_t existsh1; - hbool_t existsh2; - hbool_t existsh3; - hbool_t existss1; - hbool_t existss2; - hbool_t existss3; - size_t num_in_progress; - hbool_t op_failed; + hid_t file_id = H5I_INVALID_HID; + hid_t parent_group_id = H5I_INVALID_HID; + hid_t group_id = H5I_INVALID_HID; + hid_t gcpl_id = H5I_INVALID_HID; + hid_t es_id = H5I_INVALID_HID; + bool existsh1; + bool existsh2; + bool existsh3; + bool existss1; + bool existss2; + bool existss3; + size_t num_in_progress; + bool op_failed; TESTING("link operations"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_LINK_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_HARD_LINKS) || !(vol_cap_flags_g & H5VL_CAP_FLAG_SOFT_LINKS) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_LINK_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_HARD_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_SOFT_LINKS) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH) || !(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { SKIPPED(); printf(" API functions for basic file, link, hard link, soft link, flush, or creation order " "aren't supported with this connector\n"); - return 0; + return; } /* Create GCPL */ @@ -2454,17 +2437,17 @@ test_link(void) /* Check if existence returns were correct */ if (!existsh1) - FAIL_PUTS_ERROR(" link exists returned FALSE for link that should exist"); + FAIL_PUTS_ERROR(" link exists returned false for link that should exist"); if (!existss1) - FAIL_PUTS_ERROR(" link exists returned FALSE for link that should exist"); + FAIL_PUTS_ERROR(" link exists returned false for link that should exist"); if (!existsh2) - FAIL_PUTS_ERROR(" link exists returned FALSE for link that should exist"); + FAIL_PUTS_ERROR(" link exists returned false for link that should exist"); if (existss2) - FAIL_PUTS_ERROR(" link exists returned TRUE for link that should not exist"); + FAIL_PUTS_ERROR(" link exists returned true for link that should not exist"); if (existsh3) - FAIL_PUTS_ERROR(" link exists returned TRUE for link that should not exist"); + FAIL_PUTS_ERROR(" link exists returned true for link that should not exist"); if (existsh3) - FAIL_PUTS_ERROR(" link exists returned TRUE for link that should not exist"); + FAIL_PUTS_ERROR(" link exists returned true for link that should not exist"); /* Close */ if (H5Gclose_async(parent_group_id, es_id) < 0) @@ -2485,7 +2468,7 @@ test_link(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2499,13 +2482,13 @@ test_link(void) } H5E_END_TRY - return 1; + return; } /* end test_link() */ /* * Test H5Ocopy() and H5Orefresh() */ -static int +static void test_ocopy_orefresh(void) { hid_t file_id = H5I_INVALID_HID; @@ -2515,18 +2498,18 @@ test_ocopy_orefresh(void) hid_t es_id = H5I_INVALID_HID; hsize_t dims[2] = {6, 10}; size_t num_in_progress; - hbool_t op_failed; + bool op_failed; TESTING("H5Ocopy() and H5Orefresh()"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_OBJECT_MORE) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_OBJECT_MORE) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH)) { SKIPPED(); printf(" API functions for basic file, group, dataset, object more, flush, or refresh aren't " "supported with this connector\n"); - return 0; + return; } /* Create dataspace */ @@ -2601,7 +2584,7 @@ test_ocopy_orefresh(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2614,28 +2597,29 @@ test_ocopy_orefresh(void) } H5E_END_TRY - return 1; + return; } /* end test_ocopy_orefresh() */ /* * Test H5Freopen() */ -static int +static void test_file_reopen(void) { - hid_t file_id = H5I_INVALID_HID; - hid_t reopened_file_id = H5I_INVALID_HID; - hid_t es_id = H5I_INVALID_HID; - size_t num_in_progress; - hbool_t op_failed; + hid_t file_id = H5I_INVALID_HID; + hid_t reopened_file_id = H5I_INVALID_HID; + hid_t es_id = H5I_INVALID_HID; + size_t num_in_progress; + bool op_failed; TESTING("H5Freopen()"); /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_MORE)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_MORE)) { SKIPPED(); printf(" API functions for basic file or file more aren't supported with this connector\n"); - return 0; + return; } /* Create event stack */ @@ -2673,7 +2657,7 @@ test_file_reopen(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2685,70 +2669,60 @@ test_file_reopen(void) } H5E_END_TRY - return 1; + return; } /* end test_file_reopen() */ /* * Cleanup temporary test files */ static void -cleanup_files(void) +test_file_cleanup(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++) { - HDsnprintf(file_name, 64, ASYNC_API_TEST_FILE_PRINTF, i); - H5Fdelete(file_name, H5P_DEFAULT); - } /* end for */ + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); + remove_test_file(NULL, file_name); + } } -int -H5_api_async_test(void) +void +H5_api_async_test_add(void) { - size_t i; - int nerrors; - - printf("**********************************************\n"); - printf("* *\n"); - printf("* API Async Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); - - /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_ASYNC)) { - SKIPPED(); - printf(" Async APIs aren't supported with this connector\n"); - return 0; - } - - for (i = 0, nerrors = 0; i < ARRAY_LENGTH(async_tests); i++) { - nerrors += (*async_tests[i])() ? 1 : 0; - } - - printf("\n"); - - printf("Cleaning up testing files\n"); - cleanup_files(); - - return nerrors; + /* Add a fake test to print out a header to distinguish different test interfaces */ + AddTest("print_async_test_header", print_async_test_header, NULL, "Prints header for async tests", NULL); + + AddTest("test_one_dataset_io", test_one_dataset_io, NULL, "single dataset I/O", NULL); + AddTest("test_multi_dataset_io", test_multi_dataset_io, NULL, "multi dataset I/O", NULL); + AddTest("test_multi_file_dataset_io", test_multi_file_dataset_io, NULL, "multi file dataset I/O", NULL); + AddTest("test_multi_file_grp_dset_io", test_multi_file_grp_dset_io, NULL, + "multi file dataset I/O with groups", NULL); + AddTest("test_set_extent", test_set_extent, NULL, "H5Dset_extent() and H5Dget_space()", NULL); + AddTest("test_attribute_exists", test_attribute_exists, NULL, "H5Aexists()", NULL); + AddTest("test_attribute_io", test_attribute_io, NULL, "attribute I/O", NULL); + AddTest("test_attribute_io_tconv", test_attribute_io_tconv, NULL, "attribute I/O with type conversion", + NULL); + AddTest("test_attribute_io_compound", test_attribute_io_compound, NULL, + "attribute I/O with compound type conversion", NULL); + AddTest("test_group", test_group, NULL, "group operations", NULL); + AddTest("test_link", test_link, NULL, "link operations", NULL); + AddTest("test_ocopy_orefresh", test_ocopy_orefresh, NULL, "H5Ocopy() and H5Orefresh()", NULL); + AddTest("test_file_reopen", test_file_reopen, NULL, "H5Freopen()", NULL); + + /* Add a fake test to cleanup test files due to current test interdependencies */ + AddTest("test_file_cleanup", test_file_cleanup, NULL, "cleanup test files", NULL); } -#else /* H5ESpublic_H */ +#else /* H5_API_TEST_HAVE_ASYNC */ -int -H5_api_async_test(void) +void +H5_api_async_test_add(void) { - printf("**********************************************\n"); - printf("* *\n"); - printf("* API Async Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); - - printf("SKIPPED due to no async support in HDF5 library\n"); - - return 0; + /* Add a fake test to print out a header to distinguish different test interfaces */ + AddTest("print_async_test_header", print_async_test_header, NULL, "Prints header for async tests", NULL); } -#endif /* H5ESpublic_H */ +#endif /* H5_API_TEST_HAVE_ASYNC */ diff --git a/test/API/H5_api_async_test.h b/test/API/H5_api_async_test.h index 8bc89032ab0..1c2881d7699 100644 --- a/test/API/H5_api_async_test.h +++ b/test/API/H5_api_async_test.h @@ -15,7 +15,7 @@ #include "H5_api_test.h" -int H5_api_async_test(void); +void H5_api_async_test_add(void); /************************************************ * * @@ -25,5 +25,5 @@ int H5_api_async_test(void); #define ASYNC_API_TEST_FILE "H5_api_async_test.h5" #define ASYNC_API_TEST_FILE_PRINTF "H5_api_async_test_%d.h5" -#define ASYNC_API_TEST_FILENAME_SIZE 32 + #endif diff --git a/test/API/H5_api_attribute_test.c b/test/API/H5_api_attribute_test.c index aa7b6f88103..4d2a5185ff8 100644 --- a/test/API/H5_api_attribute_test.c +++ b/test/API/H5_api_attribute_test.c @@ -20,99 +20,112 @@ * order value gets reset when all attributes are removed. */ -static int test_create_attribute_on_root(void); -static int test_create_attribute_on_dataset(void); -static int test_create_attribute_on_datatype(void); -static int test_create_attribute_with_null_space(void); -static int test_create_attribute_with_scalar_space(void); -static int test_create_attribute_with_space_in_name(void); -static int test_create_attribute_invalid_params(void); -static int test_open_attribute(void); -static int test_open_attribute_invalid_params(void); -static int test_write_attribute(void); -static int test_write_attribute_invalid_params(void); -static int test_read_attribute(void); -static int test_read_attribute_invalid_params(void); -static int test_read_empty_attribute(void); -static int test_close_attribute_invalid_id(void); -static int test_get_attribute_space_and_type(void); -static int test_get_attribute_space_and_type_invalid_params(void); -static int test_attribute_property_lists(void); -static int test_get_attribute_name(void); -static int test_get_attribute_name_invalid_params(void); -static int test_get_attribute_storage_size(void); -static int test_get_attribute_info(void); -static int test_get_attribute_info_invalid_params(void); -static int test_rename_attribute(void); -static int test_rename_attribute_invalid_params(void); -static int test_attribute_iterate_group(void); -static int test_attribute_iterate_dataset(void); -static int test_attribute_iterate_datatype(void); -static int test_attribute_iterate_index_saving(void); -static int test_attribute_iterate_invalid_params(void); -static int test_attribute_iterate_0_attributes(void); -static int test_delete_attribute(void); -static int test_delete_attribute_invalid_params(void); -static int test_attribute_exists(void); -static int test_attribute_exists_invalid_params(void); -static int test_attribute_many(void); -static int test_attribute_duplicate_id(void); -static int test_get_number_attributes(void); -static int test_attr_shared_dtype(void); +static void print_attribute_test_header(void); +static void test_create_attribute_on_root(void); +static void test_create_attribute_on_dataset(void); +static void test_create_attribute_on_datatype(void); +static void test_create_attribute_with_null_space(void); +static void test_create_attribute_with_scalar_space(void); +static void test_create_attribute_with_space_in_name(void); +static void test_create_attribute_invalid_params(void); +static void test_open_attribute(void); +static void test_open_attribute_invalid_params(void); +static void test_write_attribute(void); +static void test_write_attribute_invalid_params(void); +static void test_read_attribute(void); +static void test_read_attribute_invalid_params(void); +static void test_read_empty_attribute(void); +static void test_close_attribute_invalid_id(void); +static void test_get_attribute_space_and_type(void); +static void test_get_attribute_space_and_type_invalid_params(void); +static void test_attribute_property_lists(void); +static void test_get_attribute_name(void); +static void test_get_attribute_name_invalid_params(void); +static void test_get_attribute_storage_size(void); +static void test_get_attribute_info(void); +static void test_get_attribute_info_invalid_params(void); +static void test_rename_attribute(void); +static void test_rename_attribute_invalid_params(void); +static void test_attribute_iterate_group(void); +static void test_attribute_iterate_dataset(void); +static void test_attribute_iterate_datatype(void); +static void test_attribute_iterate_index_saving(void); +static void test_attribute_iterate_invalid_params(void); +static void test_attribute_iterate_0_attributes(void); +static void test_attribute_compound_subset(void); +static void test_attribute_string_encodings(void); +static void test_delete_attribute(void); +static void test_delete_attribute_invalid_params(void); +static void test_attribute_exists(void); +static void test_attribute_exists_invalid_params(void); +static void test_attribute_many(void); +static void test_attribute_duplicate_id(void); +static void test_get_number_attributes(void); +static void test_attr_shared_dtype(void); + +MULTI_DECLARE(test_create_attribute_on_root) +MULTI_DECLARE(test_create_attribute_on_dataset) +MULTI_DECLARE(test_create_attribute_on_datatype) +MULTI_DECLARE(test_create_attribute_with_null_space) +MULTI_DECLARE(test_create_attribute_with_scalar_space) +MULTI_DECLARE(test_create_attribute_with_space_in_name) +MULTI_DECLARE(test_create_attribute_invalid_params) +MULTI_DECLARE(test_open_attribute) +MULTI_DECLARE(test_open_attribute_invalid_params) +MULTI_DECLARE(test_write_attribute) +MULTI_DECLARE(test_write_attribute_invalid_params) +MULTI_DECLARE(test_read_attribute) +MULTI_DECLARE(test_read_attribute_invalid_params) +MULTI_DECLARE(test_read_empty_attribute) +MULTI_DECLARE(test_close_attribute_invalid_id) +MULTI_DECLARE(test_get_attribute_space_and_type) +MULTI_DECLARE(test_get_attribute_space_and_type_invalid_params) +MULTI_DECLARE(test_attribute_property_lists) +MULTI_DECLARE(test_get_attribute_name) +MULTI_DECLARE(test_get_attribute_name_invalid_params) +MULTI_DECLARE(test_get_attribute_storage_size) +MULTI_DECLARE(test_get_attribute_info) +MULTI_DECLARE(test_get_attribute_info_invalid_params) +MULTI_DECLARE(test_rename_attribute) +MULTI_DECLARE(test_rename_attribute_invalid_params) +MULTI_DECLARE(test_attribute_iterate_group) +MULTI_DECLARE(test_attribute_iterate_dataset) +MULTI_DECLARE(test_attribute_iterate_datatype) +MULTI_DECLARE(test_attribute_iterate_index_saving) +MULTI_DECLARE(test_attribute_iterate_invalid_params) +MULTI_DECLARE(test_attribute_iterate_0_attributes) +MULTI_DECLARE(test_attribute_compound_subset) +MULTI_DECLARE(test_attribute_string_encodings) +MULTI_DECLARE(test_delete_attribute) +MULTI_DECLARE(test_delete_attribute_invalid_params) +MULTI_DECLARE(test_attribute_exists) +MULTI_DECLARE(test_attribute_exists_invalid_params) +MULTI_DECLARE(test_attribute_many) +MULTI_DECLARE(test_attribute_duplicate_id) +MULTI_DECLARE(test_get_number_attributes) +MULTI_DECLARE(test_attr_shared_dtype) static herr_t attr_iter_callback1(hid_t location_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data); static herr_t attr_iter_callback2(hid_t location_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data); -/* - * The array of attribute tests to be performed. - */ -static int (*attribute_tests[])(void) = {test_create_attribute_on_root, - test_create_attribute_on_dataset, - test_create_attribute_on_datatype, - test_create_attribute_with_null_space, - test_create_attribute_with_scalar_space, - test_create_attribute_with_space_in_name, - test_create_attribute_invalid_params, - test_open_attribute, - test_open_attribute_invalid_params, - test_write_attribute, - test_write_attribute_invalid_params, - test_read_attribute, - test_read_attribute_invalid_params, - test_read_empty_attribute, - test_close_attribute_invalid_id, - test_get_attribute_space_and_type, - test_get_attribute_space_and_type_invalid_params, - test_attribute_property_lists, - test_get_attribute_name, - test_get_attribute_name_invalid_params, - test_get_attribute_storage_size, - test_get_attribute_info, - test_get_attribute_info_invalid_params, - test_rename_attribute, - test_rename_attribute_invalid_params, - test_attribute_iterate_group, - test_attribute_iterate_dataset, - test_attribute_iterate_datatype, - test_attribute_iterate_index_saving, - test_attribute_iterate_invalid_params, - test_attribute_iterate_0_attributes, - test_delete_attribute, - test_delete_attribute_invalid_params, - test_attribute_exists, - test_attribute_exists_invalid_params, - test_attribute_duplicate_id, - test_attribute_many, - test_get_number_attributes, - test_attr_shared_dtype}; +static void +print_attribute_test_header(void) +{ + printf("\n"); + printf("**********************************************\n"); + printf("* *\n"); + printf("* API Attribute Tests *\n"); + printf("* *\n"); + printf("**********************************************\n\n"); +} /* * A test to check that an attribute can be created on * the root group. */ -static int +static void test_create_attribute_on_root(void) { htri_t attr_exists; @@ -127,7 +140,7 @@ test_create_attribute_on_root(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { SKIPPED(); printf(" API functions for basic file or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -138,12 +151,12 @@ test_create_attribute_on_root(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_CREATE_ON_ROOT_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_CREATE_ON_ROOT_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype1 = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype1 = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; - if ((attr_dtype2 = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype2 = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; PASSED(); @@ -228,7 +241,7 @@ test_create_attribute_on_root(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -242,14 +255,14 @@ test_create_attribute_on_root(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an attribute can be created on * a dataset. */ -static int +static void test_create_attribute_on_dataset(void) { htri_t attr_exists; @@ -271,7 +284,7 @@ test_create_attribute_on_dataset(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or attribute aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -296,17 +309,17 @@ test_create_attribute_on_dataset(void) } if ((dset_space_id = - generate_random_dataspace(ATTRIBUTE_CREATE_ON_DATASET_DSET_SPACE_RANK, NULL, NULL, FALSE)) < 0) + generate_random_dataspace(ATTRIBUTE_CREATE_ON_DATASET_DSET_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; if ((attr_space_id = - generate_random_dataspace(ATTRIBUTE_CREATE_ON_DATASET_ATTR_SPACE_RANK, NULL, NULL, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_CREATE_ON_DATASET_ATTR_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((attr_dtype1 = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype1 = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; - if ((attr_dtype2 = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype2 = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, ATTRIBUTE_CREATE_ON_DATASET_DSET_NAME, dset_dtype, dset_space_id, @@ -408,7 +421,7 @@ test_create_attribute_on_dataset(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -427,14 +440,14 @@ test_create_attribute_on_dataset(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an attribute can be created on * a committed datatype. */ -static int +static void test_create_attribute_on_datatype(void) { htri_t attr_exists; @@ -455,7 +468,7 @@ test_create_attribute_on_datatype(void) SKIPPED(); printf(" API functions for basic file, group, stored datatype, or attribute aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -479,7 +492,7 @@ test_create_attribute_on_datatype(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -492,12 +505,12 @@ test_create_attribute_on_datatype(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_CREATE_ON_DATATYPE_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_CREATE_ON_DATATYPE_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype1 = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype1 = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; - if ((attr_dtype2 = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype2 = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; PASSED(); @@ -585,7 +598,7 @@ test_create_attribute_on_datatype(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -602,14 +615,14 @@ test_create_attribute_on_datatype(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that creating an attribute with a * NULL dataspace is not problematic. */ -static int +static void test_create_attribute_with_null_space(void) { htri_t attr_exists; @@ -627,7 +640,7 @@ test_create_attribute_with_null_space(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -652,7 +665,7 @@ test_create_attribute_with_null_space(void) if ((space_id = H5Screate(H5S_NULL)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_CREATE_NULL_DATASPACE_TEST_ATTR_NAME, attr_dtype, space_id, @@ -699,7 +712,7 @@ test_create_attribute_with_null_space(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -713,14 +726,14 @@ test_create_attribute_with_null_space(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that creating an attribute with a * scalar dataspace is not problematic. */ -static int +static void test_create_attribute_with_scalar_space(void) { htri_t attr_exists; @@ -738,7 +751,7 @@ test_create_attribute_with_scalar_space(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -763,7 +776,7 @@ test_create_attribute_with_scalar_space(void) if ((space_id = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_CREATE_SCALAR_DATASPACE_TEST_ATTR_NAME, attr_dtype, @@ -810,7 +823,7 @@ test_create_attribute_with_scalar_space(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -824,14 +837,14 @@ test_create_attribute_with_scalar_space(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a space in an attribute's name * is not problematic. */ -static int +static void test_create_attribute_with_space_in_name(void) { htri_t attr_exists; @@ -851,7 +864,7 @@ test_create_attribute_with_space_in_name(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -874,10 +887,10 @@ test_create_attribute_with_space_in_name(void) } if ((space_id = - generate_random_dataspace(ATTRIBUTE_CREATE_WITH_SPACE_IN_NAME_SPACE_RANK, NULL, NULL, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_CREATE_WITH_SPACE_IN_NAME_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_CREATE_WITH_SPACE_IN_NAME_ATTR_NAME, attr_dtype, space_id, @@ -915,7 +928,7 @@ test_create_attribute_with_space_in_name(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -930,14 +943,14 @@ test_create_attribute_with_space_in_name(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an attribute can't be created when * H5Acreate is passed invalid parameters. */ -static int +static void test_create_attribute_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -954,7 +967,7 @@ test_create_attribute_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -978,10 +991,10 @@ test_create_attribute_invalid_params(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_CREATE_INVALID_PARAMS_SPACE_RANK, NULL, NULL, TRUE)) < + if ((space_id = generate_random_dataspace(ATTRIBUTE_CREATE_INVALID_PARAMS_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; PASSED(); @@ -1360,7 +1373,7 @@ test_create_attribute_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1374,13 +1387,13 @@ test_create_attribute_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Aopen(_by_idx). */ -static int +static void test_open_attribute(void) { hid_t file_id = H5I_INVALID_HID; @@ -1398,7 +1411,7 @@ test_open_attribute(void) SKIPPED(); printf(" API functions for basic file, group, or attribute aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1436,10 +1449,10 @@ test_open_attribute(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_OPEN_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_OPEN_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_type = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_type = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; /* Create several attributes */ @@ -1762,7 +1775,7 @@ test_open_attribute(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1777,14 +1790,14 @@ test_open_attribute(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an attribute can't be opened when * H5Aopen(_by_name/_by_idx) is passed invalid parameters. */ -static int +static void test_open_attribute_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -1801,7 +1814,7 @@ test_open_attribute_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1826,10 +1839,10 @@ test_open_attribute_invalid_params(void) } if ((space_id = - generate_random_dataspace(ATTRIBUTE_OPEN_INVALID_PARAMS_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_OPEN_INVALID_PARAMS_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_type = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_type = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_OPEN_INVALID_PARAMS_TEST_ATTR_NAME, attr_type, space_id, @@ -2278,7 +2291,7 @@ test_open_attribute_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2292,14 +2305,14 @@ test_open_attribute_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a simple write to an attribute * can be made. */ -static int +static void test_write_attribute(void) { hsize_t dims[ATTRIBUTE_WRITE_TEST_SPACE_RANK]; @@ -2320,7 +2333,7 @@ test_write_attribute(void) SKIPPED(); printf(" API functions for basic file, group, attribute, or file flush aren't supported with " "this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2342,7 +2355,7 @@ test_write_attribute(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_WRITE_TEST_SPACE_RANK, NULL, dims, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_WRITE_TEST_SPACE_RANK, NULL, dims, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_WRITE_TEST_ATTR_NAME, ATTRIBUTE_WRITE_TEST_ATTR_DTYPE, @@ -2406,7 +2419,7 @@ test_write_attribute(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2421,14 +2434,14 @@ test_write_attribute(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that writing an attribute fails when * H5Awrite is passed invalid parameters. */ -static int +static void test_write_attribute_invalid_params(void) { hsize_t dims[ATTRIBUTE_WRITE_INVALID_PARAMS_TEST_SPACE_RANK]; @@ -2450,7 +2463,7 @@ test_write_attribute_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -2475,7 +2488,7 @@ test_write_attribute_invalid_params(void) } if ((space_id = - generate_random_dataspace(ATTRIBUTE_WRITE_INVALID_PARAMS_TEST_SPACE_RANK, NULL, dims, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_WRITE_INVALID_PARAMS_TEST_SPACE_RANK, NULL, dims, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_WRITE_INVALID_PARAMS_TEST_ATTR_NAME, @@ -2595,7 +2608,7 @@ test_write_attribute_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2610,7 +2623,7 @@ test_write_attribute_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* @@ -2618,7 +2631,7 @@ test_write_attribute_invalid_params(void) * and verified after it has been written to an * attribute. */ -static int +static void test_read_attribute(void) { hsize_t dims[ATTRIBUTE_READ_TEST_SPACE_RANK]; @@ -2640,7 +2653,7 @@ test_read_attribute(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2662,7 +2675,7 @@ test_read_attribute(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_READ_TEST_SPACE_RANK, NULL, dims, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_READ_TEST_SPACE_RANK, NULL, dims, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_READ_TEST_ATTR_NAME, ATTRIBUTE_READ_TEST_ATTR_DTYPE, @@ -2749,7 +2762,7 @@ test_read_attribute(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2766,14 +2779,14 @@ test_read_attribute(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that reading an attribute fails when * H5Aread is passed invalid parameters. */ -static int +static void test_read_attribute_invalid_params(void) { hsize_t dims[ATTRIBUTE_READ_INVALID_PARAMS_TEST_SPACE_RANK]; @@ -2796,7 +2809,7 @@ test_read_attribute_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -2821,7 +2834,7 @@ test_read_attribute_invalid_params(void) } if ((space_id = - generate_random_dataspace(ATTRIBUTE_READ_INVALID_PARAMS_TEST_SPACE_RANK, NULL, dims, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_READ_INVALID_PARAMS_TEST_SPACE_RANK, NULL, dims, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_READ_INVALID_PARAMS_TEST_ATTR_NAME, @@ -2963,7 +2976,7 @@ test_read_attribute_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2980,13 +2993,13 @@ test_read_attribute_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * Test reading an empty attribute is ok */ -static int +static void test_read_empty_attribute(void) { hsize_t dims[ATTRIBUTE_READ_EMPTY_SPACE_RANK]; @@ -3007,7 +3020,7 @@ test_read_empty_attribute(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -3029,7 +3042,7 @@ test_read_empty_attribute(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_READ_EMPTY_SPACE_RANK, NULL, dims, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_READ_EMPTY_SPACE_RANK, NULL, dims, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_READ_EMPTY_ATTR_NAME, ATTRIBUTE_READ_EMPTY_DTYPE, space_id, @@ -3092,7 +3105,7 @@ test_read_empty_attribute(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3107,13 +3120,13 @@ test_read_empty_attribute(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Aclose fails when it is passed * an invalid attribute ID. */ -static int +static void test_close_attribute_invalid_id(void) { herr_t err_ret = -1; @@ -3125,7 +3138,7 @@ test_close_attribute_invalid_id(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { SKIPPED(); printf(" API functions for basic file or attribute aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -3151,7 +3164,7 @@ test_close_attribute_invalid_id(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3160,7 +3173,7 @@ test_close_attribute_invalid_id(void) } H5E_END_TRY - return 1; + return; } /* @@ -3168,7 +3181,7 @@ test_close_attribute_invalid_id(void) * dataspace and datatype can be retrieved with * H5Aget_space and H5Aget_type, respectively. */ -static int +static void test_get_attribute_space_and_type(void) { hsize_t attr_dims[ATTRIBUTE_GET_SPACE_TYPE_TEST_SPACE_RANK]; @@ -3191,7 +3204,7 @@ test_get_attribute_space_and_type(void) SKIPPED(); printf(" API functions for basic file, group, attribute, or attribute aren't supported with " "this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3216,10 +3229,10 @@ test_get_attribute_space_and_type(void) } if ((attr_space_id = - generate_random_dataspace(ATTRIBUTE_GET_SPACE_TYPE_TEST_SPACE_RANK, NULL, attr_dims, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_GET_SPACE_TYPE_TEST_SPACE_RANK, NULL, attr_dims, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_GET_SPACE_TYPE_TEST_ATTR_NAME, attr_dtype, attr_space_id, @@ -3449,7 +3462,7 @@ test_get_attribute_space_and_type(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3465,7 +3478,7 @@ test_get_attribute_space_and_type(void) } H5E_END_TRY - return 1; + return; } /* @@ -3473,7 +3486,7 @@ test_get_attribute_space_and_type(void) * can't be retrieved when H5Aget_space and H5Aget_type are passed * invalid parameters, respectively. */ -static int +static void test_get_attribute_space_and_type_invalid_params(void) { htri_t attr_exists; @@ -3494,7 +3507,7 @@ test_get_attribute_space_and_type_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3520,10 +3533,10 @@ test_get_attribute_space_and_type_invalid_params(void) } if ((attr_space_id = generate_random_dataspace(ATTRIBUTE_GET_SPACE_TYPE_INVALID_PARAMS_TEST_SPACE_RANK, - NULL, NULL, TRUE)) < 0) + NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_GET_SPACE_TYPE_INVALID_PARAMS_TEST_ATTR_NAME, attr_dtype, @@ -3610,7 +3623,7 @@ test_get_attribute_space_and_type_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3626,7 +3639,7 @@ test_get_attribute_space_and_type_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* @@ -3634,7 +3647,7 @@ test_get_attribute_space_and_type_invalid_params(void) * can be persisted and that a valid copy of that ACPL can * be retrieved later with a call to H5Aget_create_plist. */ -static int +static void test_attribute_property_lists(void) { H5T_cset_t encoding = H5T_CSET_UTF8; @@ -3654,7 +3667,7 @@ test_attribute_property_lists(void) SKIPPED(); printf(" API functions for basic file, group, attribute, or getting property list aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3678,12 +3691,12 @@ test_attribute_property_lists(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_PROPERTY_LIST_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_PROPERTY_LIST_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype1 = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype1 = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; - if ((attr_dtype2 = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype2 = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((acpl_id1 = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) { @@ -3893,7 +3906,7 @@ test_attribute_property_lists(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3911,7 +3924,7 @@ test_attribute_property_lists(void) } H5E_END_TRY - return 1; + return; } /* @@ -3919,7 +3932,7 @@ test_attribute_property_lists(void) * correctly retrieved with H5Aget_name and * H5Aget_name_by_idx. */ -static int +static void test_get_attribute_name(void) { ssize_t name_buf_size; @@ -3941,7 +3954,7 @@ test_get_attribute_name(void) SKIPPED(); printf(" API functions for basic file, group, or attribute aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3979,10 +3992,10 @@ test_get_attribute_name(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_GET_NAME_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_GET_NAME_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; /* Create several attributes */ @@ -4082,8 +4095,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME); @@ -4127,8 +4140,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_crt_order_increasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME); @@ -4145,8 +4158,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_crt_order_increasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2); @@ -4163,8 +4176,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_crt_order_increasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3); @@ -4195,8 +4208,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_crt_order_decreasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME); @@ -4213,8 +4226,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_crt_order_decreasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2); @@ -4231,8 +4244,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_crt_order_decreasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3); @@ -4257,8 +4270,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_name_order_increasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME); @@ -4275,8 +4288,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_name_order_increasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2); @@ -4293,8 +4306,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_name_order_increasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3); @@ -4319,8 +4332,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_name_order_decreasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME); @@ -4337,8 +4350,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_name_order_decreasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME2); @@ -4355,8 +4368,8 @@ test_get_attribute_name(void) PART_ERROR(H5Aget_name_by_idx_name_order_decreasing); } - if (HDstrncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3, - strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3) + 1)) { + if (strncmp(name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3, + strlen(ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3) + 1)) { H5_FAILED(); printf(" retrieved attribute name '%s' didn't match '%s'\n", name_buf, ATTRIBUTE_GET_NAME_TEST_ATTRIBUTE_NAME3); @@ -4391,7 +4404,7 @@ test_get_attribute_name(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -4408,7 +4421,7 @@ test_get_attribute_name(void) } H5E_END_TRY - return 1; + return; } /* @@ -4416,7 +4429,7 @@ test_get_attribute_name(void) * retrieved when H5Aget_name(_by_idx) is passed invalid * parameters. */ -static int +static void test_get_attribute_name_invalid_params(void) { ssize_t name_buf_size; @@ -4437,7 +4450,7 @@ test_get_attribute_name_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -4463,10 +4476,10 @@ test_get_attribute_name_invalid_params(void) } if ((space_id = generate_random_dataspace(ATTRIBUTE_GET_NAME_INVALID_PARAMS_TEST_SPACE_RANK, NULL, NULL, - TRUE)) < 0) + true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_GET_NAME_INVALID_PARAMS_TEST_ATTRIBUTE_NAME, attr_dtype, @@ -4750,7 +4763,7 @@ test_get_attribute_name_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -4766,26 +4779,26 @@ test_get_attribute_name_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Aget_storage_size. */ -static int +static void test_get_attribute_storage_size(void) { TESTING("H5Aget_storage_size"); SKIPPED(); - return 0; + return; } /* * A test to check the functionality of H5Aget_info(_by_idx). */ -static int +static void test_get_attribute_info(void) { H5A_info_t attr_info; @@ -4806,7 +4819,7 @@ test_get_attribute_info(void) SKIPPED(); printf(" API functions for basic file, group, or attribute aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -4844,10 +4857,10 @@ test_get_attribute_info(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_GET_INFO_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_GET_INFO_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; /* Create several attributes */ @@ -5411,7 +5424,7 @@ test_get_attribute_info(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -5426,14 +5439,14 @@ test_get_attribute_info(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Aget_info(_by_name/_by_idx) * doesn't succeed when passed invalid parameters. */ -static int +static void test_get_attribute_info_invalid_params(void) { H5A_info_t attr_info; @@ -5454,7 +5467,7 @@ test_get_attribute_info_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -5480,10 +5493,10 @@ test_get_attribute_info_invalid_params(void) } if ((space_id = generate_random_dataspace(ATTRIBUTE_GET_INFO_INVALID_PARAMS_TEST_SPACE_RANK, NULL, NULL, - TRUE)) < 0) + true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_GET_INFO_INVALID_PARAMS_TEST_ATTR_NAME, attr_dtype, @@ -5874,7 +5887,7 @@ test_get_attribute_info_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -5888,14 +5901,14 @@ test_get_attribute_info_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an attribute can be renamed * with H5Arename and H5Arename_by_name. */ -static int +static void test_rename_attribute(void) { htri_t attr_exists; @@ -5914,7 +5927,7 @@ test_rename_attribute(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -5938,10 +5951,10 @@ test_rename_attribute(void) goto error; } - if ((attr_space_id = generate_random_dataspace(ATTRIBUTE_RENAME_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((attr_space_id = generate_random_dataspace(ATTRIBUTE_RENAME_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_RENAME_TEST_ATTR_NAME, attr_dtype, attr_space_id, @@ -6090,7 +6103,7 @@ test_rename_attribute(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6105,14 +6118,14 @@ test_rename_attribute(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an attribute can't be renamed * when H5Arename(_by_name) is passed invalid parameters. */ -static int +static void test_rename_attribute_invalid_params(void) { htri_t attr_exists; @@ -6132,7 +6145,7 @@ test_rename_attribute_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -6157,10 +6170,10 @@ test_rename_attribute_invalid_params(void) } if ((attr_space_id = generate_random_dataspace(ATTRIBUTE_RENAME_INVALID_PARAMS_TEST_SPACE_RANK, NULL, - NULL, TRUE)) < 0) + NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_RENAME_INVALID_PARAMS_TEST_ATTR_NAME, attr_dtype, @@ -6459,7 +6472,7 @@ test_rename_attribute_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6474,7 +6487,7 @@ test_rename_attribute_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* @@ -6484,7 +6497,7 @@ test_rename_attribute_invalid_params(void) * order of both attribute name and attribute * creation order. */ -static int +static void test_attribute_iterate_group(void) { size_t link_counter; @@ -6505,7 +6518,7 @@ test_attribute_iterate_group(void) SKIPPED(); printf(" API functions for basic file, group, attribute, or iterate aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -6543,18 +6556,18 @@ test_attribute_iterate_group(void) goto error; } - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_space_id = - generate_random_dataspace(ATTRIBUTE_ITERATE_TEST_ATTR_SPACE_RANK, NULL, NULL, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_ITERATE_TEST_ATTR_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; /* Create some attributes with a reverse-ordering naming scheme to test creation order */ for (i = 0; i < ATTRIBUTE_ITERATE_TEST_NUM_ATTRS; i++) { char attr_name[ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE]; - HDsnprintf(attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE, - ATTRIBUTE_ITERATE_TEST_ATTR_NAME "%d", (int)(ATTRIBUTE_ITERATE_TEST_NUM_ATTRS - i - 1)); + snprintf(attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE, ATTRIBUTE_ITERATE_TEST_ATTR_NAME "%d", + (int)(ATTRIBUTE_ITERATE_TEST_NUM_ATTRS - i - 1)); if ((attr_id = H5Acreate2(group_id, attr_name, attr_dtype, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -6851,7 +6864,7 @@ test_attribute_iterate_group(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6866,7 +6879,7 @@ test_attribute_iterate_group(void) } H5E_END_TRY - return 1; + return; } /* @@ -6876,7 +6889,7 @@ test_attribute_iterate_group(void) * order of both attribute name and attribute * creation order. */ -static int +static void test_attribute_iterate_dataset(void) { size_t link_counter; @@ -6901,7 +6914,7 @@ test_attribute_iterate_dataset(void) SKIPPED(); printf(" API functions for basic file, group, dataset, attribute, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -6939,16 +6952,16 @@ test_attribute_iterate_dataset(void) } } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((dset_space_id = - generate_random_dataspace(ATTRIBUTE_ITERATE_TEST_DSET_SPACE_RANK, NULL, NULL, FALSE)) < 0) + generate_random_dataspace(ATTRIBUTE_ITERATE_TEST_DSET_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; if ((attr_space_id = - generate_random_dataspace(ATTRIBUTE_ITERATE_TEST_ATTR_SPACE_RANK, NULL, NULL, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_ITERATE_TEST_ATTR_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, ATTRIBUTE_ITERATE_TEST_DSET_NAME, dset_dtype, dset_space_id, @@ -6962,8 +6975,8 @@ test_attribute_iterate_dataset(void) for (i = 0; i < ATTRIBUTE_ITERATE_TEST_NUM_ATTRS; i++) { char attr_name[ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE]; - HDsnprintf(attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE, - ATTRIBUTE_ITERATE_TEST_ATTR_NAME "%d", (int)(ATTRIBUTE_ITERATE_TEST_NUM_ATTRS - i - 1)); + snprintf(attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE, ATTRIBUTE_ITERATE_TEST_ATTR_NAME "%d", + (int)(ATTRIBUTE_ITERATE_TEST_NUM_ATTRS - i - 1)); if ((attr_id = H5Acreate2(dset_id, attr_name, attr_dtype, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -7272,7 +7285,7 @@ test_attribute_iterate_dataset(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -7290,7 +7303,7 @@ test_attribute_iterate_dataset(void) } H5E_END_TRY - return 1; + return; } /* @@ -7300,7 +7313,7 @@ test_attribute_iterate_dataset(void) * decreasing order of both attribute name and attribute * creation order. */ -static int +static void test_attribute_iterate_datatype(void) { size_t link_counter; @@ -7323,7 +7336,7 @@ test_attribute_iterate_datatype(void) SKIPPED(); printf(" API functions for basic file, group, stored datatype, attribute, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -7361,13 +7374,13 @@ test_attribute_iterate_datatype(void) } } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_space_id = - generate_random_dataspace(ATTRIBUTE_ITERATE_TEST_ATTR_SPACE_RANK, NULL, NULL, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_ITERATE_TEST_ATTR_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; if (H5Tcommit2(group_id, ATTRIBUTE_ITERATE_TEST_DTYPE_NAME, type_id, H5P_DEFAULT, tcpl_id, H5P_DEFAULT) < @@ -7381,8 +7394,8 @@ test_attribute_iterate_datatype(void) for (i = 0; i < ATTRIBUTE_ITERATE_TEST_NUM_ATTRS; i++) { char attr_name[ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE]; - HDsnprintf(attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE, - ATTRIBUTE_ITERATE_TEST_ATTR_NAME "%d", (int)(ATTRIBUTE_ITERATE_TEST_NUM_ATTRS - i - 1)); + snprintf(attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE, ATTRIBUTE_ITERATE_TEST_ATTR_NAME "%d", + (int)(ATTRIBUTE_ITERATE_TEST_NUM_ATTRS - i - 1)); if ((attr_id = H5Acreate2(type_id, attr_name, attr_dtype, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -7689,7 +7702,7 @@ test_attribute_iterate_datatype(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -7705,7 +7718,7 @@ test_attribute_iterate_datatype(void) } H5E_END_TRY - return 1; + return; } /* @@ -7715,14 +7728,14 @@ test_attribute_iterate_datatype(void) * order of both attribute name and attribute * creation order. */ -static int +static void test_attribute_iterate_index_saving(void) { TESTING("attribute iteration index saving capability"); SKIPPED(); - return 1; + return; } /* @@ -7730,7 +7743,7 @@ test_attribute_iterate_index_saving(void) * be iterated over when H5Aiterate(_by_name) is * passed invalid parameters. */ -static int +static void test_attribute_iterate_invalid_params(void) { herr_t err_ret = -1; @@ -7750,7 +7763,7 @@ test_attribute_iterate_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, attribute, or iterate aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -7774,11 +7787,11 @@ test_attribute_iterate_invalid_params(void) goto error; } - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_space_id = generate_random_dataspace(ATTRIBUTE_ITERATE_INVALID_PARAMS_TEST_ATTR_SPACE_RANK, - NULL, NULL, TRUE)) < 0) + NULL, NULL, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_ITERATE_INVALID_PARAMS_TEST_ATTR_NAME, attr_dtype, @@ -8126,7 +8139,7 @@ test_attribute_iterate_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -8143,7 +8156,7 @@ test_attribute_iterate_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* @@ -8151,7 +8164,7 @@ test_attribute_iterate_invalid_params(void) * on an object with no attributes attached to it is * not problematic. */ -static int +static void test_attribute_iterate_0_attributes(void) { hid_t file_id = H5I_INVALID_HID; @@ -8169,7 +8182,7 @@ test_attribute_iterate_0_attributes(void) SKIPPED(); printf(" API functions for basic file, group, dataset, attribute, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -8193,11 +8206,11 @@ test_attribute_iterate_0_attributes(void) goto error; } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_space_id = generate_random_dataspace(ATTRIBUTE_ITERATE_TEST_0_ATTRIBUTES_DSET_SPACE_RANK, NULL, - NULL, FALSE)) < 0) + NULL, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, ATTRIBUTE_ITERATE_TEST_0_ATTRIBUTES_DSET_NAME, dset_dtype, @@ -8316,7 +8329,7 @@ test_attribute_iterate_0_attributes(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -8330,14 +8343,541 @@ test_attribute_iterate_0_attributes(void) } H5E_END_TRY - return 1; + return; +} + +/* A compound type for test_attribute_compound_subset */ +typedef struct attribute_compound_io_t { + int a; + int b; +} attribute_compound_io_t; + +/* + * A test to ensure that data is read back correctly from a attribute after it has + * been written, using subsets of compound datatypes + */ +static void +test_attribute_compound_subset(void) +{ + hsize_t dims[1] = {ATTRIBUTE_COMPOUND_IO_ATTR_DIMS}; + size_t i; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t full_type_id = H5I_INVALID_HID; + hid_t a_type_id = H5I_INVALID_HID; + hid_t b_type_id = H5I_INVALID_HID; + attribute_compound_io_t wbuf[ATTRIBUTE_COMPOUND_IO_ATTR_DIMS]; + attribute_compound_io_t rbuf[ATTRIBUTE_COMPOUND_IO_ATTR_DIMS]; + attribute_compound_io_t fbuf[ATTRIBUTE_COMPOUND_IO_ATTR_DIMS]; + attribute_compound_io_t erbuf[ATTRIBUTE_COMPOUND_IO_ATTR_DIMS]; + + TESTING_MULTIPART( + "verification of attribute data using H5Awrite then H5Aread with compound type subsets"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { + SKIPPED(); + printf( + " API functions for basic file, group, or attribute aren't supported with this connector\n"); + return; + } + + TESTING_2("test setup"); + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, ATTRIBUTE_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", ATTRIBUTE_TEST_GROUP_NAME); + goto error; + } + + if ((group_id = H5Gcreate2(container_group, ATTRIBUTE_COMPOUND_IO_TEST_GROUP_NAME, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", ATTRIBUTE_COMPOUND_IO_TEST_GROUP_NAME); + goto error; + } + + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR; + + if ((full_type_id = H5Tcreate(H5T_COMPOUND, sizeof(attribute_compound_io_t))) < 0) + TEST_ERROR; + if (H5Tinsert(full_type_id, "a", HOFFSET(attribute_compound_io_t, a), H5T_NATIVE_INT) < 0) + TEST_ERROR; + if (H5Tinsert(full_type_id, "b", HOFFSET(attribute_compound_io_t, b), H5T_NATIVE_INT) < 0) + TEST_ERROR; + + if ((a_type_id = H5Tcreate(H5T_COMPOUND, sizeof(attribute_compound_io_t))) < 0) + TEST_ERROR; + if (H5Tinsert(a_type_id, "a", HOFFSET(attribute_compound_io_t, a), H5T_NATIVE_INT) < 0) + TEST_ERROR; + + if ((b_type_id = H5Tcreate(H5T_COMPOUND, sizeof(attribute_compound_io_t))) < 0) + TEST_ERROR; + if (H5Tinsert(b_type_id, "b", HOFFSET(attribute_compound_io_t, b), H5T_NATIVE_INT) < 0) + TEST_ERROR; + + if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_COMPOUND_IO_TEST_ATTR_NAME, full_type_id, space_id, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create attribute '%s'\n", ATTRIBUTE_COMPOUND_IO_TEST_ATTR_NAME); + goto error; + } + + PASSED(); + + BEGIN_MULTIPART + { + PART_BEGIN(write_full_read_full) + { + TESTING_2("H5Awrite then H5Aread with all compound members"); + + /* Initialize wbuf */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + wbuf[i].a = (int)(2 * i); + wbuf[i].b = (int)(2 * i + 1); + } + + /* Write data */ + if (H5Awrite(attr_id, full_type_id, wbuf) < 0) + PART_TEST_ERROR(write_full_read_full); + + /* Update fbuf to match file state */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + fbuf[i].a = wbuf[i].a; + fbuf[i].b = wbuf[i].b; + } + + /* Initialize rbuf to -1 */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + rbuf[i].a = -1; + rbuf[i].b = -1; + } + + /* Set erbuf (simply match file state since we're reading the whole + * thing) */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + erbuf[i].a = fbuf[i].a; + erbuf[i].b = fbuf[i].b; + } + + /* Read data */ + if (H5Aread(attr_id, full_type_id, rbuf) < 0) + PART_TEST_ERROR(write_full_read_full); + + /* Verify data */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + if (rbuf[i].a != erbuf[i].a) + PART_TEST_ERROR(write_full_read_full); + if (rbuf[i].b != erbuf[i].b) + PART_TEST_ERROR(write_full_read_full); + } + + PASSED(); + } + PART_END(write_full_read_full); + + PART_BEGIN(read_a) + { + TESTING_2("H5Aread with compound member a"); + + /* Initialize rbuf to -1 */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + rbuf[i].a = -1; + rbuf[i].b = -1; + } + + /* Set erbuf (element a comes from the file, element b in untouched) + */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + erbuf[i].a = fbuf[i].a; + erbuf[i].b = rbuf[i].b; + } + + /* Read data */ + if (H5Aread(attr_id, a_type_id, rbuf) < 0) + PART_TEST_ERROR(read_a); + + /* Verify data */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + if (rbuf[i].a != erbuf[i].a) + PART_TEST_ERROR(read_a); + if (rbuf[i].b != erbuf[i].b) + PART_TEST_ERROR(read_a); + } + + PASSED(); + } + PART_END(read_a); + + PART_BEGIN(write_b_read_full) + { + TESTING_2("H5Awrite with compound member b then H5Aread with all compound members"); + + /* Initialize wbuf */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + wbuf[i].a = (int)(2 * ATTRIBUTE_COMPOUND_IO_ATTR_DIMS + 2 * i); + wbuf[i].b = (int)(2 * ATTRIBUTE_COMPOUND_IO_ATTR_DIMS + 2 * i + 1); + } + + /* Write data */ + if (H5Awrite(attr_id, b_type_id, wbuf) < 0) + PART_TEST_ERROR(write_b_read_full); + + /* Update fbuf to match file state - only element b was updated */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + fbuf[i].b = wbuf[i].b; + } + + /* Initialize rbuf to -1 */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + rbuf[i].a = -1; + rbuf[i].b = -1; + } + + /* Set erbuf (simply match file state since we're reading the whole + * thing) */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + erbuf[i].a = fbuf[i].a; + erbuf[i].b = fbuf[i].b; + } + + /* Read data */ + if (H5Aread(attr_id, full_type_id, rbuf) < 0) + PART_TEST_ERROR(write_b_read_full); + + /* Verify data */ + for (i = 0; i < ATTRIBUTE_COMPOUND_IO_ATTR_DIMS; i++) { + if (rbuf[i].a != erbuf[i].a) + PART_TEST_ERROR(write_b_read_full); + if (rbuf[i].b != erbuf[i].b) + PART_TEST_ERROR(write_b_read_full); + } + + PASSED(); + } + PART_END(write_b_read_full); + } + END_MULTIPART; + + TESTING_2("test cleanup"); + + if (H5Sclose(space_id) < 0) + TEST_ERROR; + if (H5Aclose(attr_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (H5Tclose(full_type_id) < 0) + TEST_ERROR; + if (H5Tclose(a_type_id) < 0) + TEST_ERROR; + if (H5Tclose(b_type_id) < 0) + TEST_ERROR; + + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + H5Sclose(space_id); + H5Aclose(attr_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + H5Tclose(full_type_id); + H5Tclose(a_type_id); + H5Tclose(b_type_id); + } + H5E_END_TRY; + + return; +} + +/* + * A test to check that attributes preserve data + * correctness for strings with ASCII or UTF-8 char sets + */ +static void +test_attribute_string_encodings(void) +{ + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID; + hid_t dset_id1 = H5I_INVALID_HID; + hid_t dset_id2 = H5I_INVALID_HID; + hid_t type_id1 = H5I_INVALID_HID; + hid_t type_id2 = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t attr_id1 = H5I_INVALID_HID; + hid_t attr_id2 = H5I_INVALID_HID; + hsize_t dims[ATTRIBUTE_STRING_ENCODINGS_RANK] = {ATTRIBUTE_STRING_ENCODINGS_EXTENT}; + size_t ascii_str_size = 0; + size_t utf8_str_size = 0; + char *write_buf = NULL; + char *read_buf = NULL; + + TESTING_MULTIPART("string encoding read/write correctness on attributes"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, basic or more dataset aren't supported with this " + "connector\n"); + return; + } + + TESTING_2("test setup"); + + ascii_str_size = strlen(ATTRIBUTE_STRING_ENCODINGS_ASCII_STRING); + utf8_str_size = strlen(ATTRIBUTE_STRING_ENCODINGS_UTF8_STRING); + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, ATTRIBUTE_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", ATTRIBUTE_TEST_GROUP_NAME); + goto error; + } + + if ((space_id = H5Screate_simple(ATTRIBUTE_STRING_ENCODINGS_RANK, dims, NULL)) < 0) { + H5_FAILED(); + printf(" couldn't create dataspace\n"); + goto error; + } + + if ((type_id1 = H5Tcopy(H5T_C_S1)) < 0) { + H5_FAILED(); + printf(" couldn't copy builtin string datatype\n"); + goto error; + } + + if ((H5Tset_size(type_id1, ascii_str_size)) < 0) { + H5_FAILED(); + printf(" couldn't set size of string datatype\n"); + goto error; + } + + if ((H5Tset_cset(type_id1, H5T_CSET_ASCII)) < 0) { + H5_FAILED(); + printf(" couldn't set character set of string to ASCII\n"); + goto error; + } + + if ((dset_id1 = H5Dcreate(container_group, ATTRIBUTE_STRING_ENCODINGS_DSET_NAME1, type_id1, space_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with ascii string\n"); + goto error; + } + + if ((attr_id1 = H5Acreate(dset_id1, ATTRIBUTE_STRING_ENCODINGS_ATTR_NAME1, type_id1, space_id, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create attribute with ascii string\n"); + goto error; + } + + if ((type_id2 = H5Tcopy(H5T_C_S1)) < 0) { + H5_FAILED(); + printf(" couldn't copy builtin string datatype\n"); + goto error; + } + + if ((H5Tset_size(type_id2, utf8_str_size)) < 0) { + H5_FAILED(); + printf(" couldn't set size of string datatype\n"); + goto error; + } + + if ((H5Tset_cset(type_id2, H5T_CSET_UTF8)) < 0) { + H5_FAILED(); + printf(" couldn't set character set of string to UTF-8\n"); + goto error; + } + + if ((dset_id2 = H5Dcreate(container_group, ATTRIBUTE_STRING_ENCODINGS_DSET_NAME2, type_id2, space_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with UTF-8 string\n"); + goto error; + } + + if ((attr_id2 = H5Acreate(dset_id2, ATTRIBUTE_STRING_ENCODINGS_ATTR_NAME2, type_id2, space_id, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create attribute with ascii string\n"); + goto error; + } + + PASSED(); + + BEGIN_MULTIPART + { + PART_BEGIN(ASCII_cset) + { + TESTING_2("ASCII character set"); + if ((write_buf = calloc(1, ascii_str_size + 1)) == NULL) { + H5_FAILED(); + printf(" couldn't allocate memory for write buffer\n"); + PART_ERROR(ASCII_cset); + } + + memcpy(write_buf, ATTRIBUTE_STRING_ENCODINGS_ASCII_STRING, ascii_str_size); + + if ((read_buf = calloc(1, ascii_str_size + 1)) == NULL) { + H5_FAILED(); + printf(" couldn't allocate memory for read buffer\n"); + PART_ERROR(ASCII_cset); + } + + if (H5Awrite(attr_id1, type_id1, write_buf) < 0) { + H5_FAILED(); + printf(" couldn't write to attribute with ASCII string\n"); + PART_ERROR(ASCII_cset); + } + + if (H5Aread(attr_id1, type_id1, read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from attribute with ASCII string\n"); + PART_ERROR(ASCII_cset); + } + + if (strncmp(write_buf, read_buf, ascii_str_size)) { + H5_FAILED(); + printf(" incorrect data read from attribute with ASCII string\n"); + PART_ERROR(ASCII_cset); + } + + free(write_buf); + write_buf = NULL; + + free(read_buf); + read_buf = NULL; + + PASSED(); + } + PART_END(ASCII_cset); + + PART_BEGIN(UTF8_cset) + { + TESTING_2("UTF-8 character set"); + + if ((write_buf = calloc(1, utf8_str_size + 1)) == NULL) { + H5_FAILED(); + printf(" couldn't allocate memory for write buffer\n"); + PART_ERROR(UTF8_cset); + } + + memcpy(write_buf, ATTRIBUTE_STRING_ENCODINGS_UTF8_STRING, utf8_str_size); + + if ((read_buf = calloc(1, utf8_str_size + 1)) == NULL) { + H5_FAILED(); + printf(" couldn't allocate memory for read buffer\n"); + PART_ERROR(UTF8_cset); + } + + if (H5Awrite(attr_id2, type_id2, write_buf) < 0) { + H5_FAILED(); + printf(" couldn't write to attribute with UTF-8 string\n"); + PART_ERROR(UTF8_cset); + } + + if (H5Aread(attr_id2, type_id2, read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from attribute with UTF-8 string\n"); + PART_ERROR(UTF8_cset); + } + + if (strncmp(write_buf, read_buf, utf8_str_size)) { + H5_FAILED(); + printf(" incorrect data read from attribute with UTF-8 string\n"); + PART_ERROR(UTF8_cset); + } + + free(write_buf); + write_buf = NULL; + + free(read_buf); + read_buf = NULL; + + PASSED(); + } + PART_END(UTF8_cset); + } + END_MULTIPART; + + TESTING_2("test cleanup"); + + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Dclose(dset_id1) < 0) + TEST_ERROR; + if (H5Dclose(dset_id2) < 0) + TEST_ERROR; + if (H5Tclose(type_id1) < 0) + TEST_ERROR; + if (H5Tclose(type_id2) < 0) + TEST_ERROR; + if (H5Aclose(attr_id1) < 0) + TEST_ERROR; + if (H5Aclose(attr_id2) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (write_buf) + free(write_buf); + if (read_buf) + free(read_buf); + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + H5Gclose(container_group); + H5Dclose(dset_id1); + H5Dclose(dset_id2); + H5Tclose(type_id1); + H5Tclose(type_id2); + H5Aclose(attr_id1); + H5Aclose(attr_id2); + H5Fclose(file_id); + if (write_buf) + free(write_buf); + if (read_buf) + free(read_buf); + } + H5E_END_TRY; + + return; } /* * A test to check that an attribute can be deleted * using H5Adelete(_by_idx). */ -static int +static void test_delete_attribute(void) { htri_t attr_exists; @@ -8357,7 +8897,7 @@ test_delete_attribute(void) SKIPPED(); printf(" API functions for basic file, group, or attribute aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -8395,10 +8935,10 @@ test_delete_attribute(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_DELETION_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_DELETION_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; PASSED(); @@ -9547,7 +10087,7 @@ test_delete_attribute(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -9562,7 +10102,7 @@ test_delete_attribute(void) } H5E_END_TRY - return 1; + return; } /* @@ -9570,7 +10110,7 @@ test_delete_attribute(void) * when H5Adelete(_by_name/_by_idx) is passed invalid * parameters. */ -static int +static void test_delete_attribute_invalid_params(void) { herr_t err_ret = -1; @@ -9590,7 +10130,7 @@ test_delete_attribute_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -9616,10 +10156,10 @@ test_delete_attribute_invalid_params(void) } if ((space_id = generate_random_dataspace(ATTRIBUTE_DELETION_INVALID_PARAMS_TEST_SPACE_RANK, NULL, NULL, - TRUE)) < 0) + true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_DELETION_INVALID_PARAMS_TEST_ATTR_NAME, attr_dtype, @@ -9968,7 +10508,7 @@ test_delete_attribute_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -9982,13 +10522,13 @@ test_delete_attribute_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Aexists and H5Aexists_by_name. */ -static int +static void test_attribute_exists(void) { htri_t attr_exists; @@ -10007,7 +10547,7 @@ test_attribute_exists(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -10031,10 +10571,10 @@ test_attribute_exists(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_EXISTS_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_EXISTS_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_EXISTS_TEST_ATTR_NAME, attr_dtype, space_id, H5P_DEFAULT, @@ -10108,7 +10648,7 @@ test_attribute_exists(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10122,14 +10662,14 @@ test_attribute_exists(void) } H5E_END_TRY - return 1; + return; } /* * A test to ensure that H5Aexists(_by_name) will fail when * given invalid parameters. */ -static int +static void test_attribute_exists_invalid_params(void) { herr_t err_ret = -1; @@ -10149,7 +10689,7 @@ test_attribute_exists_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -10174,10 +10714,10 @@ test_attribute_exists_invalid_params(void) } if ((space_id = generate_random_dataspace(ATTRIBUTE_EXISTS_INVALID_PARAMS_TEST_SPACE_RANK, NULL, NULL, - TRUE)) < 0) + true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_EXISTS_INVALID_PARAMS_TEST_ATTR_NAME, attr_dtype, space_id, @@ -10385,7 +10925,7 @@ test_attribute_exists_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10399,14 +10939,14 @@ test_attribute_exists_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to make sure many attributes can be written * to the file */ -static int +static void test_attribute_many(void) { unsigned u; @@ -10427,7 +10967,7 @@ test_attribute_many(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -10449,15 +10989,15 @@ test_attribute_many(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_MANY_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_MANY_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; /* Create many attributes */ for (u = 0; u < ATTRIBUTE_MANY_NUMB; u++) { - sprintf(attrname, "many-%06u", u); + snprintf(attrname, sizeof(attrname), "many-%06u", u); if ((attr_id = H5Acreate2(group_id, attrname, attr_dtype, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -10495,7 +11035,7 @@ test_attribute_many(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10509,14 +11049,14 @@ test_attribute_many(void) } H5E_END_TRY - return 1; + return; } /* * A test to make sure an attribute can be opened for * a second time */ -static int +static void test_attribute_duplicate_id(void) { htri_t attr_exists; @@ -10535,7 +11075,7 @@ test_attribute_duplicate_id(void) SKIPPED(); printf( " API functions for basic file, group, or attribute aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -10557,10 +11097,10 @@ test_attribute_duplicate_id(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_DUPLICATE_ID_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_DUPLICATE_ID_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_DUPLICATE_ID_ATTR_NAME, attr_dtype, space_id, H5P_DEFAULT, @@ -10607,7 +11147,7 @@ test_attribute_duplicate_id(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10622,7 +11162,7 @@ test_attribute_duplicate_id(void) } H5E_END_TRY - return 1; + return; } /* @@ -10631,7 +11171,7 @@ test_attribute_duplicate_id(void) * * XXX: Cover all of the cases and move to H5O tests. */ -static int +static void test_get_number_attributes(void) { H5O_info2_t obj_info; @@ -10651,7 +11191,7 @@ test_get_number_attributes(void) SKIPPED(); printf(" API functions for basic file, group, attribute, or object aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -10675,10 +11215,10 @@ test_get_number_attributes(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_GET_NUM_ATTRS_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_GET_NUM_ATTRS_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_GET_NUM_ATTRS_TEST_ATTR_NAME, attr_dtype, space_id, @@ -10787,7 +11327,7 @@ test_get_number_attributes(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10801,7 +11341,7 @@ test_get_number_attributes(void) } H5E_END_TRY - return 1; + return; } /* @@ -10810,7 +11350,7 @@ test_get_number_attributes(void) * * XXX: May move to H5O tests. */ -static int +static void test_attr_shared_dtype(void) { H5O_info2_t obj_info; @@ -10833,7 +11373,7 @@ test_attr_shared_dtype(void) SKIPPED(); printf(" API functions for basic file, group, attribute, stored datatype, or object aren't " "supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -10855,10 +11395,10 @@ test_attr_shared_dtype(void) goto error; } - if ((space_id = generate_random_dataspace(ATTRIBUTE_SHARED_DTYPE_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((space_id = generate_random_dataspace(ATTRIBUTE_SHARED_DTYPE_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; /* Commit datatype to file */ @@ -10948,7 +11488,7 @@ test_attr_shared_dtype(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10961,7 +11501,7 @@ test_attr_shared_dtype(void) } H5E_END_TRY - return 1; + return; } static herr_t @@ -10990,18 +11530,18 @@ attr_iter_callback1(hid_t location_id, const char *attr_name, const H5A_info_t * */ test_iteration = (counter_val / ATTRIBUTE_ITERATE_TEST_NUM_ATTRS); if (test_iteration == 0 || test_iteration == 3) { - HDsnprintf(expected_attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE, - ATTRIBUTE_ITERATE_TEST_ATTR_NAME "%d", - (int)(counter_val % ATTRIBUTE_ITERATE_TEST_NUM_ATTRS)); + snprintf(expected_attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE, + ATTRIBUTE_ITERATE_TEST_ATTR_NAME "%d", + (int)(counter_val % ATTRIBUTE_ITERATE_TEST_NUM_ATTRS)); } else { - HDsnprintf( + snprintf( expected_attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE, ATTRIBUTE_ITERATE_TEST_ATTR_NAME "%d", (int)(ATTRIBUTE_ITERATE_TEST_NUM_ATTRS - (counter_val % ATTRIBUTE_ITERATE_TEST_NUM_ATTRS) - 1)); } - if (HDstrncmp(attr_name, expected_attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE)) { + if (strncmp(attr_name, expected_attr_name, ATTRIBUTE_ITERATE_TEST_ATTR_NAME_BUF_SIZE)) { printf(" attribute name '%s' didn't match expected name '%s'\n", attr_name, expected_attr_name); ret_val = H5_ITER_ERROR; goto done; @@ -11050,26 +11590,88 @@ attr_iter_callback2(hid_t location_id, const char *attr_name, const H5A_info_t * UNUSED(ainfo); UNUSED(op_data); - return 0; + return H5_ITER_CONT; } -int -H5_api_attribute_test(void) +void +H5_api_attribute_test_add(void) { - size_t i; - int nerrors; - - printf("**********************************************\n"); - printf("* *\n"); - printf("* API Attribute Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); - - for (i = 0, nerrors = 0; i < ARRAY_LENGTH(attribute_tests); i++) { - nerrors += (*attribute_tests[i])() ? 1 : 0; - } - - printf("\n"); - - return nerrors; + /* Add a fake test to print out a header to distinguish different test interfaces */ + // TODO + AddTest("print_attribute_test_header", print_attribute_test_header, NULL, + "Prints header for attribute tests", NULL); + + AddTest("test_create_attribute_on_root", MT_API_TEST_FUNC_OUTER(test_create_attribute_on_root), NULL, + "attribute creation on the root group", NULL); + AddTest("test_create_attribute_on_dataset", MT_API_TEST_FUNC_OUTER(test_create_attribute_on_dataset), NULL, + "attribute creation on a dataset", NULL); + AddTest("test_create_attribute_on_datatype", MT_API_TEST_FUNC_OUTER(test_create_attribute_on_datatype), NULL, + "attribute creation on a committed datatype", NULL); + AddTest("test_create_attribute_with_null_space", MT_API_TEST_FUNC_OUTER(test_create_attribute_with_null_space), NULL, + "attribute creation with a NULL dataspace", NULL); + AddTest("test_create_attribute_with_scalar_space", MT_API_TEST_FUNC_OUTER(test_create_attribute_with_scalar_space), NULL, + "attribute creation with a SCALAR dataspace", NULL); + AddTest("test_create_attribute_with_space_in_name", MT_API_TEST_FUNC_OUTER(test_create_attribute_with_space_in_name), NULL, + "attribute creation with a space in attribute's name", NULL); + AddTest("test_create_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_attribute_invalid_params), NULL, + "attribute creation with invalid parameters", NULL); + AddTest("test_open_attribute", MT_API_TEST_FUNC_OUTER(test_open_attribute), NULL, "attribute opening", NULL); + AddTest("test_open_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_attribute_invalid_params), NULL, + "attribute opening with invalid parameters", NULL); + AddTest("test_write_attribute", MT_API_TEST_FUNC_OUTER(test_write_attribute), NULL, "H5Awrite", NULL); + AddTest("test_write_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_write_attribute_invalid_params), NULL, + "H5Awrite with invalid parameters", NULL); + AddTest("test_read_attribute", MT_API_TEST_FUNC_OUTER(test_read_attribute), NULL, "H5Aread", NULL); + AddTest("test_read_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_read_attribute_invalid_params), NULL, + "H5Aread with invalid parameters", NULL); + AddTest("test_read_empty_attribute", MT_API_TEST_FUNC_OUTER(test_read_empty_attribute), NULL, "reading an empty attribute", NULL); + AddTest("test_close_attribute_invalid_id", MT_API_TEST_FUNC_OUTER(test_close_attribute_invalid_id), NULL, + "H5Aclose with an invalid attribute ID", NULL); + AddTest("test_get_attribute_space_and_type", MT_API_TEST_FUNC_OUTER(test_get_attribute_space_and_type), NULL, + "retrieval of an attribute's dataspace and datatype", NULL); + AddTest("test_get_attribute_space_and_type_invalid_params", + MT_API_TEST_FUNC_OUTER(test_get_attribute_space_and_type_invalid_params), NULL, + "H5Aget_type/H5Aget_space with invalid parameters", NULL); + AddTest("test_attribute_property_lists", MT_API_TEST_FUNC_OUTER(test_attribute_property_lists), NULL, + "attribute property list operations", NULL); + AddTest("test_get_attribute_name", MT_API_TEST_FUNC_OUTER(test_get_attribute_name), NULL, "retrieval of an attribute's name", + NULL); + AddTest("test_get_attribute_name_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_attribute_name_invalid_params), NULL, + "retrieval of an attribute's name with invalid parameters", NULL); + AddTest("test_get_attribute_storage_size", MT_API_TEST_FUNC_OUTER(test_get_attribute_storage_size), NULL, "H5Aget_storage_size", + NULL); + AddTest("test_get_attribute_info", MT_API_TEST_FUNC_OUTER(test_get_attribute_info), NULL, "retrieval of attribute info", NULL); + AddTest("test_get_attribute_info_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_attribute_info_invalid_params), NULL, + "retrieval of attribute info with invalid parameters", NULL); + AddTest("test_rename_attribute", MT_API_TEST_FUNC_OUTER(test_rename_attribute), NULL, "attribute renaming", NULL); + AddTest("test_rename_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_rename_attribute_invalid_params), NULL, + "attribute renaming with invalid parameters", NULL); + AddTest("test_attribute_iterate_group", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_group), NULL, + "attribute iteration on a group", NULL); + AddTest("test_attribute_iterate_dataset", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_dataset), NULL, + "attribute iteration on a dataset", NULL); + AddTest("test_attribute_iterate_datatype", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_datatype), NULL, + "attribute iteration on a committed datatype", NULL); + AddTest("test_attribute_iterate_index_saving", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_index_saving), NULL, + "attribute iteration index saving capability", NULL); + AddTest("test_attribute_iterate_invalid_params", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_invalid_params), NULL, + "attribute iteration with invalid parameters", NULL); + AddTest("test_attribute_iterate_0_attributes", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_0_attributes), NULL, + "attribute iteration on object with 0 attributes", NULL); + AddTest("test_attribute_compound_subset", MT_API_TEST_FUNC_OUTER(test_attribute_compound_subset), NULL, + "verification of attribute data using H5Awrite then H5Aread with compound type subsets", NULL); + AddTest("test_attribute_string_encodings", MT_API_TEST_FUNC_OUTER(test_attribute_string_encodings), NULL, + "string encoding read/write correctness on attributes", NULL); + AddTest("test_delete_attribute", MT_API_TEST_FUNC_OUTER(test_delete_attribute), NULL, "attribute deletion", NULL); + AddTest("test_delete_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_delete_attribute_invalid_params), NULL, + "attribute deletion with invalid parameters", NULL); + AddTest("test_attribute_exists", MT_API_TEST_FUNC_OUTER(test_attribute_exists), NULL, "attribute existence", NULL); + AddTest("test_attribute_exists_invalid_params", MT_API_TEST_FUNC_OUTER(test_attribute_exists_invalid_params), NULL, + "attribute existence with invalid parameters", NULL); + AddTest("test_attribute_duplicate_id", MT_API_TEST_FUNC_OUTER(test_attribute_duplicate_id), NULL, + "duplicated IDs for an attribute", NULL); + AddTest("test_attribute_many", MT_API_TEST_FUNC_OUTER(test_attribute_many), NULL, "creating many attributes", NULL); + AddTest("test_get_number_attributes", MT_API_TEST_FUNC_OUTER(test_get_number_attributes), NULL, + "retrieval of the number of attributes on an object", NULL); + AddTest("test_attr_shared_dtype", MT_API_TEST_FUNC_OUTER(test_attr_shared_dtype), NULL, "shared datatype for attributes", NULL); } diff --git a/test/API/H5_api_attribute_test.h b/test/API/H5_api_attribute_test.h index dd83e732491..9baba1ceee5 100644 --- a/test/API/H5_api_attribute_test.h +++ b/test/API/H5_api_attribute_test.h @@ -15,7 +15,7 @@ #include "H5_api_test.h" -int H5_api_attribute_test(void); +void H5_api_attribute_test_add(void); /************************************************** * * @@ -156,6 +156,19 @@ int H5_api_attribute_test(void); #define ATTRIBUTE_ITERATE_TEST_0_ATTRIBUTES_SUBGROUP_NAME "attribute_iterate_test_0_attributes" #define ATTRIBUTE_ITERATE_TEST_0_ATTRIBUTES_DSET_NAME "attribute_iterate_dset" +#define ATTRIBUTE_COMPOUND_IO_ATTR_DIMS 10 +#define ATTRIBUTE_COMPOUND_IO_TEST_GROUP_NAME "attribute_compound_io_test_group" +#define ATTRIBUTE_COMPOUND_IO_TEST_ATTR_NAME "attribute_compound_io_test_attr" + +#define ATTRIBUTE_STRING_ENCODINGS_RANK 1 +#define ATTRIBUTE_STRING_ENCODINGS_EXTENT 1 +#define ATTRIBUTE_STRING_ENCODINGS_DSET_NAME1 "encoding_dset1" +#define ATTRIBUTE_STRING_ENCODINGS_DSET_NAME2 "encoding_dset2" +#define ATTRIBUTE_STRING_ENCODINGS_ASCII_STRING "asciistr" +#define ATTRIBUTE_STRING_ENCODINGS_UTF8_STRING "αaααaaaα" +#define ATTRIBUTE_STRING_ENCODINGS_ATTR_NAME1 "encoding_attr1" +#define ATTRIBUTE_STRING_ENCODINGS_ATTR_NAME2 "encoding_attr2" + #define ATTRIBUTE_ITERATE_INVALID_PARAMS_TEST_ATTR_SPACE_RANK 1 #define ATTRIBUTE_ITERATE_INVALID_PARAMS_TEST_SUBGROUP_NAME "attribute_iterate_invalid_params_test" #define ATTRIBUTE_ITERATE_INVALID_PARAMS_TEST_ATTR_NAME "invalid_params_iter_attr1" diff --git a/test/API/H5_api_dataset_test.c b/test/API/H5_api_dataset_test.c index b74187bb2a5..359c374b9c6 100644 --- a/test/API/H5_api_dataset_test.c +++ b/test/API/H5_api_dataset_test.c @@ -16,147 +16,180 @@ * XXX: H5Dread_chunk/H5Dwrite_chunk, H5Dfill/scatter/gather */ -static int test_create_dataset_under_root(void); -static int test_create_dataset_under_existing_group(void); -static int test_create_dataset_invalid_params(void); -static int test_create_anonymous_dataset(void); -static int test_create_anonymous_dataset_invalid_params(void); -static int test_create_dataset_null_space(void); -static int test_create_dataset_scalar_space(void); -static int test_create_zero_dim_dset(void); -static int test_create_dataset_random_shapes(void); -static int test_create_dataset_predefined_types(void); -static int test_create_dataset_string_types(void); -static int test_create_dataset_compound_types(void); -static int test_create_dataset_enum_types(void); -static int test_create_dataset_array_types(void); -static int test_create_dataset_creation_properties(void); -static int test_create_many_dataset(void); -static int test_open_dataset(void); -static int test_open_dataset_invalid_params(void); -static int test_close_dataset_invalid_params(void); -static int test_get_dataset_space_and_type(void); -static int test_get_dataset_space_and_type_invalid_params(void); -static int test_get_dataset_space_status(void); -static int test_get_dataset_space_status_invalid_params(void); -static int test_dataset_property_lists(void); -static int test_get_dataset_storage_size(void); -static int test_get_dataset_storage_size_invalid_params(void); -static int test_get_dataset_chunk_storage_size(void); -static int test_get_dataset_chunk_storage_size_invalid_params(void); -static int test_get_dataset_offset(void); -static int test_get_dataset_offset_invalid_params(void); -static int test_read_dataset_small_all(void); -static int test_read_dataset_small_hyperslab(void); -static int test_read_dataset_small_point_selection(void); -static int test_dataset_io_point_selections(void); -static int test_read_dataset_invalid_params(void); -static int test_write_dataset_small_all(void); -static int test_write_dataset_small_hyperslab(void); -static int test_write_dataset_small_point_selection(void); -static int test_write_dataset_data_verification(void); -static int test_write_dataset_invalid_params(void); -static int test_dataset_builtin_type_conversion(void); -static int test_dataset_compound_partial_io(void); -static int test_dataset_set_extent_chunked_unlimited(void); -static int test_dataset_set_extent_chunked_fixed(void); -static int test_dataset_set_extent_data(void); -static int test_dataset_set_extent_double_handles(void); -static int test_dataset_set_extent_invalid_params(void); -static int test_flush_dataset(void); -static int test_flush_dataset_invalid_params(void); -static int test_refresh_dataset(void); -static int test_refresh_dataset_invalid_params(void); +static void print_dataset_test_header(void); +static void test_create_dataset_under_root(void); +static void test_create_dataset_under_existing_group(void); +static void test_create_dataset_invalid_params(void); +static void test_create_anonymous_dataset(void); +static void test_create_anonymous_dataset_invalid_params(void); +static void test_create_dataset_null_space(void); +static void test_create_dataset_scalar_space(void); +static void test_create_zero_dim_dset(void); +static void test_create_dataset_random_shapes(void); +static void test_create_dataset_predefined_types(void); +static void test_create_dataset_string_types(void); +static void test_create_dataset_compound_types(void); +static void test_create_dataset_enum_types(void); +static void test_create_dataset_array_types(void); +static void test_create_dataset_creation_properties(void); +static void test_create_many_dataset(void); +static void test_open_dataset(void); +static void test_open_dataset_invalid_params(void); +static void test_close_dataset_invalid_params(void); +static void test_get_dataset_space_and_type(void); +static void test_get_dataset_space_and_type_invalid_params(void); +static void test_get_dataset_space_status(void); +static void test_get_dataset_space_status_invalid_params(void); +static void test_dataset_property_lists(void); +static void test_get_dataset_storage_size(void); +static void test_get_dataset_storage_size_invalid_params(void); +static void test_get_dataset_chunk_storage_size(void); +static void test_get_dataset_chunk_storage_size_invalid_params(void); +static void test_get_dataset_offset(void); +static void test_get_dataset_offset_invalid_params(void); +static void test_read_dataset_small_all(void); +static void test_read_dataset_small_hyperslab(void); +static void test_read_dataset_small_point_selection(void); +static void test_read_multi_dataset_small_all(void); +static void test_read_multi_dataset_small_hyperslab(void); +static void test_read_multi_dataset_small_point_selection(void); +static void test_dataset_io_point_selections(void); +static void test_read_dataset_invalid_params(void); +static void test_write_dataset_small_all(void); +static void test_write_dataset_small_hyperslab(void); +static void test_write_dataset_small_point_selection(void); +static void test_write_dataset_data_verification(void); +static void test_write_multi_dataset_small_all(void); +static void test_write_multi_dataset_small_hyperslab(void); +static void test_write_multi_dataset_small_point_selection(void); +static void test_write_multi_dataset_data_verification(void); +static void test_write_dataset_invalid_params(void); +static void test_dataset_string_encodings(void); +static void test_dataset_builtin_type_conversion(void); +static void test_dataset_real_to_int_conversion(void); +static void test_dataset_compound_partial_io(void); +static void test_dataset_vlen_io(void); +static void test_dataset_set_extent_chunked_unlimited(void); +static void test_dataset_set_extent_chunked_fixed(void); +static void test_dataset_set_extent_data(void); +static void test_dataset_set_extent_double_handles(void); +static void test_dataset_set_extent_invalid_params(void); +static void test_flush_dataset(void); +static void test_flush_dataset_invalid_params(void); +static void test_refresh_dataset(void); +static void test_refresh_dataset_invalid_params(void); /* * Chunking tests */ -static int test_create_single_chunk_dataset(void); -static int test_write_single_chunk_dataset(void); -static int test_create_multi_chunk_dataset(void); -static int test_write_multi_chunk_dataset_same_shape_read(void); -static int test_write_multi_chunk_dataset_diff_shape_read(void); -static int test_overwrite_multi_chunk_dataset_same_shape_read(void); -static int test_overwrite_multi_chunk_dataset_diff_shape_read(void); -static int test_read_partial_chunk_all_selection(void); -static int test_read_partial_chunk_hyperslab_selection(void); -static int test_read_partial_chunk_point_selection(void); - -static int test_get_vlen_buf_size(void); - -/* - * The array of dataset tests to be performed. - */ -static int (*dataset_tests[])(void) = { - test_create_dataset_under_root, - test_create_dataset_under_existing_group, - test_create_dataset_invalid_params, - test_create_anonymous_dataset, - test_create_anonymous_dataset_invalid_params, - test_create_dataset_null_space, - test_create_dataset_scalar_space, - test_create_zero_dim_dset, - test_create_dataset_random_shapes, - test_create_dataset_predefined_types, - test_create_dataset_string_types, - test_create_dataset_compound_types, - test_create_dataset_enum_types, - test_create_dataset_array_types, - test_create_dataset_creation_properties, - test_create_many_dataset, - test_open_dataset, - test_open_dataset_invalid_params, - test_close_dataset_invalid_params, - test_get_dataset_space_and_type, - test_get_dataset_space_and_type_invalid_params, - test_get_dataset_space_status, - test_get_dataset_space_status_invalid_params, - test_dataset_property_lists, - test_get_dataset_storage_size, - test_get_dataset_storage_size_invalid_params, - test_get_dataset_chunk_storage_size, - test_get_dataset_chunk_storage_size_invalid_params, - test_get_dataset_offset, - test_get_dataset_offset_invalid_params, - test_read_dataset_small_all, - test_read_dataset_small_hyperslab, - test_read_dataset_small_point_selection, - test_dataset_io_point_selections, - test_read_dataset_invalid_params, - test_write_dataset_small_all, - test_write_dataset_small_hyperslab, - test_write_dataset_small_point_selection, - test_write_dataset_data_verification, - test_write_dataset_invalid_params, - test_dataset_builtin_type_conversion, - test_dataset_compound_partial_io, - test_dataset_set_extent_chunked_unlimited, - test_dataset_set_extent_chunked_fixed, - test_dataset_set_extent_data, - test_dataset_set_extent_double_handles, - test_dataset_set_extent_invalid_params, - test_flush_dataset, - test_flush_dataset_invalid_params, - test_refresh_dataset, - test_refresh_dataset_invalid_params, - test_create_single_chunk_dataset, - test_write_single_chunk_dataset, - test_create_multi_chunk_dataset, - test_write_multi_chunk_dataset_same_shape_read, - test_write_multi_chunk_dataset_diff_shape_read, - test_overwrite_multi_chunk_dataset_same_shape_read, - test_overwrite_multi_chunk_dataset_diff_shape_read, - test_read_partial_chunk_all_selection, - test_read_partial_chunk_hyperslab_selection, - test_read_partial_chunk_point_selection, - test_get_vlen_buf_size, -}; +static void test_create_single_chunk_dataset(void); +static void test_write_single_chunk_dataset(void); +static void test_create_multi_chunk_dataset(void); +static void test_write_multi_chunk_dataset_same_shape_read(void); +static void test_write_multi_chunk_dataset_diff_shape_read(void); +static void test_overwrite_multi_chunk_dataset_same_shape_read(void); +static void test_overwrite_multi_chunk_dataset_diff_shape_read(void); +static void test_read_partial_chunk_all_selection(void); +static void test_read_partial_chunk_hyperslab_selection(void); +static void test_read_partial_chunk_point_selection(void); + +static void test_get_vlen_buf_size(void); + +MULTI_DECLARE(test_create_dataset_under_root) +MULTI_DECLARE(test_create_dataset_under_existing_group) +MULTI_DECLARE(test_create_dataset_invalid_params) +MULTI_DECLARE(test_create_anonymous_dataset) +MULTI_DECLARE(test_create_anonymous_dataset_invalid_params) +MULTI_DECLARE(test_create_dataset_null_space) +MULTI_DECLARE(test_create_dataset_scalar_space) +MULTI_DECLARE(test_create_zero_dim_dset) +MULTI_DECLARE(test_create_dataset_random_shapes) +MULTI_DECLARE(test_create_dataset_predefined_types) +MULTI_DECLARE(test_create_dataset_string_types) +MULTI_DECLARE(test_create_dataset_compound_types) +MULTI_DECLARE(test_create_dataset_enum_types) +MULTI_DECLARE(test_create_dataset_array_types) +MULTI_DECLARE(test_create_dataset_creation_properties) +MULTI_DECLARE(test_create_many_dataset) +MULTI_DECLARE(test_open_dataset) +MULTI_DECLARE(test_open_dataset_invalid_params) +MULTI_DECLARE(test_close_dataset_invalid_params) +MULTI_DECLARE(test_get_dataset_space_and_type) +MULTI_DECLARE(test_get_dataset_space_and_type_invalid_params) +MULTI_DECLARE(test_get_dataset_space_status) +MULTI_DECLARE(test_get_dataset_space_status_invalid_params) +MULTI_DECLARE(test_dataset_property_lists) +MULTI_DECLARE(test_get_dataset_storage_size) +MULTI_DECLARE(test_get_dataset_storage_size_invalid_params) +MULTI_DECLARE(test_get_dataset_chunk_storage_size) +MULTI_DECLARE(test_get_dataset_chunk_storage_size_invalid_params) +MULTI_DECLARE(test_get_dataset_offset) +MULTI_DECLARE(test_get_dataset_offset_invalid_params) +MULTI_DECLARE(test_read_dataset_small_all) +MULTI_DECLARE(test_read_dataset_small_hyperslab) +MULTI_DECLARE(test_read_dataset_small_point_selection) +MULTI_DECLARE(test_read_multi_dataset_small_all) +MULTI_DECLARE(test_read_multi_dataset_small_hyperslab) +MULTI_DECLARE(test_read_multi_dataset_small_point_selection) +MULTI_DECLARE(test_dataset_io_point_selections) +MULTI_DECLARE(test_read_dataset_invalid_params) +MULTI_DECLARE(test_write_dataset_small_all) +MULTI_DECLARE(test_write_dataset_small_hyperslab) +MULTI_DECLARE(test_write_dataset_small_point_selection) +MULTI_DECLARE(test_write_dataset_data_verification) +MULTI_DECLARE(test_write_multi_dataset_small_all) +MULTI_DECLARE(test_write_multi_dataset_small_hyperslab) +MULTI_DECLARE(test_write_multi_dataset_small_point_selection) +MULTI_DECLARE(test_write_multi_dataset_data_verification) +MULTI_DECLARE(test_write_dataset_invalid_params) +MULTI_DECLARE(test_dataset_string_encodings) +MULTI_DECLARE(test_dataset_builtin_type_conversion) +MULTI_DECLARE(test_dataset_real_to_int_conversion) +MULTI_DECLARE(test_dataset_compound_partial_io) +MULTI_DECLARE(test_dataset_vlen_io) +MULTI_DECLARE(test_dataset_set_extent_chunked_unlimited) +MULTI_DECLARE(test_dataset_set_extent_chunked_fixed) +MULTI_DECLARE(test_dataset_set_extent_data) +MULTI_DECLARE(test_dataset_set_extent_double_handles) +MULTI_DECLARE(test_dataset_set_extent_invalid_params) +MULTI_DECLARE(test_flush_dataset) +MULTI_DECLARE(test_flush_dataset_invalid_params) +MULTI_DECLARE(test_refresh_dataset) +MULTI_DECLARE(test_refresh_dataset_invalid_params) + +MULTI_DECLARE(test_create_single_chunk_dataset) +MULTI_DECLARE(test_write_single_chunk_dataset) +MULTI_DECLARE(test_create_multi_chunk_dataset) +MULTI_DECLARE(test_write_multi_chunk_dataset_same_shape_read) +MULTI_DECLARE(test_write_multi_chunk_dataset_diff_shape_read) +MULTI_DECLARE(test_overwrite_multi_chunk_dataset_same_shape_read) +MULTI_DECLARE(test_overwrite_multi_chunk_dataset_diff_shape_read) +MULTI_DECLARE(test_read_partial_chunk_all_selection) +MULTI_DECLARE(test_read_partial_chunk_hyperslab_selection) +MULTI_DECLARE(test_read_partial_chunk_point_selection) + +MULTI_DECLARE(test_get_vlen_buf_size) + +static size_t filter(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned int H5_ATTR_UNUSED cd_values[], size_t nbytes, + size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf); + +static void +print_dataset_test_header(void) +{ + printf("\n"); + printf("**********************************************\n"); + printf("* *\n"); + printf("* API Dataset Tests *\n"); + printf("* *\n"); + printf("**********************************************\n\n"); +} /* * A test to check that a dataset can be * created under the root group. */ -static int +static void test_create_dataset_under_root(void) { hid_t file_id = H5I_INVALID_HID; @@ -170,7 +203,7 @@ test_create_dataset_under_root(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -179,10 +212,10 @@ test_create_dataset_under_root(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATASET_CREATE_UNDER_ROOT_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(DATASET_CREATE_UNDER_ROOT_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; /* Create the Dataset under the root group of the file */ @@ -204,7 +237,7 @@ test_create_dataset_under_root(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -216,14 +249,14 @@ test_create_dataset_under_root(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a dataset can be created * under a group that is not the root group. */ -static int +static void test_create_dataset_under_existing_group(void) { hid_t file_id = H5I_INVALID_HID; @@ -239,7 +272,7 @@ test_create_dataset_under_existing_group(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -261,11 +294,11 @@ test_create_dataset_under_existing_group(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATASET_CREATE_UNDER_EXISTING_SPACE_RANK, NULL, NULL, FALSE)) < + if ((fspace_id = generate_random_dataspace(DATASET_CREATE_UNDER_EXISTING_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, DATASET_CREATE_UNDER_EXISTING_DSET_NAME, dset_dtype, fspace_id, @@ -290,7 +323,7 @@ test_create_dataset_under_existing_group(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -304,14 +337,14 @@ test_create_dataset_under_existing_group(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a dataset can't be created * when H5Dcreate is passed invalid parameters. */ -static int +static void test_create_dataset_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -327,7 +360,7 @@ test_create_dataset_invalid_params(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -351,11 +384,11 @@ test_create_dataset_invalid_params(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATASET_CREATE_INVALID_PARAMS_SPACE_RANK, NULL, NULL, FALSE)) < + if ((fspace_id = generate_random_dataspace(DATASET_CREATE_INVALID_PARAMS_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; PASSED(); @@ -547,7 +580,7 @@ test_create_dataset_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -561,13 +594,13 @@ test_create_dataset_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an anonymous dataset can be created. */ -static int +static void test_create_anonymous_dataset(void) { hid_t file_id = H5I_INVALID_HID; @@ -583,7 +616,7 @@ test_create_anonymous_dataset(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -605,10 +638,10 @@ test_create_anonymous_dataset(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATASET_CREATE_ANONYMOUS_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(DATASET_CREATE_ANONYMOUS_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate_anon(group_id, dset_dtype, fspace_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -632,7 +665,7 @@ test_create_anonymous_dataset(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -646,7 +679,7 @@ test_create_anonymous_dataset(void) } H5E_END_TRY - return 1; + return; } /* @@ -654,7 +687,7 @@ test_create_anonymous_dataset(void) * be created when H5Dcreate_anon is passed invalid * parameters. */ -static int +static void test_create_anonymous_dataset_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -670,7 +703,7 @@ test_create_anonymous_dataset_invalid_params(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -696,10 +729,10 @@ test_create_anonymous_dataset_invalid_params(void) } if ((fspace_id = generate_random_dataspace(DATASET_CREATE_ANONYMOUS_INVALID_PARAMS_SPACE_RANK, NULL, NULL, - FALSE)) < 0) + false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; PASSED(); @@ -828,7 +861,7 @@ test_create_anonymous_dataset_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -842,14 +875,14 @@ test_create_anonymous_dataset_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that creating a dataset with a NULL * dataspace is not problematic. */ -static int +static void test_create_dataset_null_space(void) { hid_t file_id = H5I_INVALID_HID; @@ -865,7 +898,7 @@ test_create_dataset_null_space(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -891,7 +924,7 @@ test_create_dataset_null_space(void) if ((fspace_id = H5Screate(H5S_NULL)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, DATASET_CREATE_NULL_DATASPACE_TEST_DSET_NAME, dset_dtype, fspace_id, @@ -925,7 +958,7 @@ test_create_dataset_null_space(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -939,14 +972,14 @@ test_create_dataset_null_space(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that creating a dataset with a scalar * dataspace is not problematic. */ -static int +static void test_create_dataset_scalar_space(void) { hid_t file_id = H5I_INVALID_HID; @@ -962,7 +995,7 @@ test_create_dataset_scalar_space(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -988,7 +1021,7 @@ test_create_dataset_scalar_space(void) if ((fspace_id = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, DATASET_CREATE_SCALAR_DATASPACE_TEST_DSET_NAME, dset_dtype, fspace_id, @@ -1022,7 +1055,7 @@ test_create_dataset_scalar_space(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1036,14 +1069,14 @@ test_create_dataset_scalar_space(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that creating a dataset with a dataspace * which contains a 0-sized dimension is not problematic. */ -static int +static void test_create_zero_dim_dset(void) { hsize_t dims[ZERO_DIM_DSET_TEST_SPACE_RANK] = {0}; @@ -1061,7 +1094,7 @@ test_create_zero_dim_dset(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1126,7 +1159,7 @@ test_create_zero_dim_dset(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1139,14 +1172,14 @@ test_create_zero_dim_dset(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a dataset can be created with * a variety of different dataspace shapes. */ -static int +static void test_create_dataset_random_shapes(void) { size_t i; @@ -1162,7 +1195,7 @@ test_create_dataset_random_shapes(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1184,20 +1217,20 @@ test_create_dataset_random_shapes(void) goto error; } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; for (i = 0; i < DATASET_SHAPE_TEST_NUM_ITERATIONS; i++) { char name[100]; int ndims = rand() % DATASET_SHAPE_TEST_MAX_DIMS + 1; - if ((space_id = generate_random_dataspace(ndims, NULL, NULL, FALSE)) < 0) { + if ((space_id = generate_random_dataspace(ndims, NULL, NULL, false)) < 0) { H5_FAILED(); printf(" couldn't create dataspace\n"); goto error; } - HDsprintf(name, "%s%zu", DATASET_SHAPE_TEST_DSET_BASE_NAME, i + 1); + snprintf(name, sizeof(name), "%s%zu", DATASET_SHAPE_TEST_DSET_BASE_NAME, i + 1); if ((dset_id = H5Dcreate2(group_id, name, dset_dtype, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -1223,7 +1256,7 @@ test_create_dataset_random_shapes(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1237,7 +1270,7 @@ test_create_dataset_random_shapes(void) } H5E_END_TRY - return 1; + return; } /* @@ -1245,7 +1278,7 @@ test_create_dataset_random_shapes(void) * each of the predefined integer and floating-point * datatypes. */ -static int +static void test_create_dataset_predefined_types(void) { size_t i; @@ -1253,11 +1286,11 @@ test_create_dataset_predefined_types(void) hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t fspace_id = H5I_INVALID_HID; hid_t dset_id = H5I_INVALID_HID; - hid_t predefined_type_test_table[] = {H5T_STD_U8LE, H5T_STD_U8BE, H5T_STD_I8LE, H5T_STD_I8BE, - H5T_STD_U16LE, H5T_STD_U16BE, H5T_STD_I16LE, H5T_STD_I16BE, - H5T_STD_U32LE, H5T_STD_U32BE, H5T_STD_I32LE, H5T_STD_I32BE, - H5T_STD_U64LE, H5T_STD_U64BE, H5T_STD_I64LE, H5T_STD_I64BE, - H5T_IEEE_F32LE, H5T_IEEE_F32BE, H5T_IEEE_F64LE, H5T_IEEE_F64BE}; + hid_t predefined_type_test_table[] = { + H5T_STD_U8LE, H5T_STD_U8BE, H5T_STD_I8LE, H5T_STD_I8BE, H5T_STD_U16LE, H5T_STD_U16BE, + H5T_STD_I16LE, H5T_STD_I16BE, H5T_STD_U32LE, H5T_STD_U32BE, H5T_STD_I32LE, H5T_STD_I32BE, + H5T_STD_U64LE, H5T_STD_U64BE, H5T_STD_I64LE, H5T_STD_I64BE, // H5T_IEEE_F16LE, H5T_IEEE_F16BE, Not present in 1.14.2 + H5T_IEEE_F32LE, H5T_IEEE_F32BE, H5T_IEEE_F64LE, H5T_IEEE_F64BE}; TESTING("dataset creation with predefined datatypes"); @@ -1266,7 +1299,7 @@ test_create_dataset_predefined_types(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1292,10 +1325,10 @@ test_create_dataset_predefined_types(void) char name[100]; if ((fspace_id = - generate_random_dataspace(DATASET_PREDEFINED_TYPE_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + generate_random_dataspace(DATASET_PREDEFINED_TYPE_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - HDsprintf(name, "%s%zu", DATASET_PREDEFINED_TYPE_TEST_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_PREDEFINED_TYPE_TEST_BASE_NAME, i); if ((dset_id = H5Dcreate2(group_id, name, predefined_type_test_table[i], fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -1328,7 +1361,7 @@ test_create_dataset_predefined_types(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1341,14 +1374,14 @@ test_create_dataset_predefined_types(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a dataset can be created using * string datatypes. */ -static int +static void test_create_dataset_string_types(void) { hid_t file_id = H5I_INVALID_HID; @@ -1364,7 +1397,7 @@ test_create_dataset_string_types(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1400,7 +1433,7 @@ test_create_dataset_string_types(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATASET_STRING_TYPE_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(DATASET_STRING_TYPE_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; PASSED(); @@ -1494,7 +1527,7 @@ test_create_dataset_string_types(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1510,14 +1543,14 @@ test_create_dataset_string_types(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a dataset can be created using * a variety of compound datatypes. */ -static int +static void test_create_dataset_compound_types(void) { size_t i, j; @@ -1536,7 +1569,7 @@ test_create_dataset_compound_types(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } /* @@ -1566,7 +1599,7 @@ test_create_dataset_compound_types(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATASET_COMPOUND_TYPE_TEST_DSET_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(DATASET_COMPOUND_TYPE_TEST_DSET_RANK, NULL, NULL, false)) < 0) TEST_ERROR; num_passes = (rand() % DATASET_COMPOUND_TYPE_TEST_MAX_PASSES) + 1; @@ -1598,9 +1631,9 @@ test_create_dataset_compound_types(void) size_t member_size; char member_name[256]; - HDsnprintf(member_name, 256, "member%zu", j); + snprintf(member_name, 256, "member%zu", j); - if ((type_pool[j] = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_pool[j] = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create compound datatype member %zu\n", j); goto error; @@ -1626,7 +1659,7 @@ test_create_dataset_compound_types(void) if (H5Tpack(compound_type) < 0) TEST_ERROR; - HDsnprintf(dset_name, sizeof(dset_name), "%s%zu", DATASET_COMPOUND_TYPE_TEST_DSET_NAME, i); + snprintf(dset_name, sizeof(dset_name), "%s%zu", DATASET_COMPOUND_TYPE_TEST_DSET_NAME, i); if ((dset_id = H5Dcreate2(group_id, dset_name, compound_type, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -1664,7 +1697,7 @@ test_create_dataset_compound_types(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1680,14 +1713,14 @@ test_create_dataset_compound_types(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a dataset can be created with * enum datatypes. */ -static int +static void test_create_dataset_enum_types(void) { size_t i; @@ -1706,7 +1739,7 @@ test_create_dataset_enum_types(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1747,13 +1780,13 @@ test_create_dataset_enum_types(void) for (i = 0; i < DATASET_ENUM_TYPE_TEST_NUM_MEMBERS; i++) { char val_name[15]; - HDsnprintf(val_name, 15, "%s%zu", DATASET_ENUM_TYPE_TEST_VAL_BASE_NAME, i); + snprintf(val_name, 15, "%s%zu", DATASET_ENUM_TYPE_TEST_VAL_BASE_NAME, i); if (H5Tenum_insert(enum_non_native, val_name, &i) < 0) TEST_ERROR; } - if ((fspace_id = generate_random_dataspace(DATASET_ENUM_TYPE_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(DATASET_ENUM_TYPE_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; if ((dset_id_native = H5Dcreate2(group_id, DATASET_ENUM_TYPE_TEST_DSET_NAME1, enum_native, fspace_id, @@ -1806,7 +1839,7 @@ test_create_dataset_enum_types(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1822,14 +1855,14 @@ test_create_dataset_enum_types(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a dataset can be created using * array datatypes. */ -static int +static void test_create_dataset_array_types(void) { hsize_t array_dims1[DATASET_ARRAY_TYPE_TEST_RANK1]; @@ -1853,7 +1886,7 @@ test_create_dataset_array_types(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1879,7 +1912,7 @@ test_create_dataset_array_types(void) for (i = 0; i < DATASET_ARRAY_TYPE_TEST_RANK1; i++) array_dims1[i] = (hsize_t)(rand() % MAX_DIM_SIZE + 1); - if ((array_base_type_id1 = generate_random_datatype(H5T_ARRAY, FALSE)) < 0) + if ((array_base_type_id1 = generate_random_datatype(H5T_ARRAY, false)) < 0) TEST_ERROR; if ((array_type_id1 = H5Tarray_create2(array_base_type_id1, DATASET_ARRAY_TYPE_TEST_RANK1, array_dims1)) < @@ -1892,7 +1925,7 @@ test_create_dataset_array_types(void) for (i = 0; i < DATASET_ARRAY_TYPE_TEST_RANK2; i++) array_dims2[i] = (hsize_t)(rand() % MAX_DIM_SIZE + 1); - if ((array_base_type_id2 = generate_random_datatype(H5T_ARRAY, FALSE)) < 0) + if ((array_base_type_id2 = generate_random_datatype(H5T_ARRAY, false)) < 0) TEST_ERROR; if ((array_type_id2 = H5Tarray_create2(array_base_type_id2, DATASET_ARRAY_TYPE_TEST_RANK2, array_dims2)) < @@ -1906,7 +1939,7 @@ test_create_dataset_array_types(void) for (i = 0; i < DATASET_ARRAY_TYPE_TEST_RANK3; i++) array_dims3[i] = (hsize_t)(rand() % MAX_DIM_SIZE + 1); - if ((array_base_type_id3 = generate_random_datatype(H5T_ARRAY, FALSE)) < 0) + if ((array_base_type_id3 = generate_random_datatype(H5T_ARRAY, false)) < 0) TEST_ERROR; if ((nested_type_id = H5Tarray_create2(array_base_type_id3, DATASET_ARRAY_TYPE_TEST_RANK3, array_dims3)) < @@ -1922,7 +1955,7 @@ test_create_dataset_array_types(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATASET_ARRAY_TYPE_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(DATASET_ARRAY_TYPE_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; if ((dset_id1 = H5Dcreate2(group_id, DATASET_ARRAY_TYPE_TEST_DSET_NAME1, array_type_id1, fspace_id, @@ -2002,7 +2035,7 @@ test_create_dataset_array_types(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2024,24 +2057,40 @@ test_create_dataset_array_types(void) } H5E_END_TRY - return 1; + return; +} + +static size_t +filter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned int H5_ATTR_UNUSED cd_values[], size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) +{ + *buf_size = 0; + return nbytes; } /* * A test to check the functionality of the different * dataset creation properties. */ -static int +static void test_create_dataset_creation_properties(void) { - hsize_t dims[DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK]; - hsize_t chunk_dims[DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK]; - size_t i; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID, dcpl_id = H5I_INVALID_HID; - hid_t dset_dtype = H5I_INVALID_HID, compact_dtype = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID, compact_fspace_id = H5I_INVALID_HID; + hsize_t dims[DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK]; + hsize_t chunk_dims[DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK]; + size_t i; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID, dcpl_id = H5I_INVALID_HID; + hid_t dset_dtype = H5I_INVALID_HID, compact_dtype = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID, compact_fspace_id = H5I_INVALID_HID; + void *read_buf = NULL; + unsigned int filter_params[DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NUM_PARAMS] = {1, 2, 3}; + unsigned int filter_params_out[DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NUM_PARAMS]; + char ud_filter_name[sizeof(DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NAME)]; + int nfilters = 0; + H5Z_filter_t retrieved_filter_id = H5I_INVALID_HID; + size_t num_filter_params = DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NUM_PARAMS; TESTING_MULTIPART("dataset creation properties"); @@ -2051,7 +2100,7 @@ test_create_dataset_creation_properties(void) SKIPPED(); printf(" API functions for basic file, group, or dataset " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -2076,19 +2125,19 @@ test_create_dataset_creation_properties(void) } if ((fspace_id = - generate_random_dataspace(DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK, NULL, dims, FALSE)) < 0) + generate_random_dataspace(DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK, NULL, dims, false)) < 0) TEST_ERROR; if ((compact_fspace_id = - generate_random_dataspace(DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK, NULL, NULL, TRUE)) < 0) + generate_random_dataspace(DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; /* Set chunk dims to be size of dataset - for filters test */ for (i = 0; i < DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK; i++) chunk_dims[i] = dims[i]; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((compact_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((compact_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; PASSED(); @@ -2118,7 +2167,8 @@ test_create_dataset_creation_properties(void) PART_ERROR(DCPL_alloc_time_test); } - HDsprintf(name, "%s%zu", DATASET_CREATION_PROPERTIES_TEST_ALLOC_TIMES_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_CREATION_PROPERTIES_TEST_ALLOC_TIMES_BASE_NAME, + i); if ((dset_id = H5Dcreate2(group_id, name, dset_dtype, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) { @@ -2194,7 +2244,8 @@ test_create_dataset_creation_properties(void) PART_ERROR(DCPL_attr_crt_order_test); } - HDsprintf(name, "%s%zu", DATASET_CREATION_PROPERTIES_TEST_CRT_ORDER_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_CREATION_PROPERTIES_TEST_CRT_ORDER_BASE_NAME, + i); if ((dset_id = H5Dcreate2(group_id, name, dset_dtype, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) { @@ -2327,7 +2378,8 @@ test_create_dataset_creation_properties(void) PART_ERROR(DCPL_fill_time_property_test); } - HDsprintf(name, "%s%zu", DATASET_CREATION_PROPERTIES_TEST_FILL_TIMES_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_CREATION_PROPERTIES_TEST_FILL_TIMES_BASE_NAME, + i); if ((dset_id = H5Dcreate2(group_id, name, dset_dtype, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) { @@ -2374,7 +2426,275 @@ test_create_dataset_creation_properties(void) } PART_END(DCPL_fill_time_property_test); - /* TODO: Test the fill value property */ + PART_BEGIN(DCPL_fill_value_test) + { + TESTING_2("fill values"); + + int int_fill_value = DATASET_FILL_VALUE_TEST_INT_FILL_VALUE; + double double_fill_value = DATASET_FILL_VALUE_TEST_DOUBLE_FILL_VALUE; + + void *val = NULL; + size_t num_elems = 1; + hid_t type_id = H5I_INVALID_HID; + + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILL_VALUES)) { + SKIPPED(); + printf(" dataset fill values are not supported by this VOL connector\n"); + PART_EMPTY(DCPL_fill_value_test); + } + + /* Integer Fill Value */ + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + H5_FAILED(); + printf(" couldn't create DCPL\n"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Pset_fill_value(dcpl_id, DATASET_FILL_VALUE_TEST_INT_TYPE, (const void *)&int_fill_value) < + 0) { + H5_FAILED(); + printf(" couldn't set integer fill value in property list"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((dset_id = + H5Dcreate(group_id, DATASET_FILL_VALUE_TEST_DSET_NAME1, DATASET_FILL_VALUE_TEST_INT_TYPE, + fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with integer fill value"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((H5Sget_simple_extent_dims(fspace_id, dims, NULL)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace dimensions"); + PART_ERROR(DCPL_fill_value_test); + } + + for (i = 0; i < DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK; i++) + num_elems *= (size_t)dims[i]; + + if ((read_buf = calloc(num_elems, sizeof(DATASET_FILL_VALUE_TEST_INT_TYPE))) == NULL) { + H5_FAILED(); + printf(" couldn't allocate memory for read buffer"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Dread(dset_id, DATASET_FILL_VALUE_TEST_INT_TYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < + 0) { + H5_FAILED(); + printf(" couldn't read from dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + for (i = 0; i < num_elems; i++) { + val = (int *)(read_buf) + i; + + if (*(int *)val != DATASET_FILL_VALUE_TEST_INT_FILL_VALUE) { + H5_FAILED(); + printf(" incorrect value read from dataset"); + PART_ERROR(DCPL_fill_value_test); + } + } + + if (H5Dclose(dset_id) < 0) { + H5_FAILED(); + printf(" couldn't close integer fill value dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Pclose(dcpl_id) < 0) { + H5_FAILED(); + printf(" couldn't close dcpl"); + PART_ERROR(DCPL_fill_value_test); + } + + /* Re-open integer dataset */ + if ((dset_id = H5Dopen2(group_id, DATASET_FILL_VALUE_TEST_DSET_NAME1, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open integer fill value dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Dclose(dset_id) < 0) { + H5_FAILED(); + printf(" couldn't close opened integer fill value dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + free(read_buf); + read_buf = NULL; + + /* Double fill value */ + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) == H5I_INVALID_HID) { + H5_FAILED(); + printf(" couldn't create dcpl"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((H5Pset_fill_value(dcpl_id, DATASET_FILL_VALUE_TEST_DOUBLE_TYPE, + (const void *)&double_fill_value)) < 0) { + H5_FAILED(); + printf(" couldn't set double fill value in property list"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((dset_id = H5Dcreate2(group_id, DATASET_FILL_VALUE_TEST_DSET_NAME2, + DATASET_FILL_VALUE_TEST_DOUBLE_TYPE, fspace_id, H5P_DEFAULT, dcpl_id, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with double fill value"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((read_buf = calloc(num_elems, sizeof(DATASET_FILL_VALUE_TEST_DOUBLE_TYPE))) == NULL) { + H5_FAILED(); + printf(" couldn't allocate memory for read buffer"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Dread(dset_id, DATASET_FILL_VALUE_TEST_DOUBLE_TYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + for (i = 0; i < num_elems; i++) { + val = (double *)(read_buf) + i; + + if (!(H5_DBL_REL_EQUAL(*(double *)val, DATASET_FILL_VALUE_TEST_DOUBLE_FILL_VALUE, + 0.0000001))) { + H5_FAILED(); + printf(" incorrect value read from dataset"); + PART_ERROR(DCPL_fill_value_test); + } + } + + if (H5Dclose(dset_id) < 0) { + H5_FAILED(); + printf(" couldn't close double fill value dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Pclose(dcpl_id) < 0) { + H5_FAILED(); + printf(" couldn't close dcpl"); + PART_ERROR(DCPL_fill_value_test); + } + + /* Re-open double dataset */ + if ((dset_id = H5Dopen2(group_id, DATASET_FILL_VALUE_TEST_DSET_NAME2, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open double fill value dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Dclose(dset_id) < 0) { + H5_FAILED(); + printf(" couldn't close opened double fill value dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + free(read_buf); + read_buf = NULL; + + /* Fixed-length string fill value */ + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) == H5I_INVALID_HID) { + H5_FAILED(); + printf(" couldn't create dcpl"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((type_id = H5Tcopy(H5T_C_S1)) < 0) { + H5_FAILED(); + printf(" couldn't copy string datatype"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((H5Tset_size(type_id, DATASET_FILL_VALUE_TEST_STRING_SIZE)) < 0) { + H5_FAILED(); + printf(" couldn't set size of string datatype"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((H5Pset_fill_value(dcpl_id, type_id, + (const void *)DATASET_FILL_VALUE_TEST_STRING_FILL_VALUE)) < 0) { + H5_FAILED(); + printf(" couldn't set string fill value in property list"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((dset_id = H5Dcreate2(group_id, DATASET_FILL_VALUE_TEST_DSET_NAME3, type_id, fspace_id, + H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with string fill value"); + PART_ERROR(DCPL_fill_value_test); + } + + if ((read_buf = calloc(num_elems, DATASET_FILL_VALUE_TEST_STRING_SIZE)) == NULL) { + H5_FAILED(); + printf(" couldn't allocate memory for read buffer"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Dread(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + for (i = 0; i < num_elems; i++) { + char val_str[DATASET_FILL_VALUE_TEST_STRING_SIZE + 1]; + + memcpy(val_str, ((char *)read_buf) + i * DATASET_FILL_VALUE_TEST_STRING_SIZE, + DATASET_FILL_VALUE_TEST_STRING_SIZE); + val_str[DATASET_FILL_VALUE_TEST_STRING_SIZE] = '\0'; + + if (strcmp(val_str, DATASET_FILL_VALUE_TEST_STRING_FILL_VALUE)) { + H5_FAILED(); + printf(" incorrect value read from string dataset"); + PART_ERROR(DCPL_fill_value_test); + } + } + + if (H5Dclose(dset_id) < 0) { + H5_FAILED(); + printf(" couldn't close string fill value dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Pclose(dcpl_id) < 0) { + H5_FAILED(); + printf(" couldn't close dcpl"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Tclose(type_id) < 0) { + H5_FAILED(); + printf(" couldn't close string type"); + PART_ERROR(DCPL_fill_value_test); + } + + free(read_buf); + read_buf = NULL; + + /* Re-open string dataset */ + if ((dset_id = H5Dopen2(group_id, DATASET_FILL_VALUE_TEST_DSET_NAME3, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open string fill value dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + if (H5Dclose(dset_id) < 0) { + H5_FAILED(); + printf(" couldn't close opened string fill value dataset"); + PART_ERROR(DCPL_fill_value_test); + } + + PASSED(); + } + PART_END(DCPL_fill_value_test); /* Test filters */ PART_BEGIN(DCPL_filters_test) @@ -2476,6 +2796,120 @@ test_create_dataset_creation_properties(void) } PART_END(DCPL_filters_test); + /* Test a user-defined filter */ + PART_BEGIN(DCPL_user_defined_filter_test) + { + TESTING_2("user-defined dataset filters"); + /* Create user-defined filter and register with library */ + const H5Z_class2_t filter_cls[1] = { + {H5Z_CLASS_T_VERS, DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_ID, 1, 1, + DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NAME, NULL, NULL, &filter}}; + + if (H5Zregister((const void *)&filter_cls) < 0) { + H5_FAILED(); + printf(" couldn't register filter\n"); + PART_ERROR(DCPL_user_defined_filter_test); + } + + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + H5_FAILED(); + printf(" couldn't create DCPL\n"); + PART_ERROR(DCPL_user_defined_filter_test); + } + + if (H5Pset_chunk(dcpl_id, DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK, chunk_dims) < 0) { + H5_FAILED(); + printf(" couldn't set chunking on DCPL\n"); + PART_ERROR(DCPL_user_defined_filter_test); + } + + /* Set user-defined filter on the DCPL */ + if (H5Pset_filter(dcpl_id, (H5Z_filter_t)DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_ID, + H5Z_FLAG_MANDATORY, 3, filter_params) < 0) { + H5_FAILED(); + printf(" couldn't set user-defined filter on DCPL\n"); + PART_ERROR(DCPL_user_defined_filter_test); + } + + /* Use a simple datatype, as not all filters support all datatypes. */ + if ((dset_id = H5Dcreate2(group_id, DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_DSET_NAME, + H5T_NATIVE_INT, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", + DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_DSET_NAME); + PART_ERROR(DCPL_user_defined_filter_test); + } + + if (dset_id >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id); + } + H5E_END_TRY; + dset_id = H5I_INVALID_HID; + } + + if ((dset_id = H5Dopen2(group_id, DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_DSET_NAME, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", + DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_DSET_NAME); + PART_ERROR(DCPL_user_defined_filter_test); + } + + if (dcpl_id >= 0) { + H5E_BEGIN_TRY + { + H5Pclose(dcpl_id); + } + H5E_END_TRY; + dcpl_id = H5I_INVALID_HID; + } + + /* Test that parameters are preserved in the DCPL */ + memset(filter_params_out, 0, + sizeof(unsigned int) * DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NUM_PARAMS); + + if ((dcpl_id = H5Dget_create_plist(dset_id)) < 0) { + H5_FAILED(); + printf(" couldn't retrieve DCPL\n"); + PART_ERROR(DCPL_user_defined_filter_test); + } + + if ((nfilters = H5Pget_nfilters(dcpl_id)) != 1) { + H5_FAILED(); + printf(" retrieved incorrect number of filters from DCPL\n"); + PART_ERROR(DCPL_user_defined_filter_test); + } + + if ((retrieved_filter_id = H5Pget_filter2( + dcpl_id, 0, H5Z_FLAG_MANDATORY, &num_filter_params, filter_params_out, + strlen(DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NAME), ud_filter_name, NULL)) < 0) { + H5_FAILED(); + printf(" retrieved incorrect user-defined filter ID\n"); + PART_ERROR(DCPL_user_defined_filter_test); + } + + for (i = 0; i < DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NUM_PARAMS; i++) + if (filter_params[i] != filter_params_out[i]) { + H5_FAILED(); + printf(" retrieved incorrect parameter value from DCPL\n"); + PART_ERROR(DCPL_user_defined_filter_test); + } + + if (dset_id >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id); + } + H5E_END_TRY; + dset_id = H5I_INVALID_HID; + } + + PASSED(); + } + PART_END(DCPL_user_defined_filter_test) + /* Test the dataset storage layout property */ PART_BEGIN(DCPL_storage_layout_test) { @@ -2513,7 +2947,7 @@ test_create_dataset_creation_properties(void) } } - HDsprintf(name, "%s%zu", DATASET_CREATION_PROPERTIES_TEST_LAYOUTS_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_CREATION_PROPERTIES_TEST_LAYOUTS_BASE_NAME, i); if ((dset_id = H5Dcreate2(group_id, name, (H5D_COMPACT == layouts[i]) ? compact_dtype : dset_dtype, @@ -2675,6 +3109,11 @@ test_create_dataset_creation_properties(void) TESTING_2("test cleanup"); + if (read_buf) { + free(read_buf); + read_buf = NULL; + } + if (H5Sclose(compact_fspace_id) < 0) TEST_ERROR; if (H5Sclose(fspace_id) < 0) @@ -2692,11 +3131,15 @@ test_create_dataset_creation_properties(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY { + if (read_buf) { + free(read_buf); + } + H5Sclose(compact_fspace_id); H5Sclose(fspace_id); H5Tclose(compact_dtype); @@ -2706,16 +3149,17 @@ test_create_dataset_creation_properties(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); - } - H5E_END_TRY - return 1; + H5E_END_TRY + + return; + } } /* * A test to create many small datasets (100,000) */ -static int +static void test_create_many_dataset(void) { hid_t file_id = H5I_INVALID_HID; @@ -2733,7 +3177,7 @@ test_create_many_dataset(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2764,7 +3208,7 @@ test_create_many_dataset(void) printf("\n"); for (i = 0; i < DATASET_NUMB; i++) { printf("\r %u/%u", i + 1, DATASET_NUMB); - sprintf(dset_name, "dset_%02u", i); + snprintf(dset_name, sizeof(dset_name), "dset_%02u", i); data = i % 256; if ((dset_id = H5Dcreate2(group_id, dset_name, H5T_NATIVE_UCHAR, dataspace_id, H5P_DEFAULT, @@ -2798,7 +3242,7 @@ test_create_many_dataset(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2811,28 +3255,28 @@ test_create_many_dataset(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that re-opening a dataset with * H5Dopen succeeds. */ -static int +static void test_open_dataset(void) { TESTING("H5Dopen"); SKIPPED(); - return 0; + return; } /* * A test to check that H5Dopen fails when it is * passed invalid parameters. */ -static int +static void test_open_dataset_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -2848,7 +3292,7 @@ test_open_dataset_invalid_params(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -2872,11 +3316,11 @@ test_open_dataset_invalid_params(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATASET_OPEN_INVALID_PARAMS_SPACE_RANK, NULL, NULL, FALSE)) < + if ((fspace_id = generate_random_dataspace(DATASET_OPEN_INVALID_PARAMS_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, DATASET_OPEN_INVALID_PARAMS_DSET_NAME, dset_dtype, fspace_id, @@ -2986,7 +3430,7 @@ test_open_dataset_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3000,14 +3444,14 @@ test_open_dataset_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Dclose fails when it is * passed an invalid dataset ID. */ -static int +static void test_close_dataset_invalid_params(void) { herr_t err_ret = -1; @@ -3019,7 +3463,7 @@ test_close_dataset_invalid_params(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -3045,7 +3489,7 @@ test_close_dataset_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3054,7 +3498,7 @@ test_close_dataset_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* @@ -3062,7 +3506,7 @@ test_close_dataset_invalid_params(void) * and datatype can be retrieved with H5Dget_space and * H5Dget_type, respectively. */ -static int +static void test_get_dataset_space_and_type(void) { hsize_t dset_dims[DATASET_GET_SPACE_TYPE_TEST_SPACE_RANK]; @@ -3083,7 +3527,7 @@ test_get_dataset_space_and_type(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3108,10 +3552,10 @@ test_get_dataset_space_and_type(void) } if ((dset_space_id = - generate_random_dataspace(DATASET_GET_SPACE_TYPE_TEST_SPACE_RANK, NULL, dset_dims, FALSE)) < 0) + generate_random_dataspace(DATASET_GET_SPACE_TYPE_TEST_SPACE_RANK, NULL, dset_dims, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, DATASET_GET_SPACE_TYPE_TEST_DSET_NAME, dset_dtype, dset_space_id, @@ -3328,7 +3772,7 @@ test_get_dataset_space_and_type(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3344,7 +3788,7 @@ test_get_dataset_space_and_type(void) } H5E_END_TRY - return 1; + return; } /* @@ -3352,7 +3796,7 @@ test_get_dataset_space_and_type(void) * can't be retrieved when H5Dget_space and H5Dget_type are passed * invalid parameters, respectively. */ -static int +static void test_get_dataset_space_and_type_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -3371,7 +3815,7 @@ test_get_dataset_space_and_type_invalid_params(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3397,10 +3841,10 @@ test_get_dataset_space_and_type_invalid_params(void) } if ((dset_space_id = generate_random_dataspace(DATASET_GET_SPACE_TYPE_INVALID_PARAMS_TEST_SPACE_RANK, - NULL, NULL, FALSE)) < 0) + NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, DATASET_GET_SPACE_TYPE_INVALID_PARAMS_TEST_DSET_NAME, dset_dtype, @@ -3473,7 +3917,7 @@ test_get_dataset_space_and_type_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3489,20 +3933,20 @@ test_get_dataset_space_and_type_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Dget_space_status. */ -static int +static void test_get_dataset_space_status(void) { TESTING("H5Dget_space_status"); SKIPPED(); - return 0; + return; } /* @@ -3510,14 +3954,14 @@ test_get_dataset_space_status(void) * status can't be retrieved with H5Dget_space_status when * it is passed invalid parameters. */ -static int +static void test_get_dataset_space_status_invalid_params(void) { TESTING("H5Dget_space_status with invalid parameters"); SKIPPED(); - return 0; + return; } /* @@ -3527,14 +3971,13 @@ test_get_dataset_space_status_invalid_params(void) * Also tests that a valid copy of a DAPL used for dataset * access can be retrieved with a call to H5Dget_access_plist. */ -static int +static void test_dataset_property_lists(void) { const char *path_prefix = "/test_prefix"; hsize_t dims[DATASET_PROPERTY_LIST_TEST_SPACE_RANK]; hsize_t chunk_dims[DATASET_PROPERTY_LIST_TEST_SPACE_RANK]; size_t i; - herr_t err_ret = -1; hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t dset_id1 = H5I_INVALID_HID, dset_id2 = H5I_INVALID_HID, dset_id3 = H5I_INVALID_HID, @@ -3545,7 +3988,6 @@ test_dataset_property_lists(void) dset_dtype4 = H5I_INVALID_HID; hid_t space_id = H5I_INVALID_HID; char *tmp_prefix = NULL; - char vol_name[5]; TESTING_MULTIPART("dataset property list operations"); @@ -3555,7 +3997,7 @@ test_dataset_property_lists(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3566,13 +4008,6 @@ test_dataset_property_lists(void) goto error; } - /** for DAOS VOL, this test is problematic since auto chunking can be selected, so skip for now */ - if (H5VLget_connector_name(file_id, vol_name, 5) < 0) { - H5_FAILED(); - printf(" couldn't get VOL connector name\n"); - goto error; - } - if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); @@ -3586,19 +4021,19 @@ test_dataset_property_lists(void) goto error; } - if ((space_id = generate_random_dataspace(DATASET_PROPERTY_LIST_TEST_SPACE_RANK, NULL, dims, FALSE)) < 0) + if ((space_id = generate_random_dataspace(DATASET_PROPERTY_LIST_TEST_SPACE_RANK, NULL, dims, false)) < 0) TEST_ERROR; for (i = 0; i < DATASET_PROPERTY_LIST_TEST_SPACE_RANK; i++) chunk_dims[i] = (hsize_t)(rand() % (int)dims[i] + 1); - if ((dset_dtype1 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype1 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((dset_dtype2 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype2 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((dset_dtype3 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype3 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((dset_dtype4 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype4 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dcpl_id1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) { @@ -3638,8 +4073,8 @@ test_dataset_property_lists(void) { TESTING_2("H5Dget_create_plist"); - /* Try to receive copies of the two property lists, one which has the property set and one which - * does not */ + /* Try to receive copies of the two property lists, one which has the property set and one + * which does not */ if ((dcpl_id1 = H5Dget_create_plist(dset_id1)) < 0) { H5_FAILED(); printf(" couldn't get property list\n"); @@ -3670,20 +4105,6 @@ test_dataset_property_lists(void) printf(" DCPL property values were incorrect\n"); PART_ERROR(H5Dget_create_plist); } - - H5E_BEGIN_TRY - { - err_ret = H5Pget_chunk(dcpl_id2, DATASET_PROPERTY_LIST_TEST_SPACE_RANK, tmp_chunk_dims); - } - H5E_END_TRY - - /* DAOS VOL can auto chunk, so don't fail */ - if (err_ret >= 0 && strcmp(vol_name, "daos") != 0) { - H5_FAILED(); - printf(" property list 2 shouldn't have had chunk dimensionality set (not a chunked " - "layout)\n"); - PART_ERROR(H5Dget_create_plist); - } } PASSED(); @@ -3729,8 +4150,8 @@ test_dataset_property_lists(void) dapl_id1 = H5I_INVALID_HID; } - /* Try to receive copies of the two property lists, one which has the property set and one which - * does not */ + /* Try to receive copies of the two property lists, one which has the property set and one + * which does not */ if ((dapl_id1 = H5Dget_access_plist(dset_id3)) < 0) { H5_FAILED(); printf(" couldn't get property list\n"); @@ -3765,7 +4186,7 @@ test_dataset_property_lists(void) PART_ERROR(H5Dget_access_plist); } - if (HDstrncmp(tmp_prefix, path_prefix, (size_t)buf_size + 1)) { + if (strncmp(tmp_prefix, path_prefix, (size_t)buf_size + 1)) { H5_FAILED(); printf(" DAPL values were incorrect!\n"); PART_ERROR(H5Dget_access_plist); @@ -3779,7 +4200,7 @@ test_dataset_property_lists(void) PART_ERROR(H5Dget_access_plist); } - if (!HDstrncmp(tmp_prefix, path_prefix, (size_t)buf_size + 1)) { + if (!strncmp(tmp_prefix, path_prefix, (size_t)buf_size + 1)) { H5_FAILED(); printf(" DAPL property value was set!\n"); PART_ERROR(H5Dget_access_plist); @@ -3872,20 +4293,6 @@ test_dataset_property_lists(void) printf(" DCPL property values were incorrect\n"); PART_ERROR(H5Dget_create_plist_reopened); } - - H5E_BEGIN_TRY - { - err_ret = H5Pget_chunk(dcpl_id2, DATASET_PROPERTY_LIST_TEST_SPACE_RANK, tmp_chunk_dims); - } - H5E_END_TRY - - /* DAOS VOL can auto chunk, so don't fail */ - if (err_ret >= 0 && strcmp(vol_name, "daos") != 0) { - H5_FAILED(); - printf(" property list 2 shouldn't have had chunk dimensionality set (not a chunked " - "layout)\n"); - PART_ERROR(H5Dget_create_plist_reopened); - } } PASSED(); @@ -3936,7 +4343,7 @@ test_dataset_property_lists(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3962,20 +4369,20 @@ test_dataset_property_lists(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Dget_storage_size. */ -static int +static void test_get_dataset_storage_size(void) { TESTING("H5Dget_storage_size"); SKIPPED(); - return 0; + return; } /* @@ -3983,27 +4390,27 @@ test_get_dataset_storage_size(void) * be retrieved when H5Dget_storage_size is passed * invalid parameters. */ -static int +static void test_get_dataset_storage_size_invalid_params(void) { TESTING("H5Dget_storage_size with invalid parameters"); SKIPPED(); - return 0; + return; } /* * A test for H5Dget_chunk_storage_size. */ -static int +static void test_get_dataset_chunk_storage_size(void) { TESTING("H5Dget_chunk_storage_size"); SKIPPED(); - return 0; + return; } /* @@ -4011,27 +4418,27 @@ test_get_dataset_chunk_storage_size(void) * a dataset can't be retrieved when H5Dget_chunk_storage_size * is passed invalid parameters. */ -static int +static void test_get_dataset_chunk_storage_size_invalid_params(void) { TESTING("H5Dget_chunk_storage_size with invalid parameters"); SKIPPED(); - return 0; + return; } /* * A test for H5Dget_offset. */ -static int +static void test_get_dataset_offset(void) { TESTING("H5Dget_offset"); SKIPPED(); - return 0; + return; } /* @@ -4039,21 +4446,21 @@ test_get_dataset_offset(void) * retrieved when H5Dget_offset is passed invalid * parameters. */ -static int +static void test_get_dataset_offset_invalid_params(void) { TESTING("H5Dget_offset with invalid parameters"); SKIPPED(); - return 0; + return; } /* * A test to check that a small amount of data can be * read back from a dataset using an H5S_ALL selection. */ -static int +static void test_read_dataset_small_all(void) { hsize_t dims[DATASET_SMALL_READ_TEST_ALL_DSET_SPACE_RANK] = {10, 5, 3}; @@ -4071,7 +4478,7 @@ test_read_dataset_small_all(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -4136,7 +4543,7 @@ test_read_dataset_small_all(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -4151,14 +4558,14 @@ test_read_dataset_small_all(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a small amount of data can be * read back from a dataset using a hyperslab selection. */ -static int +static void test_read_dataset_small_hyperslab(void) { hsize_t start[DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK]; @@ -4180,7 +4587,7 @@ test_read_dataset_small_hyperslab(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -4262,7 +4669,7 @@ test_read_dataset_small_hyperslab(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -4278,14 +4685,14 @@ test_read_dataset_small_hyperslab(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a small amount of data can be * read back from a dataset using a point selection. */ -static int +static void test_read_dataset_small_point_selection(void) { hsize_t points[DATASET_SMALL_READ_TEST_POINT_SELECTION_NUM_POINTS * @@ -4307,7 +4714,7 @@ test_read_dataset_small_point_selection(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -4391,7 +4798,7 @@ test_read_dataset_small_point_selection(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -4407,534 +4814,2616 @@ test_read_dataset_small_point_selection(void) } H5E_END_TRY - return 1; + return; } /* - * Tests point selection I/O with different patterns + * A test to check that a small amount of data can be + * read back from multiple datasets using H5S_ALL selections. */ -#define DATASET_IO_POINT_DIM_0 6 -#define DATASET_IO_POINT_DIM_1 9 -#define DATASET_IO_POINT_CDIM_0 4 -#define DATASET_IO_POINT_CDIM_1 3 -#define DATASET_IO_POINT_NPOINTS 10 -#define DATASET_IO_POINT_GEN_POINTS(POINTS, I, J) \ - { \ - for ((I) = 0; (I) < DATASET_IO_POINT_NPOINTS; (I)++) \ - do { \ - (POINTS)[2 * (I)] = (hsize_t)(rand() % DATASET_IO_POINT_DIM_0); \ - (POINTS)[2 * (I) + 1] = (hsize_t)(rand() % DATASET_IO_POINT_DIM_1); \ - for ((J) = 0; ((J) < (I)) && (((POINTS)[2 * (I)] != (POINTS)[2 * (J)]) || \ - ((POINTS)[2 * (I) + 1] != (POINTS)[2 * (J) + 1])); \ - (J)++) \ - ; \ - } while ((J) < (I)); \ - } -static int -test_dataset_io_point_selections(void) +static void +test_read_multi_dataset_small_all(void) { + + hsize_t dims[DATASET_SMALL_READ_TEST_ALL_DSET_SPACE_RANK] = {10, 5, 3}; + size_t i, data_size; hid_t file_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t mspace_id_full = H5I_INVALID_HID, mspace_id_all = H5I_INVALID_HID, fspace_id = H5I_INVALID_HID; - hid_t dcpl_id_chunk = H5I_INVALID_HID; - hsize_t dims[2] = {DATASET_IO_POINT_DIM_0, DATASET_IO_POINT_DIM_1}; - hsize_t cdims[2] = {DATASET_IO_POINT_CDIM_0, DATASET_IO_POINT_CDIM_1}; - hsize_t points[DATASET_IO_POINT_NPOINTS * 2]; - hsize_t points2[DATASET_IO_POINT_NPOINTS * 2]; - hsize_t npoints = DATASET_IO_POINT_NPOINTS; - hsize_t start[2] = {1, 2}; - hsize_t stride[2] = {2, 5}; - hsize_t count[2] = {2, 1}; - hsize_t block[2] = {1, 5}; - int buf_all[DATASET_IO_POINT_DIM_0][DATASET_IO_POINT_DIM_1]; - int file_state[DATASET_IO_POINT_DIM_0][DATASET_IO_POINT_DIM_1]; - int erbuf[DATASET_IO_POINT_DIM_0][DATASET_IO_POINT_DIM_1]; - int buf_point[DATASET_IO_POINT_NPOINTS]; - hbool_t do_chunk; - int i, j; + hid_t fspace_id = H5I_INVALID_HID; + hid_t dset_id_arr[DATASET_MULTI_COUNT]; + hid_t fspace_id_arr[DATASET_MULTI_COUNT]; + hid_t dtype_id_arr[DATASET_MULTI_COUNT]; + void *read_buf_arr[DATASET_MULTI_COUNT]; - TESTING("point selection I/O with all selection in memory and points in file"); + TESTING("small multi read from datasets with H5S_ALL"); /* Make sure the connector supports the API functions being tested */ if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } - /* Create dataspaces and DCPL */ - if ((mspace_id_full = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR; - if ((mspace_id_all = H5Screate_simple(1, &npoints, NULL)) < 0) - TEST_ERROR; - if ((fspace_id = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR; - if ((dcpl_id_chunk = H5Pcreate(H5P_DATASET_CREATE)) < 0) - TEST_ERROR; + /* Prevent uninitialized memory usage on test failure */ + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + read_buf_arr[i] = NULL; + dset_id_arr[i] = H5I_INVALID_HID; + } - /* Enable chunking on chunk DCPL */ - if (H5Pset_chunk(dcpl_id_chunk, 2, cdims) < 0) - TEST_ERROR; + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } - /* Open file */ - if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - TEST_ERROR; + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } - /* Open container group */ - if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) - TEST_ERROR; + if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_READ_MULTI_TEST_ALL_GROUP_NAME, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", DATASET_SMALL_READ_TEST_ALL_GROUP_NAME); + goto error; + } - /* Create group */ - if ((group_id = H5Gcreate2(container_group, DATASET_IO_POINT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT)) < 0) + if ((fspace_id = H5Screate_simple(DATASET_SMALL_READ_TEST_ALL_DSET_SPACE_RANK, dims, NULL)) < 0) TEST_ERROR; - /* Perform with and without chunking */ - for (do_chunk = FALSE;; do_chunk = TRUE) { - if (do_chunk) { - TESTING("point selection I/O with all selection in memory and points in file with chunking"); - - /* Create chunked dataset */ - if ((dset_id = H5Dcreate2(group_id, DATASET_IO_POINT_DSET_NAME_CHUNK, H5T_NATIVE_INT, fspace_id, - H5P_DEFAULT, dcpl_id_chunk, H5P_DEFAULT)) < 0) - TEST_ERROR; - } /* end if */ - else - /* Create non-chunked dataset */ - if ((dset_id = H5Dcreate2(group_id, DATASET_IO_POINT_DSET_NAME_NOCHUNK, H5T_NATIVE_INT, fspace_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR; + for (i = 0, data_size = 1; i < DATASET_SMALL_READ_TEST_ALL_DSET_SPACE_RANK; i++) + data_size *= dims[i]; + data_size *= DATASET_SMALL_READ_TEST_ALL_DSET_DTYPESIZE; - /* Fill write buffer */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - buf_all[i][j] = rand(); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + char dset_name[DSET_NAME_BUF_SIZE]; - /* Write data */ - if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to write entire dataset"); + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_READ_TEST_ALL_DSET_NAME, i, '\0')) + TEST_ERROR; - /* Update file_state */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - file_state[i][j] = buf_all[i][j]; + if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_name, DATASET_SMALL_READ_TEST_ALL_DSET_DTYPE, + fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_SMALL_READ_TEST_ALL_DSET_NAME); + goto error; + } - /* Generate points to read */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); + fspace_id_arr[i] = fspace_id; + dtype_id_arr[i] = DATASET_SMALL_READ_TEST_ALL_DSET_DTYPE; - /* Select points */ - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + if (NULL == (read_buf_arr[i] = malloc(data_size))) TEST_ERROR; + } - /* Wipe read buffer */ - memset(buf_point, 0, sizeof(buf_point)); + if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, fspace_id_arr, fspace_id_arr, + H5P_DEFAULT, read_buf_arr) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", DATASET_SMALL_READ_TEST_ALL_DSET_NAME); + goto error; + } - /* Read points to "all" memory buffer */ - if (H5Dread(dset_id, H5T_NATIVE_INT, mspace_id_all, fspace_id, H5P_DEFAULT, buf_point) < 0) - FAIL_PUTS_ERROR("Failed to read points from dataset to all memory buffer"); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + free(read_buf_arr[i]); + read_buf_arr[i] = NULL; + } + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + for (i = 0; i < DATASET_MULTI_COUNT; i++) + if (H5Dclose(dset_id_arr[i]) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - if (buf_point[i] != file_state[points[2 * i]][points[2 * i + 1]]) - FAIL_PUTS_ERROR("Incorrect data read from points to all memory buffer"); + PASSED(); - /* Generate points to write */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); + return; - /* Select points */ - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) - TEST_ERROR; +error: + H5E_BEGIN_TRY + { + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + free(read_buf_arr[i]); + read_buf_arr[i] = NULL; + H5Dclose(dset_id_arr[i]); + } + H5Sclose(fspace_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY; - /* Fill write buffer */ - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - buf_point[i] = rand(); + return; +} - /* Write points from "all" memory buffer */ - if (H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id_all, fspace_id, H5P_DEFAULT, buf_point) < 0) - FAIL_PUTS_ERROR("Failed to write points to dataset from all memory buffer"); +/* + * A test to check that a small amount of data can be + * read back from datasets using hyperslab selections. + */ +static void +test_read_multi_dataset_small_hyperslab(void) +{ + hsize_t start[DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t stride[DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t count[DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t block[DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t dims[DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK] = {10, 5, 3}; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id_arr[DATASET_MULTI_COUNT]; + hid_t mspace_id = H5I_INVALID_HID, fspace_id = H5I_INVALID_HID; + hid_t mspace_id_arr[DATASET_MULTI_COUNT]; + hid_t fspace_id_arr[DATASET_MULTI_COUNT]; + hid_t dtype_arr[DATASET_MULTI_COUNT]; + void *read_buf_arr[DATASET_MULTI_COUNT]; - /* Update file state */ - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - file_state[points[2 * i]][points[2 * i + 1]] = buf_point[i]; + TESTING("small multi read from datasets with a hyperslab selection"); - /* Wipe read buffer */ - memset(buf_all, 0, sizeof(buf_all)); + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } - /* Read entire dataset */ - if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to read entire dataset"); + /* Prevent uninitialized memory usage on test failure */ + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + read_buf_arr[i] = NULL; + dset_id_arr[i] = H5I_INVALID_HID; + } - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - if (buf_all[i][j] != file_state[i][j]) - FAIL_PUTS_ERROR("Incorrect data found after writing from all memory buffer to points"); + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } - PASSED(); + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } - if (do_chunk) - TESTING("point selection I/O with points in memory and file (same shape) with chunking"); - else - TESTING("point selection I/O with points in memory and file (same shape)"); + if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_READ_MULTI_TEST_HYPERSLAB_GROUP_NAME, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", + DATASET_SMALL_READ_TEST_HYPERSLAB_GROUP_NAME); + goto error; + } - /* Generate points to read */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); + if ((fspace_id = H5Screate_simple(DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK, dims, NULL)) < 0) + TEST_ERROR; + if ((mspace_id = H5Screate_simple(DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK - 1, dims, NULL)) < 0) + TEST_ERROR; - /* Select points */ - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) - TEST_ERROR; + for (i = 0; i < DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK; i++) { + start[i] = 0; + stride[i] = 1; + count[i] = dims[i]; + block[i] = 1; + } - /* Wipe read buffer */ - memset(buf_all, 0, sizeof(buf_all)); + count[2] = 1; - /* Generate expected read buffer */ - memset(erbuf, 0, sizeof(erbuf)); - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - erbuf[points[2 * i]][points[2 * i + 1]] = file_state[points[2 * i]][points[2 * i + 1]]; + if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) < 0) + TEST_ERROR; - /* Read data points->points */ - if (H5Dread(dset_id, H5T_NATIVE_INT, fspace_id, fspace_id, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to read points from dataset to points in memory buffer"); + for (i = 0, data_size = 1; i < DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_SPACE_RANK - 1; i++) + data_size *= dims[i]; + data_size *= DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_DTYPESIZE; - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - if (buf_all[i][j] != erbuf[i][j]) - FAIL_PUTS_ERROR("Incorrect data found read from points in file to points in memory"); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + char dset_name[DSET_NAME_BUF_SIZE]; - /* Generate points to write */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_NAME, i, '\0')) + TEST_ERROR; - /* Select points */ - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_name, DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_DTYPE, + fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_NAME); + goto error; + } + + if (NULL == (read_buf_arr[i] = malloc(data_size))) TEST_ERROR; + mspace_id_arr[i] = mspace_id; + fspace_id_arr[i] = fspace_id; + dtype_arr[i] = DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_DTYPE; + } + + if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_arr, mspace_id_arr, fspace_id_arr, H5P_DEFAULT, + read_buf_arr) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_NAME); + goto error; + } + + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (read_buf_arr[i]) { + free(read_buf_arr[i]); + read_buf_arr[i] = NULL; + } + if (H5Dclose(dset_id_arr[i]) < 0) + TEST_ERROR; + } + + if (H5Sclose(mspace_id) < 0) + TEST_ERROR; + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (read_buf_arr[i]) { + free(read_buf_arr[i]); + read_buf_arr[i] = NULL; + } + H5Dclose(dset_id_arr[i]); + } + H5Sclose(mspace_id); + H5Sclose(fspace_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY; + + return; +} + +/* + * A test to check that a small amount of data can be + * read back from datasets using point selections. + */ +static void +test_read_multi_dataset_small_point_selection(void) +{ + hsize_t points[DATASET_SMALL_READ_TEST_POINT_SELECTION_NUM_POINTS * + DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_SPACE_RANK]; + hsize_t dims[DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_SPACE_RANK] = {10, 10, 10}; + hsize_t mspace_dims[] = {DATASET_SMALL_READ_TEST_POINT_SELECTION_NUM_POINTS}; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID, mspace_id = H5I_INVALID_HID; + hid_t dset_id_arr[DATASET_MULTI_COUNT]; + hid_t mspace_id_arr[DATASET_MULTI_COUNT], fspace_id_arr[DATASET_MULTI_COUNT]; + hid_t dtype_arr[DATASET_MULTI_COUNT]; + void *read_buf[DATASET_MULTI_COUNT]; + + TESTING("small multi read from datasets with point selections"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } + + /* Prevent uninitialized memory usage on test failure */ + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + read_buf[i] = NULL; + dset_id_arr[i] = H5I_INVALID_HID; + } + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } + + if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_READ_MULTI_TEST_POINT_SELECTION_GROUP_NAME, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", + DATASET_SMALL_READ_TEST_POINT_SELECTION_GROUP_NAME); + goto error; + } + + if ((fspace_id = H5Screate_simple(DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_SPACE_RANK, dims, NULL)) < + 0) + TEST_ERROR; + if ((mspace_id = H5Screate_simple(1, mspace_dims, NULL)) < 0) + TEST_ERROR; + + data_size = DATASET_SMALL_READ_TEST_POINT_SELECTION_NUM_POINTS * + DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_DTYPESIZE; + + for (i = 0; i < DATASET_SMALL_READ_TEST_POINT_SELECTION_NUM_POINTS; i++) { + size_t j; + + for (j = 0; j < DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_SPACE_RANK; j++) + points[(i * DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_SPACE_RANK) + j] = i; + } + + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_SMALL_READ_TEST_POINT_SELECTION_NUM_POINTS, + points) < 0) { + H5_FAILED(); + printf(" couldn't select points\n"); + goto error; + } + + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + char dset_name[DSET_NAME_BUF_SIZE]; + + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_NAME, i, '\0')) + TEST_ERROR; + + if ((dset_id_arr[i] = + H5Dcreate2(group_id, dset_name, DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_DTYPE, + fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_NAME); + goto error; + } + + if (NULL == (read_buf[i] = malloc(data_size))) + TEST_ERROR; + + dtype_arr[i] = DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_DTYPE; + mspace_id_arr[i] = mspace_id; + fspace_id_arr[i] = fspace_id; + } + + if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_arr, mspace_id_arr, fspace_id_arr, H5P_DEFAULT, + read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_NAME); + goto error; + } + + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (read_buf[i]) { + free(read_buf[i]); + read_buf[i] = NULL; + } + if (H5Dclose(dset_id_arr[i]) < 0) + TEST_ERROR; + } + + if (H5Sclose(mspace_id) < 0) + TEST_ERROR; + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (read_buf[i]) { + free(read_buf[i]); + read_buf[i] = NULL; + } + H5Dclose(dset_id_arr[i]); + } + H5Sclose(mspace_id); + H5Sclose(fspace_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY; + + return; +} + +/* + * Tests point selection I/O with different patterns + */ +#define DATASET_IO_POINT_DIM_0 6 +#define DATASET_IO_POINT_DIM_1 9 +#define DATASET_IO_POINT_CDIM_0 4 +#define DATASET_IO_POINT_CDIM_1 3 +#define DATASET_IO_POINT_NPOINTS 10 +#define DATASET_IO_POINT_GEN_POINTS(POINTS, I, J) \ + { \ + for ((I) = 0; (I) < DATASET_IO_POINT_NPOINTS; (I)++) \ + do { \ + (POINTS)[2 * (I)] = (hsize_t)(rand() % DATASET_IO_POINT_DIM_0); \ + (POINTS)[2 * (I) + 1] = (hsize_t)(rand() % DATASET_IO_POINT_DIM_1); \ + for ((J) = 0; ((J) < (I)) && (((POINTS)[2 * (I)] != (POINTS)[2 * (J)]) || \ + ((POINTS)[2 * (I) + 1] != (POINTS)[2 * (J) + 1])); \ + (J)++) \ + ; \ + } while ((J) < (I)); \ + } +static void +test_dataset_io_point_selections(void) +{ + hid_t file_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t mspace_id_full = H5I_INVALID_HID, mspace_id_all = H5I_INVALID_HID, fspace_id = H5I_INVALID_HID; + hid_t dcpl_id_chunk = H5I_INVALID_HID; + hsize_t dims[2] = {DATASET_IO_POINT_DIM_0, DATASET_IO_POINT_DIM_1}; + hsize_t cdims[2] = {DATASET_IO_POINT_CDIM_0, DATASET_IO_POINT_CDIM_1}; + hsize_t points[DATASET_IO_POINT_NPOINTS * 2]; + hsize_t points2[DATASET_IO_POINT_NPOINTS * 2]; + hsize_t npoints = DATASET_IO_POINT_NPOINTS; + hsize_t start[2] = {1, 2}; + hsize_t stride[2] = {2, 5}; + hsize_t count[2] = {2, 1}; + hsize_t block[2] = {1, 5}; + int buf_all[DATASET_IO_POINT_DIM_0][DATASET_IO_POINT_DIM_1]; + int file_state[DATASET_IO_POINT_DIM_0][DATASET_IO_POINT_DIM_1]; + int erbuf[DATASET_IO_POINT_DIM_0][DATASET_IO_POINT_DIM_1]; + int buf_point[DATASET_IO_POINT_NPOINTS]; + bool do_chunk; + int i, j; + + TESTING("point selection I/O with all selection in memory and points in file"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } + + /* Create dataspaces and DCPL */ + if ((mspace_id_full = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; + if ((mspace_id_all = H5Screate_simple(1, &npoints, NULL)) < 0) + TEST_ERROR; + if ((fspace_id = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; + if ((dcpl_id_chunk = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + + /* Enable chunking on chunk DCPL */ + if (H5Pset_chunk(dcpl_id_chunk, 2, cdims) < 0) + TEST_ERROR; + + /* Open file */ + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Open container group */ + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Create group */ + if ((group_id = H5Gcreate2(container_group, DATASET_IO_POINT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Perform with and without chunking */ + for (do_chunk = false;; do_chunk = true) { + if (do_chunk) { + TESTING("point selection I/O with all selection in memory and points in file with chunking"); + + /* Create chunked dataset */ + if ((dset_id = H5Dcreate2(group_id, DATASET_IO_POINT_DSET_NAME_CHUNK, H5T_NATIVE_INT, fspace_id, + H5P_DEFAULT, dcpl_id_chunk, H5P_DEFAULT)) < 0) + TEST_ERROR; + } /* end if */ + else + /* Create non-chunked dataset */ + if ((dset_id = H5Dcreate2(group_id, DATASET_IO_POINT_DSET_NAME_NOCHUNK, H5T_NATIVE_INT, fspace_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + /* Fill write buffer */ for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) buf_all[i][j] = rand(); - /* Write data points->points */ - if (H5Dwrite(dset_id, H5T_NATIVE_INT, fspace_id, fspace_id, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to write from in memory to points in dataset"); + /* Write data */ + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to write entire dataset"); + + /* Update file_state */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + file_state[i][j] = buf_all[i][j]; + + /* Generate points to read */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + + /* Select points */ + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + + /* Wipe read buffer */ + memset(buf_point, 0, sizeof(buf_point)); + + /* Read points to "all" memory buffer */ + if (H5Dread(dset_id, H5T_NATIVE_INT, mspace_id_all, fspace_id, H5P_DEFAULT, buf_point) < 0) + FAIL_PUTS_ERROR("Failed to read points from dataset to all memory buffer"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + if (buf_point[i] != file_state[points[2 * i]][points[2 * i + 1]]) + FAIL_PUTS_ERROR("Incorrect data read from points to all memory buffer"); + + /* Generate points to write */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + + /* Select points */ + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + + /* Fill write buffer */ + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + buf_point[i] = rand(); + + /* Write points from "all" memory buffer */ + if (H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id_all, fspace_id, H5P_DEFAULT, buf_point) < 0) + FAIL_PUTS_ERROR("Failed to write points to dataset from all memory buffer"); + + /* Update file state */ + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + file_state[points[2 * i]][points[2 * i + 1]] = buf_point[i]; + + /* Wipe read buffer */ + memset(buf_all, 0, sizeof(buf_all)); + + /* Read entire dataset */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to read entire dataset"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + if (buf_all[i][j] != file_state[i][j]) + FAIL_PUTS_ERROR("Incorrect data found after writing from all memory buffer to points"); + + PASSED(); + + if (do_chunk) + TESTING("point selection I/O with points in memory and file (same shape) with chunking"); + else + TESTING("point selection I/O with points in memory and file (same shape)"); + + /* Generate points to read */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + + /* Select points */ + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + + /* Wipe read buffer */ + memset(buf_all, 0, sizeof(buf_all)); + + /* Generate expected read buffer */ + memset(erbuf, 0, sizeof(erbuf)); + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + erbuf[points[2 * i]][points[2 * i + 1]] = file_state[points[2 * i]][points[2 * i + 1]]; + + /* Read data points->points */ + if (H5Dread(dset_id, H5T_NATIVE_INT, fspace_id, fspace_id, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to read points from dataset to points in memory buffer"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + if (buf_all[i][j] != erbuf[i][j]) + FAIL_PUTS_ERROR("Incorrect data found read from points in file to points in memory"); + + /* Generate points to write */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + + /* Select points */ + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + + /* Fill write buffer */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + buf_all[i][j] = rand(); + + /* Write data points->points */ + if (H5Dwrite(dset_id, H5T_NATIVE_INT, fspace_id, fspace_id, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to write from in memory to points in dataset"); + + /* Update file_state */ + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + file_state[points[2 * i]][points[2 * i + 1]] = buf_all[points[2 * i]][points[2 * i + 1]]; + + /* Wipe read buffer */ + memset(buf_all, 0, sizeof(buf_all)); + + /* Read entire dataset */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to read entire dataset"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + if (buf_all[i][j] != file_state[i][j]) + FAIL_PUTS_ERROR( + "Incorrect data found after writing from points in memory to points in dataset"); + + PASSED(); + + if (do_chunk) + TESTING("point selection I/O with points in memory and file (different shape) with chunking"); + else + TESTING("point selection I/O with points in memory and file (different shape)"); + + /* Generate points to read */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + DATASET_IO_POINT_GEN_POINTS(points2, i, j); + + /* Select points */ + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + if (H5Sselect_elements(mspace_id_full, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points2) < 0) + TEST_ERROR; + + /* Wipe read buffer */ + memset(buf_all, 0, sizeof(buf_all)); + + /* Generate expected read buffer */ + memset(erbuf, 0, sizeof(erbuf)); + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + erbuf[points2[2 * i]][points2[2 * i + 1]] = file_state[points[2 * i]][points[2 * i + 1]]; + + /* Read data points->points */ + if (H5Dread(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to read points from dataset to points in memory buffer"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + if (buf_all[i][j] != erbuf[i][j]) + FAIL_PUTS_ERROR( + "Incorrect data found after reading from points in file to points in memory"); + + /* Generate points to write */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + DATASET_IO_POINT_GEN_POINTS(points2, i, j); + + /* Select points */ + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + if (H5Sselect_elements(mspace_id_full, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points2) < 0) + TEST_ERROR; + + /* Fill write buffer */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + buf_all[i][j] = rand(); + + /* Write data points->points */ + if (H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to write from points in memory to points in dataset"); + + /* Update file_state */ + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + file_state[points[2 * i]][points[2 * i + 1]] = buf_all[points2[2 * i]][points2[2 * i + 1]]; + + /* Wipe read buffer */ + memset(buf_all, 0, sizeof(buf_all)); + + /* Read entire dataset */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to read entire dataset"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + if (buf_all[i][j] != file_state[i][j]) + FAIL_PUTS_ERROR( + "Incorrect data found after writing from points in memory to points in dataset"); + + PASSED(); + + if (do_chunk) + TESTING("point selection I/O with hyperslab in memory and points in file with chunking"); + else + TESTING("point selection I/O with hyperslab in memory and points in file"); + + /* Generate points to read */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + + /* Select points */ + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + + /* Select hyperslab */ + if (H5Sselect_hyperslab(mspace_id_full, H5S_SELECT_SET, start, stride, count, block) < 0) + TEST_ERROR; + + /* Wipe read buffer */ + memset(buf_all, 0, sizeof(buf_all)); + + /* Generate expected read buffer */ + memset(erbuf, 0, sizeof(erbuf)); + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + erbuf[start[0] + (stride[0] * ((hsize_t)i / block[1]))][start[1] + ((hsize_t)i % block[1])] = + file_state[points[2 * i]][points[2 * i + 1]]; + + /* Read data points->hslab */ + if (H5Dread(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to read points from dataset to hyperslab in memory buffer"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + if (buf_all[i][j] != erbuf[i][j]) + FAIL_PUTS_ERROR( + "Incorrect data found after reading from points in file to hyperslab in memory"); + + /* Generate points to write */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + + /* Select points */ + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + + /* Fill write buffer */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + buf_all[i][j] = rand(); + + /* Write data hlsab->points */ + if (H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to write from hyperslab in memory to points in dataset"); + + /* Update file_state */ + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + file_state[points[2 * i]][points[2 * i + 1]] = + buf_all[start[0] + (stride[0] * ((hsize_t)i / block[1]))][start[1] + ((hsize_t)i % block[1])]; + + /* Wipe read buffer */ + memset(buf_all, 0, sizeof(buf_all)); + + /* Read entire dataset */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to read entire dataset"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + if (buf_all[i][j] != file_state[i][j]) + FAIL_PUTS_ERROR("Incorrect data found after writing from hyperslab in memory to " + "points in dataset"); + + PASSED(); + + if (do_chunk) + TESTING("point selection I/O with points in memory and hyperslab in file with chunking"); + else + TESTING("point selection I/O with points in memory and hyperslab in file"); + + /* Generate points to read */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + + /* Select points */ + if (H5Sselect_elements(mspace_id_full, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + + /* Select hyperslab */ + if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) < 0) + TEST_ERROR; + + /* Wipe read buffer */ + memset(buf_all, 0, sizeof(buf_all)); + + /* Generate expected read buffer */ + memset(erbuf, 0, sizeof(erbuf)); + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + erbuf[points[2 * i]][points[2 * i + 1]] = + file_state[start[0] + (stride[0] * ((hsize_t)i / block[1]))] + [start[1] + ((hsize_t)i % block[1])]; + + /* Read data hslab->points */ + if (H5Dread(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to read hyperslab from dataset to points in memory buffer"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + if (buf_all[i][j] != erbuf[i][j]) + FAIL_PUTS_ERROR( + "Incorrect data found after reading from hyperslab in file to points in memory"); + + /* Generate points to write */ + DATASET_IO_POINT_GEN_POINTS(points, i, j); + + /* Select points */ + if (H5Sselect_elements(mspace_id_full, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + TEST_ERROR; + + /* Fill write buffer */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + buf_all[i][j] = rand(); + + /* Write data points->hslab */ + if (H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to write from points in memory to hyperslab in dataset"); + + /* Update file_state */ + for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) + file_state[start[0] + (stride[0] * ((hsize_t)i / block[1]))][start[1] + ((hsize_t)i % block[1])] = + buf_all[points[2 * i]][points[2 * i + 1]]; + + /* Wipe read buffer */ + memset(buf_all, 0, sizeof(buf_all)); + + /* Read entire dataset */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) + FAIL_PUTS_ERROR("Failed to read entire dataset"); + + /* Verify data */ + for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) + for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) + if (buf_all[i][j] != file_state[i][j]) + FAIL_PUTS_ERROR("Incorrect data found after writing from points in memory to " + "hyperslab in dataset"); + + if (!do_chunk) + PASSED(); + + /* Close dataset */ + if (H5Dclose(dset_id) < 0) + TEST_ERROR; + + /* Exit after chunked run */ + if (do_chunk) + break; + } /* end for */ + + /* Close */ + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (H5Pclose(dcpl_id_chunk) < 0) + TEST_ERROR; + if (H5Sclose(mspace_id_full) < 0) + TEST_ERROR; + if (H5Sclose(mspace_id_all) < 0) + TEST_ERROR; + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + H5Sclose(fspace_id); + H5Sclose(mspace_id_full); + H5Sclose(mspace_id_all); + H5Pclose(dcpl_id_chunk); + H5Dclose(dset_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY + + return; +} /* end test_dataset_io_point_selections() */ + +/* + * A test to check that data can't be read from a + * dataset when H5Dread is passed invalid parameters. + */ +static void +test_read_dataset_invalid_params(void) +{ + hsize_t dims[DATASET_READ_INVALID_PARAMS_TEST_DSET_SPACE_RANK] = {10, 5, 3}; + herr_t err_ret = -1; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + void *read_buf = NULL; + + TESTING_MULTIPART("H5Dread with invalid parameters"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } + + TESTING_2("test setup"); + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } + + if ((group_id = H5Gcreate2(container_group, DATASET_READ_INVALID_PARAMS_TEST_GROUP_NAME, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", DATASET_READ_INVALID_PARAMS_TEST_GROUP_NAME); + goto error; + } + + if ((fspace_id = H5Screate_simple(DATASET_READ_INVALID_PARAMS_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) + TEST_ERROR; + + if ((dset_id = H5Dcreate2(group_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_NAME, + DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, fspace_id, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_READ_INVALID_PARAMS_TEST_DSET_NAME); + goto error; + } + + for (i = 0, data_size = 1; i < DATASET_READ_INVALID_PARAMS_TEST_DSET_SPACE_RANK; i++) + data_size *= dims[i]; + data_size *= DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPESIZE; + + if (NULL == (read_buf = malloc(data_size))) + TEST_ERROR; + + PASSED(); + + BEGIN_MULTIPART + { + PART_BEGIN(H5Dread_invalid_dset_id) + { + TESTING_2("H5Dread with an invalid dataset ID"); + + H5E_BEGIN_TRY + { + err_ret = H5Dread(H5I_INVALID_HID, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, + H5S_ALL, H5P_DEFAULT, read_buf); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" read from dataset using H5Dread with an invalid dataset ID!\n"); + PART_ERROR(H5Dread_invalid_dset_id); + } + + PASSED(); + } + PART_END(H5Dread_invalid_dset_id); + + PART_BEGIN(H5Dread_invalid_datatype) + { + TESTING_2("H5Dread with an invalid memory datatype"); + + H5E_BEGIN_TRY + { + err_ret = H5Dread(dset_id, H5I_INVALID_HID, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" read from dataset using H5Dread with an invalid memory datatype!\n"); + PART_ERROR(H5Dread_invalid_datatype); + } + + PASSED(); + } + PART_END(H5Dread_invalid_datatype); + + PART_BEGIN(H5Dread_invalid_mem_dataspace) + { + TESTING_2("H5Dread with an invalid memory dataspace"); + + H5E_BEGIN_TRY + { + err_ret = H5Dread(dset_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5I_INVALID_HID, + H5S_ALL, H5P_DEFAULT, read_buf); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" read from dataset using H5Dread with an invalid memory dataspace!\n"); + PART_ERROR(H5Dread_invalid_mem_dataspace); + } + + PASSED(); + } + PART_END(H5Dread_invalid_mem_dataspace); + + PART_BEGIN(H5Dread_invalid_file_dataspace) + { + TESTING_2("H5Dread with an invalid file dataspace"); + + H5E_BEGIN_TRY + { + err_ret = H5Dread(dset_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, + H5I_INVALID_HID, H5P_DEFAULT, read_buf); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" read from dataset using H5Dread with an invalid file dataspace!\n"); + PART_ERROR(H5Dread_invalid_file_dataspace); + } + + PASSED(); + } + PART_END(H5Dread_invalid_file_dataspace); + + PART_BEGIN(H5Dread_invalid_dxpl) + { + TESTING_2("H5Dread with an invalid DXPL"); + + H5E_BEGIN_TRY + { + err_ret = H5Dread(dset_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, + H5I_INVALID_HID, read_buf); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" read from dataset using H5Dread with an invalid DXPL!\n"); + PART_ERROR(H5Dread_invalid_dxpl); + } + + PASSED(); + } + PART_END(H5Dread_invalid_dxpl); + + PART_BEGIN(H5Dread_invalid_data_buf) + { + TESTING_2("H5Dread with an invalid data buffer"); + + H5E_BEGIN_TRY + { + err_ret = H5Dread(dset_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, + H5P_DEFAULT, NULL); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" read from dataset using H5Dread with an invalid data buffer!\n"); + PART_ERROR(H5Dread_invalid_data_buf); + } + + PASSED(); + } + PART_END(H5Dread_invalid_data_buf); + } + END_MULTIPART; + + TESTING_2("test cleanup"); + + if (read_buf) { + free(read_buf); + read_buf = NULL; + } + + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + if (H5Dclose(dset_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + if (read_buf) + free(read_buf); + H5Sclose(fspace_id); + H5Dclose(dset_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY + + return; +} + +/* + * A test to check that a small write can be + * made to a dataset using an H5S_ALL selection. + */ +static void +test_write_dataset_small_all(void) +{ + hssize_t space_npoints; + hsize_t dims[DATASET_SMALL_WRITE_TEST_ALL_DSET_SPACE_RANK] = {10, 5, 3}; + size_t i; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + void *data = NULL; + + TESTING("small write to dataset with H5S_ALL"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } + + if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_WRITE_TEST_ALL_GROUP_NAME, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", DATASET_SMALL_WRITE_TEST_ALL_GROUP_NAME); + goto error; + } + + if ((fspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_ALL_DSET_SPACE_RANK, dims, NULL)) < 0) + TEST_ERROR; + + if ((dset_id = H5Dcreate2(group_id, DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME, + DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME); + goto error; + } + + /* Close the dataset and dataspace to ensure that writing works correctly in this manner */ + if (H5Dclose(dset_id) < 0) + TEST_ERROR; + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + + if ((dset_id = H5Dopen2(group_id, DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME); + goto error; + } + + if ((fspace_id = H5Dget_space(dset_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataset dataspace\n"); + goto error; + } + + if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + goto error; + } + + if (NULL == (data = malloc((hsize_t)space_npoints * DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPESIZE))) + TEST_ERROR; + + for (i = 0; i < (hsize_t)space_npoints; i++) + ((int *)data)[i] = (int)i; + + if (H5Dwrite(dset_id, DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) { + H5_FAILED(); + printf(" couldn't write to dataset '%s'\n", DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME); + goto error; + } + + if (data) { + free(data); + data = NULL; + } + + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + if (H5Dclose(dset_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + if (data) + free(data); + H5Sclose(fspace_id); + H5Dclose(dset_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY + + return; +} + +/* + * A test to check that a small write can be made + * to a dataset using a hyperslab selection. + */ +static void +test_write_dataset_small_hyperslab(void) +{ + hsize_t start[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t stride[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t count[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t block[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t dims[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK] = {10, 5, 3}; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t mspace_id = H5I_INVALID_HID, fspace_id = H5I_INVALID_HID; + void *data = NULL; + + TESTING("small write to dataset with a hyperslab selection"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } + + if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_WRITE_TEST_HYPERSLAB_GROUP_NAME, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", + DATASET_SMALL_WRITE_TEST_HYPERSLAB_GROUP_NAME); + goto error; + } + + if ((fspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK, dims, NULL)) < 0) + TEST_ERROR; + if ((mspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK - 1, dims, NULL)) < + 0) + TEST_ERROR; + + if ((dset_id = H5Dcreate2(group_id, DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_NAME, + DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPE, fspace_id, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_NAME); + goto error; + } + + for (i = 0, data_size = 1; i < DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK - 1; i++) + data_size *= dims[i]; + data_size *= DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPESIZE; + + if (NULL == (data = malloc(data_size))) + TEST_ERROR; + + for (i = 0; i < data_size / DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPESIZE; i++) + ((int *)data)[i] = (int)i; + + for (i = 0; i < DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK; i++) { + start[i] = 0; + stride[i] = 1; + count[i] = dims[i]; + block[i] = 1; + } + + count[2] = 1; + + if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) < 0) + TEST_ERROR; + + if (H5Dwrite(dset_id, DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPE, mspace_id, fspace_id, H5P_DEFAULT, + data) < 0) { + H5_FAILED(); + printf(" couldn't write to dataset '%s'\n", DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_NAME); + goto error; + } + + if (data) { + free(data); + data = NULL; + } + + if (H5Sclose(mspace_id) < 0) + TEST_ERROR; + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + if (H5Dclose(dset_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + if (data) + free(data); + H5Sclose(mspace_id); + H5Sclose(fspace_id); + H5Dclose(dset_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY + + return; +} + +/* + * A test to check that a small write can be made + * to a dataset using a point selection. + */ +static void +test_write_dataset_small_point_selection(void) +{ + hsize_t points[DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS * + DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK]; + hsize_t dims[DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK] = {10, 10, 10}; + hsize_t mdims[] = {DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS}; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + hid_t mspace_id = H5I_INVALID_HID; + void *data = NULL; + + TESTING("small write to dataset with a point selection"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } + + if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_GROUP_NAME, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", + DATASET_SMALL_WRITE_TEST_POINT_SELECTION_GROUP_NAME); + goto error; + } + + if ((fspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK, dims, NULL)) < + 0) + TEST_ERROR; + if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) + TEST_ERROR; + + if ((dset_id = H5Dcreate2(group_id, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_NAME, + DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPE, fspace_id, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_NAME); + goto error; + } + + data_size = DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS * + DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPESIZE; + + if (NULL == (data = malloc(data_size))) + TEST_ERROR; + + for (i = 0; i < data_size / DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPESIZE; i++) + ((int *)data)[i] = (int)i; + + for (i = 0; i < DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS; i++) { + size_t j; + + for (j = 0; j < DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK; j++) + points[(i * DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK) + j] = i; + } + + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS, + points) < 0) { + H5_FAILED(); + printf(" couldn't select points\n"); + goto error; + } + + if (H5Dwrite(dset_id, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPE, mspace_id, fspace_id, + H5P_DEFAULT, data) < 0) { + H5_FAILED(); + printf(" couldn't write to dataset '%s'\n", DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_NAME); + goto error; + } + + if (data) { + free(data); + data = NULL; + } + + if (H5Sclose(mspace_id) < 0) + TEST_ERROR; + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + if (H5Dclose(dset_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + if (data) + free(data); + H5Sclose(mspace_id); + H5Sclose(fspace_id); + H5Dclose(dset_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY + + return; +} + +/* + * A test to ensure that data is read back correctly from + * a dataset after it has been written. + */ +static void +test_write_dataset_data_verification(void) +{ + hssize_t space_npoints; + hsize_t dims[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK] = {10, 10, 10}; + hsize_t start[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + hsize_t stride[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + hsize_t count[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + hsize_t block[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + hsize_t + points[DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS * DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + hid_t mspace_id = H5I_INVALID_HID; + void *data = NULL; + void *write_buf = NULL; + void *read_buf = NULL; + + TESTING_MULTIPART("verification of dataset data using H5Dwrite then H5Dread"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { + SKIPPED(); + printf(" API functions for basic file, group, basic or more dataset aren't supported with this " + "connector\n"); + return; + } + + TESTING_2("test setup"); + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } + + if ((group_id = H5Gcreate2(container_group, DATASET_DATA_VERIFY_WRITE_TEST_GROUP_NAME, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_GROUP_NAME); + goto error; + } + + if ((fspace_id = H5Screate_simple(DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) + TEST_ERROR; + + if ((dset_id = H5Dcreate2(group_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME, + DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + goto error; + } + + for (i = 0, data_size = 1; i < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; i++) + data_size *= dims[i]; + data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; + + if (NULL == (data = malloc(data_size))) + TEST_ERROR; + + for (i = 0; i < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; i++) + ((int *)data)[i] = (int)i; + + PASSED(); + + BEGIN_MULTIPART + { + PART_BEGIN(H5Dwrite_all_read) + { + TESTING_2("H5Dwrite using H5S_ALL then H5Dread"); + + if (H5Dwrite(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + data) < 0) { + H5_FAILED(); + printf(" couldn't write to dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_all_read); + } + + if (data) { + free(data); + data = NULL; + } + + if (fspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(fspace_id); + } + H5E_END_TRY + fspace_id = H5I_INVALID_HID; + } + if (dset_id >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id); + } + H5E_END_TRY + dset_id = H5I_INVALID_HID; + } + + if ((dset_id = H5Dopen2(group_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_all_read); + } + + if ((fspace_id = H5Dget_space(dset_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataset dataspace\n"); + PART_ERROR(H5Dwrite_all_read); + } + + if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + PART_ERROR(H5Dwrite_all_read); + } + + if (NULL == + (data = malloc((hsize_t)space_npoints * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset read\n"); + PART_ERROR(H5Dwrite_all_read); + } + + if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + data) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_all_read); + } + + for (i = 0; i < (hsize_t)space_npoints; i++) + if (((int *)data)[i] != (int)i) { + H5_FAILED(); + printf(" H5S_ALL selection data verification failed\n"); + PART_ERROR(H5Dwrite_all_read); + } + + if (data) { + free(data); + data = NULL; + } + + PASSED(); + } + PART_END(H5Dwrite_all_read); + + PART_BEGIN(H5Dwrite_hyperslab_read) + { + TESTING_2("H5Dwrite using hyperslab selection then H5Dread"); + + data_size = dims[1] * 2 * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; + + if (NULL == (write_buf = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset write\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + for (i = 0; i < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; i++) + ((int *)write_buf)[i] = 56; + + for (i = 0, data_size = 1; i < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; i++) + data_size *= dims[i]; + data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; + + if (NULL == (data = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset data verification\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + data) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + for (i = 0; i < 2; i++) { + size_t j; + + for (j = 0; j < dims[1]; j++) + ((int *)data)[(i * dims[1] * dims[2]) + (j * dims[2])] = 56; + } + + /* Write to first two rows of dataset */ + start[0] = start[1] = start[2] = 0; + stride[0] = stride[1] = stride[2] = 1; + count[0] = 2; + count[1] = dims[1]; + count[2] = 1; + block[0] = block[1] = block[2] = 1; + + if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) < 0) { + H5_FAILED(); + printf(" couldn't select hyperslab for dataset write\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + { + hsize_t mdims[] = {(hsize_t)2 * dims[1]}; + + if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) { + H5_FAILED(); + printf(" couldn't create memory dataspace\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + } + + if (H5Dwrite(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, mspace_id, fspace_id, + H5P_DEFAULT, write_buf) < 0) { + H5_FAILED(); + printf(" couldn't write to dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + if (mspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(mspace_id); + } + H5E_END_TRY + mspace_id = H5I_INVALID_HID; + } + if (fspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(fspace_id); + } + H5E_END_TRY + fspace_id = H5I_INVALID_HID; + } + if (dset_id >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id); + } + H5E_END_TRY + dset_id = H5I_INVALID_HID; + } + + if ((dset_id = H5Dopen2(group_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + if ((fspace_id = H5Dget_space(dset_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataset dataspace\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + if (NULL == + (read_buf = malloc((hsize_t)space_npoints * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset read\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + if (memcmp(data, read_buf, data_size)) { + H5_FAILED(); + printf(" hyperslab selection data verification failed\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + if (data) { + free(data); + data = NULL; + } + + if (write_buf) { + free(write_buf); + write_buf = NULL; + } + + if (read_buf) { + free(read_buf); + read_buf = NULL; + } + + PASSED(); + } + PART_END(H5Dwrite_hyperslab_read); + + PART_BEGIN(H5Dwrite_point_sel_read) + { + TESTING_2("H5Dwrite using point selection then H5Dread"); + + data_size = + DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; + + if (NULL == (write_buf = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset write\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } + + for (i = 0; i < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; i++) + ((int *)write_buf)[i] = 13; + + for (i = 0, data_size = 1; i < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; i++) + data_size *= dims[i]; + data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; + + if (NULL == (data = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset data verification\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } + + if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + data) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_point_sel_read); + } + + for (i = 0; i < dims[0]; i++) { + size_t j; + + for (j = 0; j < dims[1]; j++) { + size_t k; + + for (k = 0; k < dims[2]; k++) { + if (i == j && j == k) + ((int *)data)[(i * dims[1] * dims[2]) + (j * dims[2]) + k] = 13; + } + } + } + + /* Select a series of 10 points in the dataset */ + for (i = 0; i < DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS; i++) { + size_t j; + + for (j = 0; j < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; j++) + points[(i * DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK) + j] = i; + } + + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS, + points) < 0) { + H5_FAILED(); + printf(" couldn't select elements in dataspace\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } + + { + hsize_t mdims[] = {(hsize_t)DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS}; + + if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) { + H5_FAILED(); + printf(" couldn't create memory dataspace\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } + } + + if (H5Dwrite(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, mspace_id, fspace_id, + H5P_DEFAULT, write_buf) < 0) { + H5_FAILED(); + printf(" couldn't write to dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_point_sel_read); + } + + if (mspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(mspace_id); + } + H5E_END_TRY + mspace_id = H5I_INVALID_HID; + } + if (fspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(fspace_id); + } + H5E_END_TRY + fspace_id = H5I_INVALID_HID; + } + if (dset_id >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id); + } + H5E_END_TRY + dset_id = H5I_INVALID_HID; + } + + if ((dset_id = H5Dopen2(group_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_point_sel_read); + } + + if ((fspace_id = H5Dget_space(dset_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataset dataspace\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } + + if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } + + if (NULL == + (read_buf = malloc((hsize_t)space_npoints * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset read\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } + + if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_point_sel_read); + } + + if (memcmp(data, read_buf, data_size)) { + H5_FAILED(); + printf(" point selection data verification failed\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } + + PASSED(); + } + PART_END(H5Dwrite_point_sel_read); + } + END_MULTIPART; + + TESTING_2("test cleanup"); + + if (data) { + free(data); + data = NULL; + } + + if (write_buf) { + free(write_buf); + write_buf = NULL; + } + + if (read_buf) { + free(read_buf); + read_buf = NULL; + } + + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + if (H5Dclose(dset_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + + PASSED(); - /* Update file_state */ - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - file_state[points[2 * i]][points[2 * i + 1]] = buf_all[points[2 * i]][points[2 * i + 1]]; + return; - /* Wipe read buffer */ - memset(buf_all, 0, sizeof(buf_all)); +error: + H5E_BEGIN_TRY + { + if (data) + free(data); + if (write_buf) + free(write_buf); + if (read_buf) + free(read_buf); + H5Sclose(mspace_id); + H5Sclose(fspace_id); + H5Dclose(dset_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY - /* Read entire dataset */ - if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to read entire dataset"); + return; +} - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - if (buf_all[i][j] != file_state[i][j]) - FAIL_PUTS_ERROR( - "Incorrect data found after writing from points in memory to points in dataset"); +/* + * A test to check that a small multi write can be + * made to a dataset using an H5S_ALL selection. + */ +static void +test_write_multi_dataset_small_all(void) +{ + hssize_t space_npoints; + hsize_t dims[DATASET_SMALL_WRITE_TEST_ALL_DSET_SPACE_RANK] = {10, 5, 3}; + size_t i; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id_arr[DATASET_MULTI_COUNT]; + hid_t fspace_id = H5I_INVALID_HID, fspace_id_arr[DATASET_MULTI_COUNT]; + hid_t dtype_id_arr[DATASET_MULTI_COUNT]; + const void *write_buf[DATASET_MULTI_COUNT]; + void *wbuf_temp[DATASET_MULTI_COUNT]; - PASSED(); + TESTING("small multi write to datasets with H5S_ALL"); - if (do_chunk) - TESTING("point selection I/O with points in memory and file (different shape) with chunking"); - else - TESTING("point selection I/O with points in memory and file (different shape)"); + /* Prevent uninitialized memory usage on test failure */ + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + dset_id_arr[i] = H5I_INVALID_HID; + write_buf[i] = NULL; + wbuf_temp[i] = NULL; + } - /* Generate points to read */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); - DATASET_IO_POINT_GEN_POINTS(points2, i, j); + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } - /* Select points */ - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } + + if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_WRITE_MULTI_TEST_ALL_GROUP_NAME, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", + DATASET_SMALL_WRITE_MULTI_TEST_ALL_GROUP_NAME); + goto error; + } + + if ((fspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_ALL_DSET_SPACE_RANK, dims, NULL)) < 0) + TEST_ERROR; + + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + char dset_name[DSET_NAME_BUF_SIZE]; + + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_WRITE_MULTI_TEST_ALL_DSET_NAME, i, '\0')) TEST_ERROR; - if (H5Sselect_elements(mspace_id_full, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points2) < 0) + + if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_name, DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE, + fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_SMALL_WRITE_MULTI_TEST_ALL_DSET_NAME); + goto error; + } + + /* Close the dataset and dataspace to ensure that writing works correctly in this manner */ + if (H5Dclose(dset_id_arr[i]) < 0) TEST_ERROR; + } - /* Wipe read buffer */ - memset(buf_all, 0, sizeof(buf_all)); + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; - /* Generate expected read buffer */ - memset(erbuf, 0, sizeof(erbuf)); - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - erbuf[points2[2 * i]][points2[2 * i + 1]] = file_state[points[2 * i]][points[2 * i + 1]]; + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + char dset_name[DSET_NAME_BUF_SIZE]; - /* Read data points->points */ - if (H5Dread(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to read points from dataset to points in memory buffer"); + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_WRITE_MULTI_TEST_ALL_DSET_NAME, i, '\0')) + TEST_ERROR; - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - if (buf_all[i][j] != erbuf[i][j]) - FAIL_PUTS_ERROR( - "Incorrect data found after reading from points in file to points in memory"); + if ((dset_id_arr[i] = H5Dopen2(group_id, dset_name, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", dset_name); + goto error; + } - /* Generate points to write */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); - DATASET_IO_POINT_GEN_POINTS(points2, i, j); + if ((fspace_id = H5Dget_space(dset_id_arr[i])) < 0) { + H5_FAILED(); + printf(" couldn't get dataset dataspace\n"); + goto error; + } - /* Select points */ - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + goto error; + } + + dtype_id_arr[i] = DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE; + fspace_id_arr[i] = H5S_ALL; + + if (NULL == + (wbuf_temp[i] = malloc((hsize_t)space_npoints * DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPESIZE))) TEST_ERROR; - if (H5Sselect_elements(mspace_id_full, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points2) < 0) + + for (size_t j = 0; j < (size_t)space_npoints; j++) + ((int **)wbuf_temp)[i][j] = (int)i; + + write_buf[i] = wbuf_temp[i]; + } + + if (H5Dwrite_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, fspace_id_arr, fspace_id_arr, + H5P_DEFAULT, write_buf) < 0) { + H5_FAILED(); + printf(" couldn't write to dataset '%s'\n", DATASET_SMALL_WRITE_MULTI_TEST_ALL_DSET_NAME); + goto error; + } + + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + free(wbuf_temp[i]); + wbuf_temp[i] = NULL; + if (H5Dclose(dset_id_arr[i]) < 0) TEST_ERROR; + } + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; - /* Fill write buffer */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - buf_all[i][j] = rand(); + PASSED(); - /* Write data points->points */ - if (H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to write from points in memory to points in dataset"); + return; - /* Update file_state */ - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - file_state[points[2 * i]][points[2 * i + 1]] = buf_all[points2[2 * i]][points2[2 * i + 1]]; +error: + H5E_BEGIN_TRY + { + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (wbuf_temp[i]) + free(wbuf_temp[i]); + H5Dclose(dset_id_arr[i]); + } - /* Wipe read buffer */ - memset(buf_all, 0, sizeof(buf_all)); + H5Sclose(fspace_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY; - /* Read entire dataset */ - if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to read entire dataset"); + return; +} - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - if (buf_all[i][j] != file_state[i][j]) - FAIL_PUTS_ERROR( - "Incorrect data found after writing from points in memory to points in dataset"); +/* + * A test to check that a small multi write can be made + * to a dataset using a hyperslab selection. + */ +static void +test_write_multi_dataset_small_hyperslab(void) +{ + hsize_t start[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t stride[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t count[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t block[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; + hsize_t dims[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK] = {10, 5, 3}; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id_arr[DATASET_MULTI_COUNT]; + hid_t mspace_id = H5I_INVALID_HID, fspace_id = H5I_INVALID_HID; + hid_t mspace_id_arr[DATASET_MULTI_COUNT], fspace_id_arr[DATASET_MULTI_COUNT]; + hid_t dtype_id_arr[DATASET_MULTI_COUNT]; + const void *write_buf[DATASET_MULTI_COUNT]; + void *wbuf_temp[DATASET_MULTI_COUNT]; - PASSED(); + TESTING("small multi write to datasets with hyperslab selections"); - if (do_chunk) - TESTING("point selection I/O with hyperslab in memory and points in file with chunking"); - else - TESTING("point selection I/O with hyperslab in memory and points in file"); + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } - /* Generate points to read */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + dset_id_arr[i] = H5I_INVALID_HID; + write_buf[i] = NULL; + wbuf_temp[i] = NULL; + } - /* Select points */ - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } + + if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_WRITE_MULTI_TEST_HYPERSLAB_GROUP_NAME, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", + DATASET_SMALL_WRITE_MULTI_TEST_HYPERSLAB_GROUP_NAME); + goto error; + } + + if ((fspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK, dims, NULL)) < 0) + TEST_ERROR; + if ((mspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK - 1, dims, NULL)) < + 0) + TEST_ERROR; + + for (i = 0, data_size = 1; i < DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK - 1; i++) + data_size *= dims[i]; + data_size *= DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPESIZE; + + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + char dset_name[DSET_NAME_BUF_SIZE]; + + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_WRITE_MULTI_TEST_HYPERSLAB_DSET_NAME, i, '\0')) TEST_ERROR; - /* Select hyperslab */ - if (H5Sselect_hyperslab(mspace_id_full, H5S_SELECT_SET, start, stride, count, block) < 0) + if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_name, DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPE, + fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", dset_name); + goto error; + } + + if (NULL == (wbuf_temp[i] = malloc(data_size))) TEST_ERROR; - /* Wipe read buffer */ - memset(buf_all, 0, sizeof(buf_all)); + for (size_t j = 0; j < data_size / DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPESIZE; j++) + ((int **)wbuf_temp)[i][j] = (int)i; - /* Generate expected read buffer */ - memset(erbuf, 0, sizeof(erbuf)); - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - erbuf[start[0] + (stride[0] * ((hsize_t)i / block[1]))][start[1] + ((hsize_t)i % block[1])] = - file_state[points[2 * i]][points[2 * i + 1]]; + write_buf[i] = (const void *)wbuf_temp[i]; + } - /* Read data points->hslab */ - if (H5Dread(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to read points from dataset to hyperslab in memory buffer"); + for (i = 0; i < DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK; i++) { + start[i] = 0; + stride[i] = 1; + count[i] = dims[i]; + block[i] = 1; + } + + count[2] = 1; + + if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) < 0) + TEST_ERROR; - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - if (buf_all[i][j] != erbuf[i][j]) - FAIL_PUTS_ERROR( - "Incorrect data found after reading from points in file to hyperslab in memory"); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + dtype_id_arr[i] = DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPE; + mspace_id_arr[i] = mspace_id; + fspace_id_arr[i] = fspace_id; + } - /* Generate points to write */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); + if (H5Dwrite_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, mspace_id_arr, fspace_id_arr, + H5P_DEFAULT, (const void **)write_buf) < 0) { + H5_FAILED(); + printf(" couldn't write to dataset '%s'\n", DATASET_SMALL_WRITE_MULTI_TEST_HYPERSLAB_DSET_NAME); + goto error; + } - /* Select points */ - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (wbuf_temp[i]) { + free(wbuf_temp[i]); + wbuf_temp[i] = NULL; + } + if (H5Dclose(dset_id_arr[i]) < 0) TEST_ERROR; + } - /* Fill write buffer */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - buf_all[i][j] = rand(); + if (H5Sclose(mspace_id) < 0) + TEST_ERROR; + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; - /* Write data hlsab->points */ - if (H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to write from hyperslab in memory to points in dataset"); + PASSED(); - /* Update file_state */ - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - file_state[points[2 * i]][points[2 * i + 1]] = - buf_all[start[0] + (stride[0] * ((hsize_t)i / block[1]))][start[1] + ((hsize_t)i % block[1])]; + return; - /* Wipe read buffer */ - memset(buf_all, 0, sizeof(buf_all)); +error: + H5E_BEGIN_TRY + { + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (wbuf_temp[i]) { + free(wbuf_temp[i]); + wbuf_temp[i] = NULL; + } + H5Dclose(dset_id_arr[i]); + } + H5Sclose(mspace_id); + H5Sclose(fspace_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + } + H5E_END_TRY; - /* Read entire dataset */ - if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to read entire dataset"); + return; +} - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - if (buf_all[i][j] != file_state[i][j]) - FAIL_PUTS_ERROR( - "Incorrect data found after writing from hyperslab in memory to points in dataset"); +/* + * A test to check that a small multi write can be made + * to a dataset using a point selection. + */ +static void +test_write_multi_dataset_small_point_selection(void) +{ + hsize_t points[DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS * + DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK]; + hsize_t dims[DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK] = {10, 10, 10}; + hsize_t mdims[] = {DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS}; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id_arr[DATASET_MULTI_COUNT]; + hid_t fspace_id = H5I_INVALID_HID, fspace_id_arr[DATASET_MULTI_COUNT]; + hid_t mspace_id = H5I_INVALID_HID, mspace_id_arr[DATASET_MULTI_COUNT]; + hid_t dtype_id_arr[DATASET_MULTI_COUNT]; + const void *write_buf[DATASET_MULTI_COUNT]; + void *wbuf_temp[DATASET_MULTI_COUNT]; - PASSED(); + TESTING("small multi write to datasets with point selections"); - if (do_chunk) - TESTING("point selection I/O with points in memory and hyperslab in file with chunking"); - else - TESTING("point selection I/O with points in memory and hyperslab in file"); + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); + return; + } - /* Generate points to read */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + write_buf[i] = NULL; + wbuf_temp[i] = NULL; + dset_id_arr[i] = H5I_INVALID_HID; + } - /* Select points */ - if (H5Sselect_elements(mspace_id_full, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) - TEST_ERROR; + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } - /* Select hyperslab */ - if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) < 0) - TEST_ERROR; + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } - /* Wipe read buffer */ - memset(buf_all, 0, sizeof(buf_all)); + if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_WRITE_MULTI_TEST_POINT_SELECTION_GROUP_NAME, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", + DATASET_SMALL_WRITE_MULTI_TEST_POINT_SELECTION_GROUP_NAME); + goto error; + } - /* Generate expected read buffer */ - memset(erbuf, 0, sizeof(erbuf)); - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - erbuf[points[2 * i]][points[2 * i + 1]] = - file_state[start[0] + (stride[0] * ((hsize_t)i / block[1]))] - [start[1] + ((hsize_t)i % block[1])]; + if ((fspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK, dims, NULL)) < + 0) + TEST_ERROR; + if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) + TEST_ERROR; - /* Read data hslab->points */ - if (H5Dread(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to read hyperslab from dataset to points in memory buffer"); + data_size = DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS * + DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPESIZE; - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - if (buf_all[i][j] != erbuf[i][j]) - FAIL_PUTS_ERROR( - "Incorrect data found after reading from hyperslab in file to points in memory"); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + char dset_name[DSET_NAME_BUF_SIZE]; - /* Generate points to write */ - DATASET_IO_POINT_GEN_POINTS(points, i, j); + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_WRITE_MULTI_TEST_POINT_SELECTION_DSET_NAME, i, '\0')) + TEST_ERROR; - /* Select points */ - if (H5Sselect_elements(mspace_id_full, H5S_SELECT_SET, DATASET_IO_POINT_NPOINTS, points) < 0) + if ((dset_id_arr[i] = + H5Dcreate2(group_id, dset_name, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPE, + fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", dset_name); + goto error; + } + + if (NULL == (wbuf_temp[i] = malloc(data_size))) TEST_ERROR; - /* Fill write buffer */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - buf_all[i][j] = rand(); + for (size_t j = 0; j < data_size / DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPESIZE; j++) + ((int **)wbuf_temp)[i][j] = (int)i; - /* Write data points->hslab */ - if (H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id_full, fspace_id, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to write from points in memory to hyperslab in dataset"); + write_buf[i] = (const void *)wbuf_temp[i]; + } - /* Update file_state */ - for (i = 0; i < DATASET_IO_POINT_NPOINTS; i++) - file_state[start[0] + (stride[0] * ((hsize_t)i / block[1]))][start[1] + ((hsize_t)i % block[1])] = - buf_all[points[2 * i]][points[2 * i + 1]]; + for (i = 0; i < DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS; i++) { + size_t j; - /* Wipe read buffer */ - memset(buf_all, 0, sizeof(buf_all)); + for (j = 0; j < DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK; j++) + points[(i * DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK) + j] = i; + } - /* Read entire dataset */ - if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_all) < 0) - FAIL_PUTS_ERROR("Failed to read entire dataset"); + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS, + points) < 0) { + H5_FAILED(); + printf(" couldn't select points\n"); + goto error; + } - /* Verify data */ - for (i = 0; i < DATASET_IO_POINT_DIM_0; i++) - for (j = 0; j < DATASET_IO_POINT_DIM_1; j++) - if (buf_all[i][j] != file_state[i][j]) - FAIL_PUTS_ERROR( - "Incorrect data found after writing from points in memory to hyperslab in dataset"); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + dtype_id_arr[i] = DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPE; + mspace_id_arr[i] = mspace_id; + fspace_id_arr[i] = fspace_id; + } - if (!do_chunk) - PASSED(); + if (H5Dwrite_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, mspace_id_arr, fspace_id_arr, + H5P_DEFAULT, (const void **)write_buf) < 0) { + H5_FAILED(); + printf(" couldn't write to multiple datasets\n"); + goto error; + } - /* Close dataset */ - if (H5Dclose(dset_id) < 0) - TEST_ERROR; + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (wbuf_temp[i]) { + free(wbuf_temp[i]); + wbuf_temp[i] = NULL; + } - /* Exit after chunked run */ - if (do_chunk) - break; - } /* end for */ + if (H5Dclose(dset_id_arr[i]) < 0) + TEST_ERROR; + } - /* Close */ + if (H5Sclose(mspace_id) < 0) + TEST_ERROR; + if (H5Sclose(fspace_id) < 0) + TEST_ERROR; if (H5Gclose(group_id) < 0) TEST_ERROR; if (H5Gclose(container_group) < 0) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; - if (H5Pclose(dcpl_id_chunk) < 0) - TEST_ERROR; - if (H5Sclose(mspace_id_full) < 0) - TEST_ERROR; - if (H5Sclose(mspace_id_all) < 0) - TEST_ERROR; - if (H5Sclose(fspace_id) < 0) - TEST_ERROR; PASSED(); - return 0; + return; error: H5E_BEGIN_TRY { + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (wbuf_temp[i]) + free(wbuf_temp[i]); + + H5Dclose(dset_id_arr[i]); + } + + H5Sclose(mspace_id); H5Sclose(fspace_id); - H5Sclose(mspace_id_full); - H5Sclose(mspace_id_all); - H5Pclose(dcpl_id_chunk); - H5Dclose(dset_id); H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); } - H5E_END_TRY + H5E_END_TRY; - return 1; -} /* end test_dataset_io_point_selections() */ + return; +} /* - * A test to check that data can't be read from a - * dataset when H5Dread is passed invalid parameters. + * A test to ensure that data is read back correctly from + * multiple datasets after it has been written. */ -static int -test_read_dataset_invalid_params(void) +static void +test_write_multi_dataset_data_verification(void) { - hsize_t dims[DATASET_READ_INVALID_PARAMS_TEST_DSET_SPACE_RANK] = {10, 5, 3}; - herr_t err_ret = -1; - size_t i, data_size; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; - void *read_buf = NULL; - - TESTING_MULTIPART("H5Dread with invalid parameters"); + hssize_t space_npoints[DATASET_MULTI_COUNT]; + hsize_t dims[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK] = {10, 10, 10}; + hsize_t start[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + hsize_t stride[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + hsize_t count[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + hsize_t block[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + hsize_t + points[DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS * DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id_arr[DATASET_MULTI_COUNT]; + hid_t dtype_id_arr[DATASET_MULTI_COUNT]; + hid_t fspace_id = H5I_INVALID_HID, fspace_id_arr[DATASET_MULTI_COUNT]; + hid_t mspace_id = H5I_INVALID_HID, mspace_id_arr[DATASET_MULTI_COUNT]; + hid_t select_all_arr[DATASET_MULTI_COUNT]; + void *data[DATASET_MULTI_COUNT]; + const void *write_buf[DATASET_MULTI_COUNT]; + void *wbuf_temp[DATASET_MULTI_COUNT]; + void *read_buf[DATASET_MULTI_COUNT]; + char dset_names[DATASET_MULTI_COUNT][DSET_NAME_BUF_SIZE]; + + TESTING_MULTIPART("verification of datasets' data using H5Dwrite_multi then H5Dread_multi"); /* Make sure the connector supports the API functions being tested */ if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); - printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + printf(" API functions for basic file, group, basic or more dataset aren't supported with this " + "connector\n"); + return; } TESTING_2("test setup"); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + select_all_arr[i] = H5S_ALL; + read_buf[i] = NULL; + write_buf[i] = NULL; + wbuf_temp[i] = NULL; + data[i] = NULL; + } + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); @@ -4947,431 +7436,511 @@ test_read_dataset_invalid_params(void) goto error; } - if ((group_id = H5Gcreate2(container_group, DATASET_READ_INVALID_PARAMS_TEST_GROUP_NAME, H5P_DEFAULT, + if ((group_id = H5Gcreate2(container_group, DATASET_DATA_VERIFY_WRITE_MULTI_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" couldn't create container sub-group '%s'\n", DATASET_READ_INVALID_PARAMS_TEST_GROUP_NAME); + printf(" couldn't create container sub-group '%s'\n", + DATASET_DATA_VERIFY_WRITE_MULTI_TEST_GROUP_NAME); goto error; } - if ((fspace_id = H5Screate_simple(DATASET_READ_INVALID_PARAMS_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) - TEST_ERROR; + if ((fspace_id = H5Screate_simple(DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) + TEST_ERROR; + + for (i = 0, data_size = 1; i < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; i++) + data_size *= dims[i]; + data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; + + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (DSET_NAME_BUF_SIZE <= snprintf(dset_names[i], DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_DATA_VERIFY_WRITE_MULTI_TEST_DSET_NAME, i, '\0')) + TEST_ERROR; + + if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_names[i], DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, + fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", dset_names[i]); + goto error; + } + + if (NULL == (data[i] = malloc(data_size))) + TEST_ERROR; - if ((dset_id = H5Dcreate2(group_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_NAME, - DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, fspace_id, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create dataset '%s'\n", DATASET_READ_INVALID_PARAMS_TEST_DSET_NAME); - goto error; - } + dtype_id_arr[i] = DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE; - for (i = 0, data_size = 1; i < DATASET_READ_INVALID_PARAMS_TEST_DSET_SPACE_RANK; i++) - data_size *= dims[i]; - data_size *= DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPESIZE; + for (size_t j = 0; j < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; j++) + ((int **)data)[i][j] = (int)j; - if (NULL == (read_buf = malloc(data_size))) - TEST_ERROR; + write_buf[i] = (const void *)data[i]; + } PASSED(); BEGIN_MULTIPART { - PART_BEGIN(H5Dread_invalid_dset_id) + PART_BEGIN(H5Dwrite_multi_all_read) { - TESTING_2("H5Dread with an invalid dataset ID"); - - H5E_BEGIN_TRY - { - err_ret = H5Dread(H5I_INVALID_HID, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, - H5S_ALL, H5P_DEFAULT, read_buf); - } - H5E_END_TRY + TESTING_2("H5Dwrite_multi using H5S_ALL then H5Dread_multi"); - if (err_ret >= 0) { + if (H5Dwrite_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, select_all_arr, select_all_arr, + H5P_DEFAULT, (const void **)write_buf) < 0) { H5_FAILED(); - printf(" read from dataset using H5Dread with an invalid dataset ID!\n"); - PART_ERROR(H5Dread_invalid_dset_id); + printf(" couldn't write to datasets"); + PART_ERROR(H5Dwrite_multi_all_read); } - PASSED(); - } - PART_END(H5Dread_invalid_dset_id); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (data[i]) { + free(data[i]); + data[i] = NULL; + } - PART_BEGIN(H5Dread_invalid_datatype) - { - TESTING_2("H5Dread with an invalid memory datatype"); + if (dset_id_arr[i] >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id_arr[i]); + } + H5E_END_TRY; + dset_id_arr[i] = H5I_INVALID_HID; + } - H5E_BEGIN_TRY - { - err_ret = H5Dread(dset_id, H5I_INVALID_HID, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf); + if ((dset_id_arr[i] = H5Dopen2(group_id, dset_names[i], H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", dset_names[i]); + PART_ERROR(H5Dwrite_multi_all_read); + } } - H5E_END_TRY - if (err_ret >= 0) { - H5_FAILED(); - printf(" read from dataset using H5Dread with an invalid memory datatype!\n"); - PART_ERROR(H5Dread_invalid_datatype); + if (fspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(fspace_id); + } + H5E_END_TRY; + fspace_id = H5I_INVALID_HID; } - PASSED(); - } - PART_END(H5Dread_invalid_datatype); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if ((fspace_id_arr[i] = H5Dget_space(dset_id_arr[i])) < 0) { + H5_FAILED(); + printf(" couldn't get dataset dataspace\n"); + PART_ERROR(H5Dwrite_multi_all_read); + } - PART_BEGIN(H5Dread_invalid_mem_dataspace) - { - TESTING_2("H5Dread with an invalid memory dataspace"); + if ((space_npoints[i] = H5Sget_simple_extent_npoints(fspace_id_arr[i])) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + PART_ERROR(H5Dwrite_multi_all_read); + } - H5E_BEGIN_TRY - { - err_ret = H5Dread(dset_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5I_INVALID_HID, - H5S_ALL, H5P_DEFAULT, read_buf); + if (NULL == (data[i] = malloc((hsize_t)space_npoints[i] * + DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset read\n"); + PART_ERROR(H5Dwrite_multi_all_read); + } } - H5E_END_TRY - if (err_ret >= 0) { + if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, select_all_arr, select_all_arr, + H5P_DEFAULT, data) < 0) { H5_FAILED(); - printf(" read from dataset using H5Dread with an invalid memory dataspace!\n"); - PART_ERROR(H5Dread_invalid_mem_dataspace); + printf(" couldn't read from datasets\n"); + PART_ERROR(H5Dwrite_multi_all_read); + } + + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + for (size_t j = 0; j < (hsize_t)space_npoints[i]; j++) + if (((int **)data)[i][j] != (int)j) { + H5_FAILED(); + printf(" H5S_ALL selection data verification failed\n"); + PART_ERROR(H5Dwrite_multi_all_read); + } + + if (data[i]) { + free(data[i]); + data[i] = NULL; + } } PASSED(); } - PART_END(H5Dread_invalid_mem_dataspace); + PART_END(H5Dwrite_multi_all_read); - PART_BEGIN(H5Dread_invalid_file_dataspace) + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (data[i]) { + free(data[i]); + data[i] = NULL; + } + } + + PART_BEGIN(H5Dwrite_multi_hyperslab_read) { - TESTING_2("H5Dread with an invalid file dataspace"); + TESTING_2("H5Dwrite_multi using hyperslab selection then H5Dread_multi"); - H5E_BEGIN_TRY - { - err_ret = H5Dread(dset_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, - H5I_INVALID_HID, H5P_DEFAULT, read_buf); - } - H5E_END_TRY + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + data_size = dims[1] * 2 * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; - if (err_ret >= 0) { - H5_FAILED(); - printf(" read from dataset using H5Dread with an invalid file dataspace!\n"); - PART_ERROR(H5Dread_invalid_file_dataspace); - } + if (NULL == (wbuf_temp[i] = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset write\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } - PASSED(); - } - PART_END(H5Dread_invalid_file_dataspace); + for (size_t j = 0; j < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; j++) { + ((int *)wbuf_temp[i])[j] = 56; + } - PART_BEGIN(H5Dread_invalid_dxpl) - { - TESTING_2("H5Dread with an invalid DXPL"); + data_size = 1; + for (size_t j = 0; j < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; j++) + data_size *= dims[j]; + data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; - H5E_BEGIN_TRY - { - err_ret = H5Dread(dset_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, - H5I_INVALID_HID, read_buf); + if (NULL == (data[i] = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for datasets' data verification\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } + + write_buf[i] = (const void *)wbuf_temp[i]; } - H5E_END_TRY - if (err_ret >= 0) { + if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, select_all_arr, select_all_arr, + H5P_DEFAULT, data) < 0) { H5_FAILED(); - printf(" read from dataset using H5Dread with an invalid DXPL!\n"); - PART_ERROR(H5Dread_invalid_dxpl); + printf(" couldn't read from datasets\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); } - PASSED(); - } - PART_END(H5Dread_invalid_dxpl); + /* Reference data for verification */ + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + for (size_t j = 0; j < 2; j++) { + size_t k; - PART_BEGIN(H5Dread_invalid_data_buf) - { - TESTING_2("H5Dread with an invalid data buffer"); + for (k = 0; k < dims[1]; k++) { + size_t index = (j * dims[1] * dims[2]) + (k * dims[2]); + ((int **)data)[i][index] = (int)56; + } + } + } - H5E_BEGIN_TRY - { - err_ret = H5Dread(dset_id, DATASET_READ_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, NULL); + /* Write to first two rows of dataset */ + start[0] = start[1] = start[2] = 0; + stride[0] = stride[1] = stride[2] = 1; + count[0] = 2; + count[1] = dims[1]; + count[2] = 1; + block[0] = block[1] = block[2] = 1; + + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (H5Sselect_hyperslab(fspace_id_arr[i], H5S_SELECT_SET, start, stride, count, block) < 0) { + H5_FAILED(); + printf(" couldn't select hyperslab for dataset write\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } + + { + hsize_t mdims[] = {(hsize_t)2 * dims[1]}; + + if ((mspace_id_arr[i] = H5Screate_simple(1, mdims, NULL)) < 0) { + H5_FAILED(); + printf(" couldn't create memory dataspace\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } + } } - H5E_END_TRY - if (err_ret >= 0) { + if (H5Dwrite_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, mspace_id_arr, fspace_id_arr, + H5P_DEFAULT, (const void **)write_buf) < 0) { H5_FAILED(); - printf(" read from dataset using H5Dread with an invalid data buffer!\n"); - PART_ERROR(H5Dread_invalid_data_buf); + printf(" couldn't write to datasets\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); } - PASSED(); - } - PART_END(H5Dread_invalid_data_buf); - } - END_MULTIPART; - - TESTING_2("test cleanup"); + if (mspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(mspace_id); + } + H5E_END_TRY; + mspace_id = H5I_INVALID_HID; + } + if (fspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(fspace_id); + } + H5E_END_TRY; + fspace_id = H5I_INVALID_HID; + } - if (read_buf) { - free(read_buf); - read_buf = NULL; - } + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (dset_id_arr[i] >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id_arr[i]); + } + H5E_END_TRY; + dset_id_arr[i] = H5I_INVALID_HID; + } - if (H5Sclose(fspace_id) < 0) - TEST_ERROR; - if (H5Dclose(dset_id) < 0) - TEST_ERROR; - if (H5Gclose(group_id) < 0) - TEST_ERROR; - if (H5Gclose(container_group) < 0) - TEST_ERROR; - if (H5Fclose(file_id) < 0) - TEST_ERROR; + if ((dset_id_arr[i] = H5Dopen2(group_id, dset_names[i], H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", dset_names[i]); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } - PASSED(); + if ((fspace_id_arr[i] = H5Dget_space(dset_id_arr[i])) < 0) { + H5_FAILED(); + printf(" couldn't get dataset dataspace\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } - return 0; + if ((space_npoints[i] = H5Sget_simple_extent_npoints(fspace_id_arr[i])) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } -error: - H5E_BEGIN_TRY - { - if (read_buf) - free(read_buf); - H5Sclose(fspace_id); - H5Dclose(dset_id); - H5Gclose(group_id); - H5Gclose(container_group); - H5Fclose(file_id); - } - H5E_END_TRY + if (NULL == (read_buf[i] = malloc((hsize_t)space_npoints[i] * + DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset read\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } + } - return 1; -} + if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, select_all_arr, select_all_arr, + H5P_DEFAULT, read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from datasets\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } -/* - * A test to check that a small write can be - * made to a dataset using an H5S_ALL selection. - */ -static int -test_write_dataset_small_all(void) -{ - hssize_t space_npoints; - hsize_t dims[DATASET_SMALL_WRITE_TEST_ALL_DSET_SPACE_RANK] = {10, 5, 3}; - size_t i; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; - void *data = NULL; + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (memcmp(data[i], read_buf[i], data_size)) { + H5_FAILED(); + printf(" hyperslab selection data verification failed\n"); + PART_ERROR(H5Dwrite_multi_hyperslab_read); + } - TESTING("small write to dataset with H5S_ALL"); + if (data[i]) { + free(data[i]); + data[i] = NULL; + } - /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { - SKIPPED(); - printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; - } + if (wbuf_temp[i]) { + free(wbuf_temp[i]); + wbuf_temp[i] = NULL; + } - if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); - goto error; - } + if (read_buf[i]) { + free(read_buf[i]); + read_buf[i] = NULL; + } + } - if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); - goto error; - } + PASSED(); + } + PART_END(H5Dwrite_multi_hyperslab_read); - if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_WRITE_TEST_ALL_GROUP_NAME, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create container sub-group '%s'\n", DATASET_SMALL_WRITE_TEST_ALL_GROUP_NAME); - goto error; - } + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (wbuf_temp[i]) { + free(wbuf_temp[i]); + wbuf_temp[i] = NULL; + } - if ((fspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_ALL_DSET_SPACE_RANK, dims, NULL)) < 0) - TEST_ERROR; + if (read_buf[i]) { + free(read_buf[i]); + read_buf[i] = NULL; + } + } - if ((dset_id = H5Dcreate2(group_id, DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME, - DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create dataset '%s'\n", DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME); - goto error; - } + PART_BEGIN(H5Dwrite_multi_point_sel_read) + { + TESTING_2("H5Dwrite_multi using point selection then H5Dread_multi"); - /* Close the dataset and dataspace to ensure that writing works correctly in this manner */ - if (H5Dclose(dset_id) < 0) - TEST_ERROR; - if (H5Sclose(fspace_id) < 0) - TEST_ERROR; + data_size = + DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; - if ((dset_id = H5Dopen2(group_id, DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't open dataset '%s'\n", DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME); - goto error; - } + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (NULL == (wbuf_temp[i] = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset write\n"); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } - if ((fspace_id = H5Dget_space(dset_id)) < 0) { - H5_FAILED(); - printf(" couldn't get dataset dataspace\n"); - goto error; - } + for (size_t j = 0; j < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; j++) + ((int **)wbuf_temp)[i][j] = 13; - if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { - H5_FAILED(); - printf(" couldn't get dataspace num points\n"); - goto error; - } + write_buf[i] = (const void *)wbuf_temp[i]; - if (NULL == (data = malloc((hsize_t)space_npoints * DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPESIZE))) - TEST_ERROR; + data_size = 1; - for (i = 0; i < (hsize_t)space_npoints; i++) - ((int *)data)[i] = (int)i; + for (size_t j = 0; j < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; j++) + data_size *= dims[j]; + data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; - if (H5Dwrite(dset_id, DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) { - H5_FAILED(); - printf(" couldn't write to dataset '%s'\n", DATASET_SMALL_WRITE_TEST_ALL_DSET_NAME); - goto error; - } + if (NULL == (data[i] = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset data verification\n"); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } + } - if (data) { - free(data); - data = NULL; - } + if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, select_all_arr, select_all_arr, + H5P_DEFAULT, data) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", + DATASET_DATA_VERIFY_WRITE_MULTI_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } - if (H5Sclose(fspace_id) < 0) - TEST_ERROR; - if (H5Dclose(dset_id) < 0) - TEST_ERROR; - if (H5Gclose(group_id) < 0) - TEST_ERROR; - if (H5Gclose(container_group) < 0) - TEST_ERROR; - if (H5Fclose(file_id) < 0) - TEST_ERROR; + /* Select a series of 10 points in the dataset */ + for (i = 0; i < DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS; i++) { + size_t j; - PASSED(); + for (j = 0; j < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; j++) + points[(i * DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK) + j] = i; + } - return 0; + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (H5Sselect_elements(fspace_id_arr[i], H5S_SELECT_SET, + DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS, points) < 0) { + H5_FAILED(); + printf(" couldn't select elements in dataspace\n"); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } -error: - H5E_BEGIN_TRY - { - if (data) - free(data); - H5Sclose(fspace_id); - H5Dclose(dset_id); - H5Gclose(group_id); - H5Gclose(container_group); - H5Fclose(file_id); - } - H5E_END_TRY + { + hsize_t mdims[] = {(hsize_t)DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS}; - return 1; -} + if ((mspace_id_arr[i] = H5Screate_simple(1, mdims, NULL)) < 0) { + H5_FAILED(); + printf(" couldn't create memory dataspace\n"); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } + } + } -/* - * A test to check that a small write can be made - * to a dataset using a hyperslab selection. - */ -static int -test_write_dataset_small_hyperslab(void) -{ - hsize_t start[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; - hsize_t stride[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; - hsize_t count[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; - hsize_t block[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK]; - hsize_t dims[DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK] = {10, 5, 3}; - size_t i, data_size; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t mspace_id = H5I_INVALID_HID, fspace_id = H5I_INVALID_HID; - void *data = NULL; + if (H5Dwrite_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, mspace_id_arr, fspace_id_arr, + H5P_DEFAULT, (const void **)write_buf) < 0) { + H5_FAILED(); + printf(" couldn't write to datasets\n"); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } - TESTING("small write to dataset with a hyperslab selection"); + if (mspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(mspace_id); + } + H5E_END_TRY; + mspace_id = H5I_INVALID_HID; + } + if (fspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(fspace_id); + } + H5E_END_TRY; + fspace_id = H5I_INVALID_HID; + } - /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { - SKIPPED(); - printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; - } + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (dset_id_arr[i] >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id_arr[i]); + } + H5E_END_TRY; + dset_id_arr[i] = H5I_INVALID_HID; + } - if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); - goto error; - } + if ((dset_id_arr[i] = H5Dopen2(group_id, dset_names[i], H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", dset_names[i]); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } - if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); - goto error; - } + if ((fspace_id = H5Dget_space(dset_id_arr[i])) < 0) { + H5_FAILED(); + printf(" couldn't get dataset dataspace\n"); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } - if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_WRITE_TEST_HYPERSLAB_GROUP_NAME, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create container sub-group '%s'\n", - DATASET_SMALL_WRITE_TEST_HYPERSLAB_GROUP_NAME); - goto error; - } + if ((space_npoints[i] = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } - if ((fspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK, dims, NULL)) < 0) - TEST_ERROR; - if ((mspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK - 1, dims, NULL)) < - 0) - TEST_ERROR; + if (NULL == (read_buf[i] = malloc((hsize_t)space_npoints[i] * + DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset read\n"); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } + } - if ((dset_id = H5Dcreate2(group_id, DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_NAME, - DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPE, fspace_id, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create dataset '%s'\n", DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_NAME); - goto error; - } + if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, select_all_arr, select_all_arr, + H5P_DEFAULT, read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", + DATASET_DATA_VERIFY_WRITE_MULTI_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } - for (i = 0, data_size = 1; i < DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK - 1; i++) - data_size *= dims[i]; - data_size *= DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPESIZE; + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + for (size_t j = 0; j < dims[0]; j++) { + size_t k; - if (NULL == (data = malloc(data_size))) - TEST_ERROR; + for (k = 0; k < dims[1]; k++) { + size_t l; - for (i = 0; i < data_size / DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPESIZE; i++) - ((int *)data)[i] = (int)i; + for (l = 0; l < dims[2]; l++) { + if (j == k && k == l) + ((int **)data)[i][(j * dims[1] * dims[2]) + (k * dims[2]) + l] = 13; + } + } + } - for (i = 0; i < DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK; i++) { - start[i] = 0; - stride[i] = 1; - count[i] = dims[i]; - block[i] = 1; + if (memcmp(data[i], read_buf[i], data_size)) { + H5_FAILED(); + printf(" point selection data verification failed\n"); + PART_ERROR(H5Dwrite_multi_point_sel_read); + } + } + + PASSED(); + } + PART_END(H5Dwrite_multi_point_sel_read); } + END_MULTIPART; - count[2] = 1; + TESTING_2("test cleanup"); - if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) < 0) - TEST_ERROR; + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (data[i]) { + free(data[i]); + data[i] = NULL; + } - if (H5Dwrite(dset_id, DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPE, mspace_id, fspace_id, H5P_DEFAULT, - data) < 0) { - H5_FAILED(); - printf(" couldn't write to dataset '%s'\n", DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_NAME); - goto error; - } + if (wbuf_temp[i]) { + free(wbuf_temp[i]); + wbuf_temp[i] = NULL; + } - if (data) { - free(data); - data = NULL; + if (read_buf[i]) { + free(read_buf[i]); + read_buf[i] = NULL; + } + + if (H5Dclose(dset_id_arr[i]) < 0) + TEST_ERROR; } - if (H5Sclose(mspace_id) < 0) - TEST_ERROR; if (H5Sclose(fspace_id) < 0) TEST_ERROR; - if (H5Dclose(dset_id) < 0) - TEST_ERROR; if (H5Gclose(group_id) < 0) TEST_ERROR; if (H5Gclose(container_group) < 0) @@ -5381,54 +7950,62 @@ test_write_dataset_small_hyperslab(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY { - if (data) - free(data); + for (i = 0; i < DATASET_MULTI_COUNT; i++) { + if (data[i]) + free(data[i]); + if (wbuf_temp[i]) + free(wbuf_temp[i]); + if (read_buf[i]) + free(read_buf[i]); + + H5Dclose(dset_id_arr[i]); + } + H5Sclose(mspace_id); H5Sclose(fspace_id); - H5Dclose(dset_id); H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); } - H5E_END_TRY - - return 1; -} + H5E_END_TRY; -/* - * A test to check that a small write can be made - * to a dataset using a point selection. - */ -static int -test_write_dataset_small_point_selection(void) -{ - hsize_t points[DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS * - DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK]; - hsize_t dims[DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK] = {10, 10, 10}; - hsize_t mdims[] = {DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS}; - size_t i, data_size; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; - hid_t mspace_id = H5I_INVALID_HID; - void *data = NULL; + return; +} - TESTING("small write to dataset with a point selection"); +/* + * A test to check that a dataset can't be written to + * when H5Dwrite is passed invalid parameters. + */ +static void +test_write_dataset_invalid_params(void) +{ + hssize_t space_npoints; + hsize_t dims[DATASET_WRITE_INVALID_PARAMS_TEST_DSET_SPACE_RANK] = {10, 5, 3}; + herr_t err_ret = -1; + size_t i; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + void *data = NULL; + + TESTING_MULTIPART("H5Dwrite with invalid parameters"); /* Make sure the connector supports the API functions being tested */ if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } + TESTING_2("test setup"); + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); @@ -5441,65 +8018,175 @@ test_write_dataset_small_point_selection(void) goto error; } - if ((group_id = H5Gcreate2(container_group, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_GROUP_NAME, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((group_id = H5Gcreate2(container_group, DATASET_WRITE_INVALID_PARAMS_TEST_GROUP_NAME, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't create container sub-group '%s'\n", - DATASET_SMALL_WRITE_TEST_POINT_SELECTION_GROUP_NAME); + DATASET_WRITE_INVALID_PARAMS_TEST_GROUP_NAME); goto error; } - if ((fspace_id = H5Screate_simple(DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK, dims, NULL)) < - 0) - TEST_ERROR; - if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) + if ((fspace_id = H5Screate_simple(DATASET_WRITE_INVALID_PARAMS_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) TEST_ERROR; - if ((dset_id = H5Dcreate2(group_id, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_NAME, - DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPE, fspace_id, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((dset_id = H5Dcreate2(group_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_NAME, + DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" couldn't create dataset '%s'\n", DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_NAME); + printf(" couldn't create dataset '%s'\n", DATASET_WRITE_INVALID_PARAMS_TEST_DSET_NAME); goto error; } - data_size = DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS * - DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPESIZE; + if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + goto error; + } - if (NULL == (data = malloc(data_size))) + if (NULL == (data = malloc((hsize_t)space_npoints * DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPESIZE))) TEST_ERROR; - for (i = 0; i < data_size / DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPESIZE; i++) + for (i = 0; i < (hsize_t)space_npoints; i++) ((int *)data)[i] = (int)i; - for (i = 0; i < DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS; i++) { - size_t j; + PASSED(); - for (j = 0; j < DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK; j++) - points[(i * DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_SPACE_RANK) + j] = i; - } + BEGIN_MULTIPART + { + PART_BEGIN(H5Dwrite_invalid_dset_id) + { + TESTING_2("H5Dwrite with an invalid dataset ID"); - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS, - points) < 0) { - H5_FAILED(); - printf(" couldn't select points\n"); - goto error; - } + H5E_BEGIN_TRY + { + err_ret = H5Dwrite(H5I_INVALID_HID, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, + H5S_ALL, H5P_DEFAULT, data); + } + H5E_END_TRY - if (H5Dwrite(dset_id, DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPE, mspace_id, fspace_id, - H5P_DEFAULT, data) < 0) { - H5_FAILED(); - printf(" couldn't write to dataset '%s'\n", DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_NAME); - goto error; + if (err_ret >= 0) { + H5_FAILED(); + printf(" wrote to dataset using H5Dwrite with an invalid dataset ID!\n"); + PART_ERROR(H5Dwrite_invalid_dset_id); + } + + PASSED(); + } + PART_END(H5Dwrite_invalid_dset_id); + + PART_BEGIN(H5Dwrite_invalid_datatype) + { + TESTING_2("H5Dwrite with an invalid memory datatype"); + + H5E_BEGIN_TRY + { + err_ret = H5Dwrite(dset_id, H5I_INVALID_HID, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" wrote to dataset using H5Dwrite with an invalid memory datatype!\n"); + PART_ERROR(H5Dwrite_invalid_datatype); + } + + PASSED(); + } + PART_END(H5Dwrite_invalid_datatype); + + PART_BEGIN(H5Dwrite_invalid_mem_dataspace) + { + TESTING_2("H5Dwrite with an invalid memory dataspace"); + + H5E_BEGIN_TRY + { + err_ret = H5Dwrite(dset_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5I_INVALID_HID, + H5S_ALL, H5P_DEFAULT, data); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" wrote to dataset using H5Dwrite with an invalid memory dataspace!\n"); + PART_ERROR(H5Dwrite_invalid_mem_dataspace); + } + + PASSED(); + } + PART_END(H5Dwrite_invalid_mem_dataspace); + + PART_BEGIN(H5Dwrite_invalid_file_dataspace) + { + TESTING_2("H5Dwrite with an invalid file dataspace"); + + H5E_BEGIN_TRY + { + err_ret = H5Dwrite(dset_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, + H5I_INVALID_HID, H5P_DEFAULT, data); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" wrote to dataset using H5Dwrite with an invalid file dataspace!\n"); + PART_ERROR(H5Dwrite_invalid_file_dataspace); + } + + PASSED(); + } + PART_END(H5Dwrite_invalid_file_dataspace); + + PART_BEGIN(H5Dwrite_invalid_dxpl) + { + TESTING_2("H5Dwrite with an invalid DXPL"); + + H5E_BEGIN_TRY + { + err_ret = H5Dwrite(dset_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, + H5I_INVALID_HID, data); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" wrote to dataset using H5Dwrite with an invalid DXPL!\n"); + PART_ERROR(H5Dwrite_invalid_dxpl); + } + + PASSED(); + } + PART_END(H5Dwrite_invalid_dxpl); + + PART_BEGIN(H5Dwrite_invalid_data_buf) + { + TESTING_2("H5Dwrite with an invalid data buffer"); + + H5E_BEGIN_TRY + { + err_ret = H5Dwrite(dset_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, + H5P_DEFAULT, NULL); + } + H5E_END_TRY + + if (err_ret >= 0) { + H5_FAILED(); + printf(" wrote to dataset using H5Dwrite with an invalid data buffer!\n"); + PART_ERROR(H5Dwrite_invalid_data_buf); + } + + PASSED(); + } + PART_END(H5Dwrite_invalid_data_buf); } + END_MULTIPART; + + TESTING_2("test cleanup"); if (data) { free(data); data = NULL; } - if (H5Sclose(mspace_id) < 0) - TEST_ERROR; if (H5Sclose(fspace_id) < 0) TEST_ERROR; if (H5Dclose(dset_id) < 0) @@ -5513,14 +8200,13 @@ test_write_dataset_small_point_selection(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY { if (data) free(data); - H5Sclose(mspace_id); H5Sclose(fspace_id); H5Dclose(dset_id); H5Gclose(group_id); @@ -5529,47 +8215,45 @@ test_write_dataset_small_point_selection(void) } H5E_END_TRY - return 1; + return; } /* - * A test to ensure that data is read back correctly from - * a dataset after it has been written. + * A test to ensure that strings of any encoding + * can be written to and read from a dataset */ -static int -test_write_dataset_data_verification(void) +static void +test_dataset_string_encodings(void) { - hssize_t space_npoints; - hsize_t dims[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK] = {10, 10, 10}; - hsize_t start[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; - hsize_t stride[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; - hsize_t count[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; - hsize_t block[DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; - hsize_t - points[DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS * DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK]; - size_t i, data_size; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; - hid_t mspace_id = H5I_INVALID_HID; - void *data = NULL; - void *write_buf = NULL; - void *read_buf = NULL; - - TESTING_MULTIPART("verification of dataset data using H5Dwrite then H5Dread"); + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID; + hid_t dset_id1 = H5I_INVALID_HID; + hid_t dset_id2 = H5I_INVALID_HID; + hid_t type_id1 = H5I_INVALID_HID; + hid_t type_id2 = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hsize_t dims[DATASET_STRING_ENCODINGS_RANK] = {DATASET_STRING_ENCODINGS_EXTENT}; + size_t ascii_str_size = 0; + size_t utf8_str_size = 0; + char *write_buf = NULL; + char *read_buf = NULL; + + TESTING_MULTIPART("string encoding read/write correctness on datasets"); /* Make sure the connector supports the API functions being tested */ if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_ATTR_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, basic or more dataset aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); + ascii_str_size = strlen(DATASET_STRING_ENCODINGS_ASCII_STRING); + utf8_str_size = strlen(DATASET_STRING_ENCODINGS_UTF8_STRING); + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); @@ -5582,357 +8266,314 @@ test_write_dataset_data_verification(void) goto error; } - if ((group_id = H5Gcreate2(container_group, DATASET_DATA_VERIFY_WRITE_TEST_GROUP_NAME, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((space_id = H5Screate_simple(DATASET_STRING_ENCODINGS_RANK, dims, NULL)) < 0) { H5_FAILED(); - printf(" couldn't create container sub-group '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_GROUP_NAME); + printf(" couldn't create dataspace\n"); goto error; } - if ((fspace_id = H5Screate_simple(DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) - TEST_ERROR; + if ((type_id1 = H5Tcopy(H5T_C_S1)) < 0) { + H5_FAILED(); + printf(" couldn't copy builtin string datatype\n"); + goto error; + } - if ((dset_id = H5Dcreate2(group_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME, - DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT)) < 0) { + if ((H5Tset_size(type_id1, ascii_str_size)) < 0) { + H5_FAILED(); + printf(" couldn't set size of string datatype\n"); + goto error; + } + + if ((H5Tset_cset(type_id1, H5T_CSET_ASCII)) < 0) { + H5_FAILED(); + printf(" couldn't set character set of string to ASCII\n"); + goto error; + } + + if ((dset_id1 = H5Dcreate(container_group, DATASET_STRING_ENCODINGS_DSET_NAME1, type_id1, space_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with ascii string\n"); + goto error; + } + + if ((type_id2 = H5Tcopy(H5T_C_S1)) < 0) { + H5_FAILED(); + printf(" couldn't copy builtin string datatype\n"); + goto error; + } + + if ((H5Tset_size(type_id2, utf8_str_size)) < 0) { + H5_FAILED(); + printf(" couldn't set size of string datatype\n"); + goto error; + } + + if ((H5Tset_cset(type_id2, H5T_CSET_UTF8)) < 0) { H5_FAILED(); - printf(" couldn't create dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); + printf(" couldn't set character set of string to UTF-8\n"); goto error; } - for (i = 0, data_size = 1; i < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; i++) - data_size *= dims[i]; - data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; - - if (NULL == (data = malloc(data_size))) - TEST_ERROR; - - for (i = 0; i < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; i++) - ((int *)data)[i] = (int)i; + if ((dset_id2 = H5Dcreate(container_group, DATASET_STRING_ENCODINGS_DSET_NAME2, type_id2, space_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with UTF-8 string\n"); + goto error; + } PASSED(); BEGIN_MULTIPART { - PART_BEGIN(H5Dwrite_all_read) + PART_BEGIN(ASCII_cset) { - TESTING_2("H5Dwrite using H5S_ALL then H5Dread"); - - if (H5Dwrite(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data) < 0) { + TESTING_2("ASCII character set"); + /* Dataset with ASCII string datatype */ + if ((write_buf = calloc(1, ascii_str_size + 1)) == NULL) { H5_FAILED(); - printf(" couldn't write to dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_all_read); - } - - if (data) { - free(data); - data = NULL; - } - - if (fspace_id >= 0) { - H5E_BEGIN_TRY - { - H5Sclose(fspace_id); - } - H5E_END_TRY - fspace_id = H5I_INVALID_HID; - } - if (dset_id >= 0) { - H5E_BEGIN_TRY - { - H5Dclose(dset_id); - } - H5E_END_TRY - dset_id = H5I_INVALID_HID; + printf(" couldn't allocate memory for write buffer\n"); + PART_ERROR(ASCII_cset); } - if ((dset_id = H5Dopen2(group_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't open dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_all_read); - } + memcpy(write_buf, DATASET_STRING_ENCODINGS_ASCII_STRING, ascii_str_size); - if ((fspace_id = H5Dget_space(dset_id)) < 0) { + if ((H5Dwrite(dset_id1, type_id1, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf)) < 0) { H5_FAILED(); - printf(" couldn't get dataset dataspace\n"); - PART_ERROR(H5Dwrite_all_read); + printf(" couldn't write to dataset with ASCII string\n"); + PART_ERROR(ASCII_cset); } - if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + if ((read_buf = calloc(1, ascii_str_size + 1)) == NULL) { H5_FAILED(); - printf(" couldn't get dataspace num points\n"); - PART_ERROR(H5Dwrite_all_read); + printf(" couldn't allocate memory for read buffer\n"); + PART_ERROR(ASCII_cset); } - if (NULL == - (data = malloc((hsize_t)space_npoints * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE))) { + if ((H5Dread(dset_id1, type_id1, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf)) < 0) { H5_FAILED(); - printf(" couldn't allocate buffer for dataset read\n"); - PART_ERROR(H5Dwrite_all_read); + printf(" couldn't read from dataset with ASCII string\n"); + PART_ERROR(ASCII_cset); } - if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data) < 0) { + if (strncmp(write_buf, read_buf, ascii_str_size)) { H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_all_read); + printf(" incorrect data read from dataset with ASCII string\n"); + PART_ERROR(ASCII_cset); } - for (i = 0; i < (hsize_t)space_npoints; i++) - if (((int *)data)[i] != (int)i) { - H5_FAILED(); - printf(" H5S_ALL selection data verification failed\n"); - PART_ERROR(H5Dwrite_all_read); - } + free(write_buf); + write_buf = NULL; - if (data) { - free(data); - data = NULL; - } + free(read_buf); + read_buf = NULL; PASSED(); } - PART_END(H5Dwrite_all_read); + PART_END(ASCII_cset); - PART_BEGIN(H5Dwrite_hyperslab_read) + PART_BEGIN(UTF8_cset) { - TESTING_2("H5Dwrite using hyperslab selection then H5Dread"); - - data_size = dims[1] * 2 * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; - - if (NULL == (write_buf = malloc(data_size))) { + TESTING_2("UTF-8 character set"); + /* Dataset with UTF-8 string datatype */ + if ((write_buf = calloc(1, utf8_str_size + 1)) == NULL) { H5_FAILED(); - printf(" couldn't allocate buffer for dataset write\n"); - PART_ERROR(H5Dwrite_hyperslab_read); + printf(" couldn't allocate memory for write buffer\n"); + PART_ERROR(UTF8_cset); } - for (i = 0; i < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; i++) - ((int *)write_buf)[i] = 56; - - for (i = 0, data_size = 1; i < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; i++) - data_size *= dims[i]; - data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; - - if (NULL == (data = malloc(data_size))) { - H5_FAILED(); - printf(" couldn't allocate buffer for dataset data verification\n"); - PART_ERROR(H5Dwrite_hyperslab_read); - } + memcpy(write_buf, DATASET_STRING_ENCODINGS_UTF8_STRING, utf8_str_size); - if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data) < 0) { + if ((H5Dwrite(dset_id2, type_id2, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf)) < 0) { H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_hyperslab_read); - } - - for (i = 0; i < 2; i++) { - size_t j; - - for (j = 0; j < dims[1]; j++) - ((int *)data)[(i * dims[1] * dims[2]) + (j * dims[2])] = 56; + printf(" couldn't write to dataset with ASCII string\n"); + PART_ERROR(UTF8_cset); } - /* Write to first two rows of dataset */ - start[0] = start[1] = start[2] = 0; - stride[0] = stride[1] = stride[2] = 1; - count[0] = 2; - count[1] = dims[1]; - count[2] = 1; - block[0] = block[1] = block[2] = 1; - - if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) < 0) { + if ((read_buf = calloc(1, utf8_str_size + 1)) == NULL) { H5_FAILED(); - printf(" couldn't select hyperslab for dataset write\n"); - PART_ERROR(H5Dwrite_hyperslab_read); - } - - { - hsize_t mdims[] = {(hsize_t)2 * dims[1]}; - - if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) { - H5_FAILED(); - printf(" couldn't create memory dataspace\n"); - PART_ERROR(H5Dwrite_hyperslab_read); - } + printf(" couldn't allocate memory for read buffer\n"); + PART_ERROR(UTF8_cset); } - if (H5Dwrite(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, mspace_id, fspace_id, - H5P_DEFAULT, write_buf) < 0) { + if ((H5Dread(dset_id2, type_id2, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf)) < 0) { H5_FAILED(); - printf(" couldn't write to dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_hyperslab_read); - } - - if (mspace_id >= 0) { - H5E_BEGIN_TRY - { - H5Sclose(mspace_id); - } - H5E_END_TRY - mspace_id = H5I_INVALID_HID; - } - if (fspace_id >= 0) { - H5E_BEGIN_TRY - { - H5Sclose(fspace_id); - } - H5E_END_TRY - fspace_id = H5I_INVALID_HID; - } - if (dset_id >= 0) { - H5E_BEGIN_TRY - { - H5Dclose(dset_id); - } - H5E_END_TRY - dset_id = H5I_INVALID_HID; + printf(" couldn't read from dataset with ASCII string\n"); + PART_ERROR(UTF8_cset); } - if ((dset_id = H5Dopen2(group_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME, H5P_DEFAULT)) < 0) { + if (strncmp(write_buf, read_buf, utf8_str_size)) { H5_FAILED(); - printf(" couldn't open dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_hyperslab_read); + printf(" incorrect data read from dataset with ASCII string\n"); + PART_ERROR(UTF8_cset); } - if ((fspace_id = H5Dget_space(dset_id)) < 0) { - H5_FAILED(); - printf(" couldn't get dataset dataspace\n"); - PART_ERROR(H5Dwrite_hyperslab_read); - } + free(write_buf); + write_buf = NULL; - if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { - H5_FAILED(); - printf(" couldn't get dataspace num points\n"); - PART_ERROR(H5Dwrite_hyperslab_read); - } + free(read_buf); + read_buf = NULL; - if (NULL == - (read_buf = malloc((hsize_t)space_npoints * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE))) { - H5_FAILED(); - printf(" couldn't allocate buffer for dataset read\n"); - PART_ERROR(H5Dwrite_hyperslab_read); - } + PASSED(); + } + PART_END(UTF8_cset); - if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - read_buf) < 0) { - H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_hyperslab_read); - } + PASSED(); + } + END_MULTIPART; - if (memcmp(data, read_buf, data_size)) { - H5_FAILED(); - printf(" hyperslab selection data verification failed\n"); - PART_ERROR(H5Dwrite_hyperslab_read); - } + TESTING_2("test cleanup"); - if (data) { - free(data); - data = NULL; - } + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Dclose(dset_id1) < 0) + TEST_ERROR; + if (H5Dclose(dset_id2) < 0) + TEST_ERROR; + if (H5Tclose(type_id1) < 0) + TEST_ERROR; + if (H5Tclose(type_id2) < 0) + TEST_ERROR; + if (write_buf) + free(write_buf); + if (read_buf) + free(read_buf); + PASSED(); - if (write_buf) { - free(write_buf); - write_buf = NULL; - } + return; - if (read_buf) { - free(read_buf); - read_buf = NULL; - } +error: + H5E_BEGIN_TRY + { + H5Fclose(file_id); + H5Gclose(container_group); + H5Dclose(dset_id1); + H5Dclose(dset_id2); + H5Tclose(type_id1); + H5Tclose(type_id2); + if (write_buf) + free(write_buf); + if (read_buf) + free(read_buf); + } + H5E_END_TRY; - PASSED(); - } - PART_END(H5Dwrite_hyperslab_read); + return; +} - PART_BEGIN(H5Dwrite_point_sel_read) - { - TESTING_2("H5Dwrite using point selection then H5Dread"); +/* + * A test to ensure that data is read back correctly from a dataset after it has + * been written, using type conversion with builtin types. + */ +static void +test_dataset_builtin_type_conversion(void) +{ + hssize_t space_npoints; + hsize_t dims[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK] = {10, 10, 10}; + hsize_t start[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; + hsize_t stride[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; + hsize_t count[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; + hsize_t block[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; + hsize_t points[DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS * + DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + hid_t mspace_id = H5I_INVALID_HID; + hid_t file_type_id = H5I_INVALID_HID; + H5T_order_t native_order; + void *data = NULL; + void *write_buf = NULL; + void *read_buf = NULL; - data_size = - DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; + TESTING_MULTIPART( + "verification of dataset data using H5Dwrite then H5Dread with type conversion of builtin types"); - if (NULL == (write_buf = malloc(data_size))) { - H5_FAILED(); - printf(" couldn't allocate buffer for dataset write\n"); - PART_ERROR(H5Dwrite_point_sel_read); - } + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { + SKIPPED(); + printf(" API functions for basic file, group, basic or more dataset aren't supported with this " + "connector\n"); + return; + } - for (i = 0; i < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; i++) - ((int *)write_buf)[i] = 13; + TESTING_2("test setup"); - for (i = 0, data_size = 1; i < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; i++) - data_size *= dims[i]; - data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; + if ((native_order = H5Tget_order(DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE)) < 0) { + H5_FAILED(); + printf(" couldn't get native byte order\n"); + goto error; + } + if (native_order == H5T_ORDER_LE) + file_type_id = H5T_STD_I32BE; + else + file_type_id = H5T_STD_I32LE; - if (NULL == (data = malloc(data_size))) { - H5_FAILED(); - printf(" couldn't allocate buffer for dataset data verification\n"); - PART_ERROR(H5Dwrite_point_sel_read); - } + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } - if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data) < 0) { - H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_point_sel_read); - } + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } - for (i = 0; i < dims[0]; i++) { - size_t j; + if ((group_id = H5Gcreate2(container_group, DATASET_DATA_BUILTIN_CONVERSION_TEST_GROUP_NAME, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create container sub-group '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_GROUP_NAME); + goto error; + } - for (j = 0; j < dims[1]; j++) { - size_t k; + if ((fspace_id = H5Screate_simple(DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) + TEST_ERROR; - for (k = 0; k < dims[2]; k++) { - if (i == j && j == k) - ((int *)data)[(i * dims[1] * dims[2]) + (j * dims[2]) + k] = 13; - } - } - } + if ((dset_id = H5Dcreate2(group_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME, file_type_id, + fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + goto error; + } - /* Select a series of 10 points in the dataset */ - for (i = 0; i < DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS; i++) { - size_t j; + for (i = 0, data_size = 1; i < DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK; i++) + data_size *= dims[i]; + data_size *= DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; - for (j = 0; j < DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK; j++) - points[(i * DATASET_DATA_VERIFY_WRITE_TEST_DSET_SPACE_RANK) + j] = i; - } + if (NULL == (data = malloc(data_size))) + TEST_ERROR; - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS, - points) < 0) { - H5_FAILED(); - printf(" couldn't select elements in dataspace\n"); - PART_ERROR(H5Dwrite_point_sel_read); - } + for (i = 0; i < data_size / DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; i++) + ((int *)data)[i] = (int)i; - { - hsize_t mdims[] = {(hsize_t)DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS}; + PASSED(); - if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) { - H5_FAILED(); - printf(" couldn't create memory dataspace\n"); - PART_ERROR(H5Dwrite_point_sel_read); - } - } + BEGIN_MULTIPART + { + PART_BEGIN(H5Dwrite_all_read) + { + TESTING_2("H5Dwrite then H5Dread with H5S_ALL selection"); - if (H5Dwrite(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, mspace_id, fspace_id, - H5P_DEFAULT, write_buf) < 0) { + if (H5Dwrite(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, + H5P_DEFAULT, data) < 0) { H5_FAILED(); - printf(" couldn't write to dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_point_sel_read); + printf(" couldn't write to dataset '%s'\n", + DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_all_read); } - if (mspace_id >= 0) { - H5E_BEGIN_TRY - { - H5Sclose(mspace_id); - } - H5E_END_TRY - mspace_id = H5I_INVALID_HID; + if (data) { + free(data); + data = NULL; } + if (fspace_id >= 0) { H5E_BEGIN_TRY { @@ -5950,303 +8591,360 @@ test_write_dataset_data_verification(void) dset_id = H5I_INVALID_HID; } - if ((dset_id = H5Dopen2(group_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME, H5P_DEFAULT)) < 0) { + if ((dset_id = H5Dopen2(group_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) < + 0) { H5_FAILED(); - printf(" couldn't open dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_point_sel_read); + printf(" couldn't open dataset '%s'\n", DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_all_read); } if ((fspace_id = H5Dget_space(dset_id)) < 0) { H5_FAILED(); printf(" couldn't get dataset dataspace\n"); - PART_ERROR(H5Dwrite_point_sel_read); + PART_ERROR(H5Dwrite_all_read); } if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { H5_FAILED(); printf(" couldn't get dataspace num points\n"); - PART_ERROR(H5Dwrite_point_sel_read); + PART_ERROR(H5Dwrite_all_read); } - if (NULL == - (read_buf = malloc((hsize_t)space_npoints * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE))) { + if (NULL == (data = malloc((hsize_t)space_npoints * + DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE))) { H5_FAILED(); printf(" couldn't allocate buffer for dataset read\n"); - PART_ERROR(H5Dwrite_point_sel_read); + PART_ERROR(H5Dwrite_all_read); } - if (H5Dread(dset_id, DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - read_buf) < 0) { + if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, + H5P_DEFAULT, data) < 0) { H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_point_sel_read); + printf(" couldn't read from dataset '%s'\n", + DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_all_read); } - if (memcmp(data, read_buf, data_size)) { - H5_FAILED(); - printf(" point selection data verification failed\n"); - PART_ERROR(H5Dwrite_point_sel_read); + for (i = 0; i < (hsize_t)space_npoints; i++) + if (((int *)data)[i] != (int)i) { + H5_FAILED(); + printf(" H5S_ALL selection data verification failed\n"); + PART_ERROR(H5Dwrite_all_read); + } + + if (data) { + free(data); + data = NULL; } PASSED(); } - PART_END(H5Dwrite_point_sel_read); - } - END_MULTIPART; - - TESTING_2("test cleanup"); - - if (data) { - free(data); - data = NULL; - } - - if (write_buf) { - free(write_buf); - write_buf = NULL; - } - - if (read_buf) { - free(read_buf); - read_buf = NULL; - } + PART_END(H5Dwrite_all_read); - if (H5Sclose(fspace_id) < 0) - TEST_ERROR; - if (H5Dclose(dset_id) < 0) - TEST_ERROR; - if (H5Gclose(group_id) < 0) - TEST_ERROR; - if (H5Gclose(container_group) < 0) - TEST_ERROR; - if (H5Fclose(file_id) < 0) - TEST_ERROR; + PART_BEGIN(H5Dwrite_hyperslab_read) + { + TESTING_2("H5Dwrite using hyperslab selection then H5Dread"); - PASSED(); + data_size = dims[1] * 2 * DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; - return 0; + if (NULL == (write_buf = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset write\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } -error: - H5E_BEGIN_TRY - { - if (data) - free(data); - if (write_buf) - free(write_buf); - if (read_buf) - free(read_buf); - H5Sclose(mspace_id); - H5Sclose(fspace_id); - H5Dclose(dset_id); - H5Gclose(group_id); - H5Gclose(container_group); - H5Fclose(file_id); - } - H5E_END_TRY + for (i = 0; i < data_size / DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; i++) + ((int *)write_buf)[i] = 56; - return 1; -} + for (i = 0, data_size = 1; i < DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK; i++) + data_size *= dims[i]; + data_size *= DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; -/* - * A test to check that a dataset can't be written to - * when H5Dwrite is passed invalid parameters. - */ -static int -test_write_dataset_invalid_params(void) -{ - hssize_t space_npoints; - hsize_t dims[DATASET_WRITE_INVALID_PARAMS_TEST_DSET_SPACE_RANK] = {10, 5, 3}; - herr_t err_ret = -1; - size_t i; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; - void *data = NULL; + if (NULL == (data = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset data verification\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } - TESTING_MULTIPART("H5Dwrite with invalid parameters"); + if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, + H5P_DEFAULT, data) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", + DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_hyperslab_read); + } - /* Make sure the connector supports the API functions being tested */ - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { - SKIPPED(); - printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; - } + for (i = 0; i < 2; i++) { + size_t j; - TESTING_2("test setup"); + for (j = 0; j < dims[1]; j++) + ((int *)data)[(i * dims[1] * dims[2]) + (j * dims[2])] = 56; + } - if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); - goto error; - } + /* Write to first two rows of dataset */ + start[0] = start[1] = start[2] = 0; + stride[0] = stride[1] = stride[2] = 1; + count[0] = 2; + count[1] = dims[1]; + count[2] = 1; + block[0] = block[1] = block[2] = 1; - if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); - goto error; - } + if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) < 0) { + H5_FAILED(); + printf(" couldn't select hyperslab for dataset write\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } - if ((group_id = H5Gcreate2(container_group, DATASET_WRITE_INVALID_PARAMS_TEST_GROUP_NAME, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create container sub-group '%s'\n", - DATASET_WRITE_INVALID_PARAMS_TEST_GROUP_NAME); - goto error; - } + { + hsize_t mdims[] = {(hsize_t)2 * dims[1]}; - if ((fspace_id = H5Screate_simple(DATASET_WRITE_INVALID_PARAMS_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) - TEST_ERROR; + if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) { + H5_FAILED(); + printf(" couldn't create memory dataspace\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + } - if ((dset_id = H5Dcreate2(group_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_NAME, - DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create dataset '%s'\n", DATASET_WRITE_INVALID_PARAMS_TEST_DSET_NAME); - goto error; - } + if (H5Dwrite(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, mspace_id, fspace_id, + H5P_DEFAULT, write_buf) < 0) { + H5_FAILED(); + printf(" couldn't write to dataset '%s'\n", + DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_hyperslab_read); + } - if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { - H5_FAILED(); - printf(" couldn't get dataspace num points\n"); - goto error; - } + if (mspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(mspace_id); + } + H5E_END_TRY + mspace_id = H5I_INVALID_HID; + } + if (fspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(fspace_id); + } + H5E_END_TRY + fspace_id = H5I_INVALID_HID; + } + if (dset_id >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id); + } + H5E_END_TRY + dset_id = H5I_INVALID_HID; + } - if (NULL == (data = malloc((hsize_t)space_npoints * DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPESIZE))) - TEST_ERROR; + if ((dset_id = H5Dopen2(group_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) < + 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_hyperslab_read); + } - for (i = 0; i < (hsize_t)space_npoints; i++) - ((int *)data)[i] = (int)i; + if ((fspace_id = H5Dget_space(dset_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataset dataspace\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } - PASSED(); + if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } - BEGIN_MULTIPART - { - PART_BEGIN(H5Dwrite_invalid_dset_id) - { - TESTING_2("H5Dwrite with an invalid dataset ID"); + if (NULL == (read_buf = malloc((hsize_t)space_npoints * + DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset read\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } - H5E_BEGIN_TRY - { - err_ret = H5Dwrite(H5I_INVALID_HID, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, - H5S_ALL, H5P_DEFAULT, data); + if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, + H5P_DEFAULT, read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", + DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_hyperslab_read); } - H5E_END_TRY - if (err_ret >= 0) { + if (memcmp(data, read_buf, data_size)) { H5_FAILED(); - printf(" wrote to dataset using H5Dwrite with an invalid dataset ID!\n"); - PART_ERROR(H5Dwrite_invalid_dset_id); + printf(" hyperslab selection data verification failed\n"); + PART_ERROR(H5Dwrite_hyperslab_read); + } + + if (data) { + free(data); + data = NULL; + } + + if (write_buf) { + free(write_buf); + write_buf = NULL; + } + + if (read_buf) { + free(read_buf); + read_buf = NULL; } PASSED(); } - PART_END(H5Dwrite_invalid_dset_id); + PART_END(H5Dwrite_hyperslab_read); - PART_BEGIN(H5Dwrite_invalid_datatype) + PART_BEGIN(H5Dwrite_point_sel_read) { - TESTING_2("H5Dwrite with an invalid memory datatype"); + TESTING_2("H5Dwrite using point selection then H5Dread"); - H5E_BEGIN_TRY - { - err_ret = H5Dwrite(dset_id, H5I_INVALID_HID, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - } - H5E_END_TRY + data_size = DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS * + DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; - if (err_ret >= 0) { + if (NULL == (write_buf = malloc(data_size))) { H5_FAILED(); - printf(" wrote to dataset using H5Dwrite with an invalid memory datatype!\n"); - PART_ERROR(H5Dwrite_invalid_datatype); + printf(" couldn't allocate buffer for dataset write\n"); + PART_ERROR(H5Dwrite_point_sel_read); } - PASSED(); - } - PART_END(H5Dwrite_invalid_datatype); + for (i = 0; i < data_size / DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; i++) + ((int *)write_buf)[i] = 13; - PART_BEGIN(H5Dwrite_invalid_mem_dataspace) - { - TESTING_2("H5Dwrite with an invalid memory dataspace"); + for (i = 0, data_size = 1; i < DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK; i++) + data_size *= dims[i]; + data_size *= DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; - H5E_BEGIN_TRY - { - err_ret = H5Dwrite(dset_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5I_INVALID_HID, - H5S_ALL, H5P_DEFAULT, data); + if (NULL == (data = malloc(data_size))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset data verification\n"); + PART_ERROR(H5Dwrite_point_sel_read); } - H5E_END_TRY - if (err_ret >= 0) { + if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, + H5P_DEFAULT, data) < 0) { H5_FAILED(); - printf(" wrote to dataset using H5Dwrite with an invalid memory dataspace!\n"); - PART_ERROR(H5Dwrite_invalid_mem_dataspace); + printf(" couldn't read from dataset '%s'\n", + DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_point_sel_read); } - PASSED(); - } - PART_END(H5Dwrite_invalid_mem_dataspace); + for (i = 0; i < dims[0]; i++) { + size_t j; - PART_BEGIN(H5Dwrite_invalid_file_dataspace) - { - TESTING_2("H5Dwrite with an invalid file dataspace"); + for (j = 0; j < dims[1]; j++) { + size_t k; + + for (k = 0; k < dims[2]; k++) { + if (i == j && j == k) + ((int *)data)[(i * dims[1] * dims[2]) + (j * dims[2]) + k] = 13; + } + } + } + + /* Select a series of 10 points in the dataset */ + for (i = 0; i < DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS; i++) { + size_t j; + + for (j = 0; j < DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK; j++) + points[(i * DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK) + j] = i; + } + + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS, + points) < 0) { + H5_FAILED(); + printf(" couldn't select elements in dataspace\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } - H5E_BEGIN_TRY { - err_ret = H5Dwrite(dset_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, - H5I_INVALID_HID, H5P_DEFAULT, data); + hsize_t mdims[] = {(hsize_t)DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS}; + + if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) { + H5_FAILED(); + printf(" couldn't create memory dataspace\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } } - H5E_END_TRY - if (err_ret >= 0) { + if (H5Dwrite(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, mspace_id, fspace_id, + H5P_DEFAULT, write_buf) < 0) { H5_FAILED(); - printf(" wrote to dataset using H5Dwrite with an invalid file dataspace!\n"); - PART_ERROR(H5Dwrite_invalid_file_dataspace); + printf(" couldn't write to dataset '%s'\n", + DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_point_sel_read); } - PASSED(); - } - PART_END(H5Dwrite_invalid_file_dataspace); - - PART_BEGIN(H5Dwrite_invalid_dxpl) - { - TESTING_2("H5Dwrite with an invalid DXPL"); + if (mspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(mspace_id); + } + H5E_END_TRY + mspace_id = H5I_INVALID_HID; + } + if (fspace_id >= 0) { + H5E_BEGIN_TRY + { + H5Sclose(fspace_id); + } + H5E_END_TRY + fspace_id = H5I_INVALID_HID; + } + if (dset_id >= 0) { + H5E_BEGIN_TRY + { + H5Dclose(dset_id); + } + H5E_END_TRY + dset_id = H5I_INVALID_HID; + } - H5E_BEGIN_TRY - { - err_ret = H5Dwrite(dset_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, - H5I_INVALID_HID, data); + if ((dset_id = H5Dopen2(group_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) < + 0) { + H5_FAILED(); + printf(" couldn't open dataset '%s'\n", DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_point_sel_read); } - H5E_END_TRY - if (err_ret >= 0) { + if ((fspace_id = H5Dget_space(dset_id)) < 0) { H5_FAILED(); - printf(" wrote to dataset using H5Dwrite with an invalid DXPL!\n"); - PART_ERROR(H5Dwrite_invalid_dxpl); + printf(" couldn't get dataset dataspace\n"); + PART_ERROR(H5Dwrite_point_sel_read); } - PASSED(); - } - PART_END(H5Dwrite_invalid_dxpl); + if ((space_npoints = H5Sget_simple_extent_npoints(fspace_id)) < 0) { + H5_FAILED(); + printf(" couldn't get dataspace num points\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } - PART_BEGIN(H5Dwrite_invalid_data_buf) - { - TESTING_2("H5Dwrite with an invalid data buffer"); + if (NULL == (read_buf = malloc((hsize_t)space_npoints * + DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE))) { + H5_FAILED(); + printf(" couldn't allocate buffer for dataset read\n"); + PART_ERROR(H5Dwrite_point_sel_read); + } - H5E_BEGIN_TRY - { - err_ret = H5Dwrite(dset_id, DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, NULL); + if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, + H5P_DEFAULT, read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", + DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + PART_ERROR(H5Dwrite_point_sel_read); } - H5E_END_TRY - if (err_ret >= 0) { + if (memcmp(data, read_buf, data_size)) { H5_FAILED(); - printf(" wrote to dataset using H5Dwrite with an invalid data buffer!\n"); - PART_ERROR(H5Dwrite_invalid_data_buf); + printf(" point selection data verification failed\n"); + PART_ERROR(H5Dwrite_point_sel_read); } PASSED(); } - PART_END(H5Dwrite_invalid_data_buf); + PART_END(H5Dwrite_point_sel_read); } END_MULTIPART; @@ -6257,6 +8955,16 @@ test_write_dataset_invalid_params(void) data = NULL; } + if (write_buf) { + free(write_buf); + write_buf = NULL; + } + + if (read_buf) { + free(read_buf); + read_buf = NULL; + } + if (H5Sclose(fspace_id) < 0) TEST_ERROR; if (H5Dclose(dset_id) < 0) @@ -6270,13 +8978,18 @@ test_write_dataset_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY { if (data) free(data); + if (write_buf) + free(write_buf); + if (read_buf) + free(read_buf); + H5Sclose(mspace_id); H5Sclose(fspace_id); H5Dclose(dset_id); H5Gclose(group_id); @@ -6285,60 +8998,45 @@ test_write_dataset_invalid_params(void) } H5E_END_TRY - return 1; + return; } -/* - * A test to ensure that data is read back correctly from a dataset after it has - * been written, using type conversion with builtin types. - */ -static int -test_dataset_builtin_type_conversion(void) +static void +test_dataset_real_to_int_conversion(void) { - hssize_t space_npoints; - hsize_t dims[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK] = {10, 10, 10}; - hsize_t start[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; - hsize_t stride[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; - hsize_t count[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; - hsize_t block[DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; - hsize_t points[DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS * - DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK]; - size_t i, data_size; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; - hid_t mspace_id = H5I_INVALID_HID; - hid_t file_type_id = H5I_INVALID_HID; - H5T_order_t native_order; - void *data = NULL; - void *write_buf = NULL; - void *read_buf = NULL; + hssize_t space_npoints; + hsize_t dims[DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK] = {10, 10, 10}; + hsize_t start[DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK]; + hsize_t stride[DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK]; + hsize_t count[DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK]; + hsize_t block[DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK]; + hsize_t points[DATASET_DATA_REAL_CONVERSION_TEST_NUM_POINTS * + DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK]; + size_t i, data_size; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + hid_t mspace_id = H5I_INVALID_HID; + hid_t real_type_id = DATASET_DATA_REAL_CONVERSION_TEST_REAL_TYPE; + void *data = NULL; + void *write_buf = NULL; + void *read_buf = NULL; TESTING_MULTIPART( - "verification of dataset data using H5Dwrite then H5Dread with type conversion of builtin types"); + "verification of dataset data using H5Dwrite then H5Dread with real <-> integer type conversion"); /* Make sure the connector supports the API functions being tested */ if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, basic or more dataset aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); - if ((native_order = H5Tget_order(DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE)) < 0) { - H5_FAILED(); - printf(" couldn't get native byte order\n"); - goto error; - } - if (native_order == H5T_ORDER_LE) - file_type_id = H5T_STD_I32BE; - else - file_type_id = H5T_STD_I32LE; - if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); @@ -6351,31 +9049,32 @@ test_dataset_builtin_type_conversion(void) goto error; } - if ((group_id = H5Gcreate2(container_group, DATASET_DATA_BUILTIN_CONVERSION_TEST_GROUP_NAME, H5P_DEFAULT, + if ((group_id = H5Gcreate2(container_group, DATASET_DATA_REAL_CONVERSION_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" couldn't create container sub-group '%s'\n", DATASET_DATA_VERIFY_WRITE_TEST_GROUP_NAME); + printf(" couldn't create container sub-group '%s'\n", + DATASET_DATA_REAL_CONVERSION_TEST_GROUP_NAME); goto error; } - if ((fspace_id = H5Screate_simple(DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) + if ((fspace_id = H5Screate_simple(DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK, dims, NULL)) < 0) TEST_ERROR; - if ((dset_id = H5Dcreate2(group_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME, file_type_id, - fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((dset_id = H5Dcreate2(group_id, DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME, real_type_id, fspace_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" couldn't create dataset '%s'\n", DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't create dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); goto error; } - for (i = 0, data_size = 1; i < DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK; i++) + for (i = 0, data_size = 1; i < DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK; i++) data_size *= dims[i]; - data_size *= DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; + data_size *= DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE; if (NULL == (data = malloc(data_size))) TEST_ERROR; - for (i = 0; i < data_size / DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; i++) + for (i = 0; i < data_size / DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE; i++) ((int *)data)[i] = (int)i; PASSED(); @@ -6384,13 +9083,12 @@ test_dataset_builtin_type_conversion(void) { PART_BEGIN(H5Dwrite_all_read) { - TESTING_2("H5Dwrite then H5Dread with H5S_ALL selection"); + TESTING_2("write then read int from real dataset with H5S_ALL selection"); - if (H5Dwrite(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data) < 0) { + if (H5Dwrite(dset_id, DATASET_DATA_REAL_CONVERSION_TEST_INT_TYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + data) < 0) { H5_FAILED(); - printf(" couldn't write to dataset '%s'\n", - DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't write to dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_all_read); } @@ -6404,7 +9102,7 @@ test_dataset_builtin_type_conversion(void) { H5Sclose(fspace_id); } - H5E_END_TRY + H5E_END_TRY; fspace_id = H5I_INVALID_HID; } if (dset_id >= 0) { @@ -6412,14 +9110,14 @@ test_dataset_builtin_type_conversion(void) { H5Dclose(dset_id); } - H5E_END_TRY + H5E_END_TRY; dset_id = H5I_INVALID_HID; } - if ((dset_id = H5Dopen2(group_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) < + if ((dset_id = H5Dopen2(group_id, DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" couldn't open dataset '%s'\n", DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't open dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_all_read); } @@ -6435,18 +9133,17 @@ test_dataset_builtin_type_conversion(void) PART_ERROR(H5Dwrite_all_read); } - if (NULL == (data = malloc((hsize_t)space_npoints * - DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE))) { + if (NULL == + (data = malloc((hsize_t)space_npoints * DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE))) { H5_FAILED(); printf(" couldn't allocate buffer for dataset read\n"); PART_ERROR(H5Dwrite_all_read); } - if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data) < 0) { + if (H5Dread(dset_id, DATASET_DATA_REAL_CONVERSION_TEST_INT_TYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + data) < 0) { H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", - DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't read from dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_all_read); } @@ -6466,11 +9163,26 @@ test_dataset_builtin_type_conversion(void) } PART_END(H5Dwrite_all_read); + if (data) { + free(data); + data = NULL; + } + + if (write_buf) { + free(write_buf); + write_buf = NULL; + } + + if (read_buf) { + free(read_buf); + read_buf = NULL; + } + PART_BEGIN(H5Dwrite_hyperslab_read) { - TESTING_2("H5Dwrite using hyperslab selection then H5Dread"); + TESTING_2("write then read int from real dataset with hyperslab selection"); - data_size = dims[1] * 2 * DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; + data_size = dims[1] * 2 * DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE; if (NULL == (write_buf = malloc(data_size))) { H5_FAILED(); @@ -6478,26 +9190,21 @@ test_dataset_builtin_type_conversion(void) PART_ERROR(H5Dwrite_hyperslab_read); } - for (i = 0; i < data_size / DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; i++) + for (i = 0; i < data_size / DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE; i++) ((int *)write_buf)[i] = 56; - for (i = 0, data_size = 1; i < DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK; i++) + for (i = 0, data_size = 1; i < DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK; i++) data_size *= dims[i]; - data_size *= DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; + data_size *= DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE; - if (NULL == (data = malloc(data_size))) { + if (NULL == (data = calloc(1, data_size))) { H5_FAILED(); printf(" couldn't allocate buffer for dataset data verification\n"); PART_ERROR(H5Dwrite_hyperslab_read); } - if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data) < 0) { - H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", - DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); - PART_ERROR(H5Dwrite_hyperslab_read); - } + for (i = 0; i < dims[0] * dims[1] * dims[2]; i++) + ((int *)data)[i] = (int)i; for (i = 0; i < 2; i++) { size_t j; @@ -6530,11 +9237,10 @@ test_dataset_builtin_type_conversion(void) } } - if (H5Dwrite(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, mspace_id, fspace_id, + if (H5Dwrite(dset_id, DATASET_DATA_REAL_CONVERSION_TEST_INT_TYPE, mspace_id, fspace_id, H5P_DEFAULT, write_buf) < 0) { H5_FAILED(); - printf(" couldn't write to dataset '%s'\n", - DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't write to dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_hyperslab_read); } @@ -6543,7 +9249,7 @@ test_dataset_builtin_type_conversion(void) { H5Sclose(mspace_id); } - H5E_END_TRY + H5E_END_TRY; mspace_id = H5I_INVALID_HID; } if (fspace_id >= 0) { @@ -6551,7 +9257,7 @@ test_dataset_builtin_type_conversion(void) { H5Sclose(fspace_id); } - H5E_END_TRY + H5E_END_TRY; fspace_id = H5I_INVALID_HID; } if (dset_id >= 0) { @@ -6559,14 +9265,14 @@ test_dataset_builtin_type_conversion(void) { H5Dclose(dset_id); } - H5E_END_TRY + H5E_END_TRY; dset_id = H5I_INVALID_HID; } - if ((dset_id = H5Dopen2(group_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) < + if ((dset_id = H5Dopen2(group_id, DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" couldn't open dataset '%s'\n", DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't open dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_hyperslab_read); } @@ -6583,17 +9289,16 @@ test_dataset_builtin_type_conversion(void) } if (NULL == (read_buf = malloc((hsize_t)space_npoints * - DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE))) { + DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE))) { H5_FAILED(); printf(" couldn't allocate buffer for dataset read\n"); PART_ERROR(H5Dwrite_hyperslab_read); } - if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, read_buf) < 0) { + if (H5Dread(dset_id, DATASET_DATA_REAL_CONVERSION_TEST_INT_TYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + read_buf) < 0) { H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", - DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't read from dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_hyperslab_read); } @@ -6622,12 +9327,27 @@ test_dataset_builtin_type_conversion(void) } PART_END(H5Dwrite_hyperslab_read); + if (data) { + free(data); + data = NULL; + } + + if (write_buf) { + free(write_buf); + write_buf = NULL; + } + + if (read_buf) { + free(read_buf); + read_buf = NULL; + } + PART_BEGIN(H5Dwrite_point_sel_read) { - TESTING_2("H5Dwrite using point selection then H5Dread"); + TESTING_2("write then read int from real dataset with point selection"); - data_size = DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS * - DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; + data_size = DATASET_DATA_REAL_CONVERSION_TEST_NUM_POINTS * + DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE; if (NULL == (write_buf = malloc(data_size))) { H5_FAILED(); @@ -6635,12 +9355,12 @@ test_dataset_builtin_type_conversion(void) PART_ERROR(H5Dwrite_point_sel_read); } - for (i = 0; i < data_size / DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; i++) + for (i = 0; i < data_size / DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE; i++) ((int *)write_buf)[i] = 13; - for (i = 0, data_size = 1; i < DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK; i++) + for (i = 0, data_size = 1; i < DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK; i++) data_size *= dims[i]; - data_size *= DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE; + data_size *= DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE; if (NULL == (data = malloc(data_size))) { H5_FAILED(); @@ -6648,11 +9368,10 @@ test_dataset_builtin_type_conversion(void) PART_ERROR(H5Dwrite_point_sel_read); } - if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data) < 0) { + if (H5Dread(dset_id, DATASET_DATA_REAL_CONVERSION_TEST_INT_TYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + data) < 0) { H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", - DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't read from dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_point_sel_read); } @@ -6670,14 +9389,14 @@ test_dataset_builtin_type_conversion(void) } /* Select a series of 10 points in the dataset */ - for (i = 0; i < DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS; i++) { + for (i = 0; i < DATASET_DATA_REAL_CONVERSION_TEST_NUM_POINTS; i++) { size_t j; - for (j = 0; j < DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK; j++) - points[(i * DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_SPACE_RANK) + j] = i; + for (j = 0; j < DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK; j++) + points[(i * DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK) + j] = i; } - if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS, + if (H5Sselect_elements(fspace_id, H5S_SELECT_SET, DATASET_DATA_REAL_CONVERSION_TEST_NUM_POINTS, points) < 0) { H5_FAILED(); printf(" couldn't select elements in dataspace\n"); @@ -6685,7 +9404,7 @@ test_dataset_builtin_type_conversion(void) } { - hsize_t mdims[] = {(hsize_t)DATASET_DATA_BUILTIN_CONVERSION_TEST_NUM_POINTS}; + hsize_t mdims[] = {(hsize_t)DATASET_DATA_REAL_CONVERSION_TEST_NUM_POINTS}; if ((mspace_id = H5Screate_simple(1, mdims, NULL)) < 0) { H5_FAILED(); @@ -6694,11 +9413,10 @@ test_dataset_builtin_type_conversion(void) } } - if (H5Dwrite(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, mspace_id, fspace_id, + if (H5Dwrite(dset_id, DATASET_DATA_REAL_CONVERSION_TEST_INT_TYPE, mspace_id, fspace_id, H5P_DEFAULT, write_buf) < 0) { H5_FAILED(); - printf(" couldn't write to dataset '%s'\n", - DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't write to dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_point_sel_read); } @@ -6707,7 +9425,7 @@ test_dataset_builtin_type_conversion(void) { H5Sclose(mspace_id); } - H5E_END_TRY + H5E_END_TRY; mspace_id = H5I_INVALID_HID; } if (fspace_id >= 0) { @@ -6715,7 +9433,7 @@ test_dataset_builtin_type_conversion(void) { H5Sclose(fspace_id); } - H5E_END_TRY + H5E_END_TRY; fspace_id = H5I_INVALID_HID; } if (dset_id >= 0) { @@ -6723,14 +9441,14 @@ test_dataset_builtin_type_conversion(void) { H5Dclose(dset_id); } - H5E_END_TRY + H5E_END_TRY; dset_id = H5I_INVALID_HID; } - if ((dset_id = H5Dopen2(group_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) < + if ((dset_id = H5Dopen2(group_id, DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" couldn't open dataset '%s'\n", DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + printf(" couldn't open dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_point_sel_read); } @@ -6747,17 +9465,16 @@ test_dataset_builtin_type_conversion(void) } if (NULL == (read_buf = malloc((hsize_t)space_npoints * - DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPESIZE))) { + DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE))) { H5_FAILED(); printf(" couldn't allocate buffer for dataset read\n"); PART_ERROR(H5Dwrite_point_sel_read); } - if (H5Dread(dset_id, DATASET_DATA_BUILTIN_CONVERSION_TEST_MEM_DTYPE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, read_buf) < 0) { - H5_FAILED(); - printf(" couldn't read from dataset '%s'\n", - DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME); + if (H5Dread(dset_id, DATASET_DATA_REAL_CONVERSION_TEST_INT_TYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + read_buf) < 0) { + H5_FAILED(); + printf(" couldn't read from dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME); PART_ERROR(H5Dwrite_point_sel_read); } @@ -6803,7 +9520,7 @@ test_dataset_builtin_type_conversion(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6821,9 +9538,9 @@ test_dataset_builtin_type_conversion(void) H5Gclose(container_group); H5Fclose(file_id); } - H5E_END_TRY + H5E_END_TRY; - return 1; + return; } /* @@ -6835,7 +9552,7 @@ typedef struct dataset_compount_partial_io_t { int b; } dataset_compount_partial_io_t; -static int +static void test_dataset_compound_partial_io(void) { hsize_t dims[1] = {DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS}; @@ -6852,15 +9569,15 @@ test_dataset_compound_partial_io(void) dataset_compount_partial_io_t fbuf[DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS]; dataset_compount_partial_io_t erbuf[DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS]; - TESTING_MULTIPART( - "verification of dataset data using H5Dwrite then H5Dread with partial element compound type I/O"); + TESTING_MULTIPART("verification of dataset data using H5Dwrite then H5Dread with partial element " + "compound type I/O"); /* Make sure the connector supports the API functions being tested */ if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -6900,151 +9617,798 @@ test_dataset_compound_partial_io(void) if (H5Tinsert(a_type_id, "a", HOFFSET(dataset_compount_partial_io_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR; - if ((b_type_id = H5Tcreate(H5T_COMPOUND, sizeof(dataset_compount_partial_io_t))) < 0) - TEST_ERROR; - if (H5Tinsert(b_type_id, "b", HOFFSET(dataset_compount_partial_io_t, b), H5T_NATIVE_INT) < 0) - TEST_ERROR; + if ((b_type_id = H5Tcreate(H5T_COMPOUND, sizeof(dataset_compount_partial_io_t))) < 0) + TEST_ERROR; + if (H5Tinsert(b_type_id, "b", HOFFSET(dataset_compount_partial_io_t, b), H5T_NATIVE_INT) < 0) + TEST_ERROR; + + if ((dset_id = H5Dcreate2(group_id, DATASET_DATA_COMPOUND_PARTIAL_IO_TEST_DSET_NAME, full_type_id, + space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset '%s'\n", DATASET_DATA_COMPOUND_PARTIAL_IO_TEST_DSET_NAME); + goto error; + } + + PASSED(); + + BEGIN_MULTIPART + { + PART_BEGIN(write_full_read_full) + { + TESTING_2("H5Dwrite then H5Dread with all compound members"); + + /* Initialize wbuf */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + wbuf[i].a = (int)(2 * i); + wbuf[i].b = (int)(2 * i + 1); + } + + /* Write data */ + if (H5Dwrite(dset_id, full_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + PART_TEST_ERROR(write_full_read_full); + + /* Update fbuf to match file state */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + fbuf[i].a = wbuf[i].a; + fbuf[i].b = wbuf[i].b; + } + + /* Initialize rbuf to -1 */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + rbuf[i].a = -1; + rbuf[i].b = -1; + } + + /* Set erbuf (simply match file state since we're reading the whole + * thing) */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + erbuf[i].a = fbuf[i].a; + erbuf[i].b = fbuf[i].b; + } + + /* Read data */ + if (H5Dread(dset_id, full_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + PART_TEST_ERROR(write_full_read_full); + + /* Verify data */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + if (rbuf[i].a != erbuf[i].a) + PART_TEST_ERROR(write_full_read_full); + if (rbuf[i].b != erbuf[i].b) + PART_TEST_ERROR(write_full_read_full); + } + + PASSED(); + } + PART_END(write_full_read_full); + + PART_BEGIN(read_a) + { + TESTING_2("H5Dread with compound member a"); + + /* Initialize rbuf to -1 */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + rbuf[i].a = -1; + rbuf[i].b = -1; + } + + /* Set erbuf (element a comes from the file, element b in untouched) + */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + erbuf[i].a = fbuf[i].a; + erbuf[i].b = rbuf[i].b; + } + + /* Read data */ + if (H5Dread(dset_id, a_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + PART_TEST_ERROR(read_a); + + /* Verify data */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + if (rbuf[i].a != erbuf[i].a) + PART_TEST_ERROR(read_a); + if (rbuf[i].b != erbuf[i].b) + PART_TEST_ERROR(read_a); + } + + PASSED(); + } + PART_END(read_a); + + PART_BEGIN(write_b_read_full) + { + TESTING_2("H5Dwrite with compound member b then H5Dread with all compound members"); + + /* Initialize wbuf */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + wbuf[i].a = (int)(2 * DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS + 2 * i); + wbuf[i].b = (int)(2 * DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS + 2 * i + 1); + } + + /* Write data */ + if (H5Dwrite(dset_id, b_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + PART_TEST_ERROR(write_b_read_full); + + /* Update fbuf to match file state - only element b was updated */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + fbuf[i].b = wbuf[i].b; + } + + /* Initialize rbuf to -1 */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + rbuf[i].a = -1; + rbuf[i].b = -1; + } + + /* Set erbuf (simply match file state since we're reading the whole + * thing) */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + erbuf[i].a = fbuf[i].a; + erbuf[i].b = fbuf[i].b; + } + + /* Read data */ + if (H5Dread(dset_id, full_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + PART_TEST_ERROR(write_b_read_full); + + /* Verify data */ + for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { + if (rbuf[i].a != erbuf[i].a) + PART_TEST_ERROR(write_b_read_full); + if (rbuf[i].b != erbuf[i].b) + PART_TEST_ERROR(write_b_read_full); + } + + PASSED(); + } + PART_END(write_b_read_full); + } + END_MULTIPART; + + TESTING_2("test cleanup"); + + if (H5Sclose(space_id) < 0) + TEST_ERROR; + if (H5Dclose(dset_id) < 0) + TEST_ERROR; + if (H5Gclose(group_id) < 0) + TEST_ERROR; + if (H5Gclose(container_group) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (H5Tclose(full_type_id) < 0) + TEST_ERROR; + if (H5Tclose(a_type_id) < 0) + TEST_ERROR; + if (H5Tclose(b_type_id) < 0) + TEST_ERROR; + + PASSED(); + + return; + +error: + H5E_BEGIN_TRY + { + H5Sclose(space_id); + H5Dclose(dset_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + H5Tclose(full_type_id); + H5Tclose(a_type_id); + H5Tclose(b_type_id); + } + H5E_END_TRY + + return; +} + +/* A test to check that vlen sequences can be written and read back + * with basic parent types and selections */ +static void +test_dataset_vlen_io(void) +{ + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_int = H5I_INVALID_HID; + hid_t dset_float = H5I_INVALID_HID; + hid_t dset_string = H5I_INVALID_HID; + hid_t vlen_int = H5I_INVALID_HID; + hid_t vlen_float = H5I_INVALID_HID; + hid_t vlen_string = H5I_INVALID_HID; + hid_t str_base_type = H5I_INVALID_HID; + + hsize_t dims[1] = {DATASET_VLEN_IO_DSET_DIMS}; + hsize_t point_coords[DATASET_VLEN_IO_DSET_DIMS / 2]; + + hvl_t wbuf[DATASET_VLEN_IO_DSET_DIMS]; + hvl_t rbuf[DATASET_VLEN_IO_DSET_DIMS]; + + memset(wbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + memset(rbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + + TESTING_MULTIPART( + "verification of dataset data with H5Dwrite and then H5D read with variable length sequence data"); + + /* Make sure the connector supports the API functions being tested */ + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { + SKIPPED(); + printf(" API functions for basic file, group, or dataset aren't supported with this " + "connector\n"); + return; + } + + TESTING_2("test setup"); + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); + goto error; + } + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); + goto error; + } + + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) { + H5_FAILED(); + printf(" couldn't create dataspace"); + goto error; + } + + if ((vlen_int = H5Tvlen_create(H5T_NATIVE_INT)) < 0) { + H5_FAILED(); + printf(" couldn't create vlen integer sequence"); + goto error; + } + + if ((vlen_float = H5Tvlen_create(H5T_NATIVE_FLOAT)) < 0) { + H5_FAILED(); + printf(" couldn't create vlen float sequence"); + goto error; + } + + if ((str_base_type = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR; + + if ((H5Tset_size(str_base_type, DATASET_VLEN_IO_STR_LEN)) < 0) + TEST_ERROR; + + if ((vlen_string = H5Tvlen_create(str_base_type)) < 0) { + H5_FAILED(); + printf(" couldn't create vlen string sequence"); + goto error; + } + + if ((dset_int = H5Dcreate2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", vlen_int, space_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with vlen integer sequence datatype"); + goto error; + } + + if ((dset_float = H5Dcreate2(container_group, DATASET_VLEN_IO_DSET_NAME "_float", vlen_float, space_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with vlen float sequence datatype"); + goto error; + } + + if ((dset_string = H5Dcreate2(container_group, DATASET_VLEN_IO_DSET_NAME "_string", vlen_string, space_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create dataset with vlen string sequence datatype"); + goto error; + } + + /* Close datasets until individual tests */ + if (H5Dclose(dset_int) < 0) { + H5_FAILED(); + printf(" couldn't close dataset with vlen integer sequence datatype"); + } + + dset_int = H5I_INVALID_HID; - if ((dset_id = H5Dcreate2(group_id, DATASET_DATA_COMPOUND_PARTIAL_IO_TEST_DSET_NAME, full_type_id, - space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if (H5Dclose(dset_float) < 0) { H5_FAILED(); - printf(" couldn't create dataset '%s'\n", DATASET_DATA_COMPOUND_PARTIAL_IO_TEST_DSET_NAME); - goto error; + printf(" couldn't close dataset with vlen float sequence datatype"); } + dset_float = H5I_INVALID_HID; + + if (H5Dclose(dset_string) < 0) { + H5_FAILED(); + printf(" couldn't close dataset with vlen string sequence datatype"); + } + + dset_string = H5I_INVALID_HID; + PASSED(); BEGIN_MULTIPART { - PART_BEGIN(write_full_read_full) + PART_BEGIN(rw_all_int) { - TESTING_2("H5Dwrite then H5Dread with all compound members"); + TESTING_2("write and read entire dataspace with integer sequence"); + /* Set up write buffer */ + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if ((wbuf[i].p = calloc(i + 1, sizeof(int) * (i + 1))) == NULL) + PART_TEST_ERROR(rw_all_int); + + for (size_t j = 0; j < i + 1; j++) { + ((int *)wbuf[i].p)[j] = (int)(i * j + 1); + } - /* Initialize wbuf */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - wbuf[i].a = (int)(2 * i); - wbuf[i].b = (int)(2 * i + 1); + wbuf[i].len = i + 1; } - /* Write data */ - if (H5Dwrite(dset_id, full_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) - PART_TEST_ERROR(write_full_read_full); + /* Open dataset */ + if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_int); - /* Update fbuf to match file state */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - fbuf[i].a = wbuf[i].a; - fbuf[i].b = wbuf[i].b; - } + /* Perform write */ + if ((H5Dwrite(dset_int, vlen_int, space_id, H5S_ALL, H5P_DEFAULT, (const void *)wbuf)) < 0) + PART_TEST_ERROR(rw_all_int); - /* Initialize rbuf to -1 */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - rbuf[i].a = -1; - rbuf[i].b = -1; + if (H5Dflush(dset_int) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + /* Close and reopen file objects to flush cache */ + if (H5Dclose(dset_int) < 0) + PART_TEST_ERROR(rw_all_int); + + dset_int = H5I_INVALID_HID; + + if (H5Gclose(container_group) < 0) + PART_TEST_ERROR(rw_all_int); + + container_group = H5I_INVALID_HID; + + if (H5Fclose(file_id) < 0) + PART_TEST_ERROR(rw_all_int); + + file_id = H5I_INVALID_HID; + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_int); + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_int); + + if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_int); + + /* Perform read */ + if ((H5Dread(dset_int, vlen_int, space_id, H5S_ALL, H5P_DEFAULT, (void *)rbuf)) < 0) + PART_TEST_ERROR(rw_all_int); + + /* Close to finalize read */ + if (H5Dclose(dset_int) < 0) + PART_TEST_ERROR(rw_all_int); + dset_int = H5I_INVALID_HID; + + /* Verify data */ + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if (!rbuf[i].p) + PART_TEST_ERROR(rw_all_int); + + if (rbuf[i].len != wbuf[i].len) + PART_TEST_ERROR(rw_all_int); + + for (size_t j = 0; j < i + 1; j++) + if (((int *)rbuf[i].p)[j] != ((int *)wbuf[i].p)[j]) + PART_TEST_ERROR(rw_all_int); } - /* Set erbuf (simply match file state since we're reading the whole - * thing) */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - erbuf[i].a = fbuf[i].a; - erbuf[i].b = fbuf[i].b; + /* Reset buffers */ + if (H5Treclaim(vlen_int, space_id, H5P_DEFAULT, rbuf) < 0) + PART_TEST_ERROR(rw_all_int); + + if (H5Treclaim(vlen_int, space_id, H5P_DEFAULT, wbuf) < 0) + PART_TEST_ERROR(rw_all_int); + + memset(wbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + memset(rbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + + PASSED(); + } + PART_END(rw_all_int) + PART_BEGIN(rw_all_float) + { + TESTING_2("write and read entire dataspace with float sequence"); + /* Set up write buffer */ + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if ((wbuf[i].p = calloc(i + 1, sizeof(float) * (i + 1))) == NULL) + PART_TEST_ERROR(rw_all_float); + + for (size_t j = 0; j < i + 1; j++) { + ((float *)wbuf[i].p)[j] = (float)(i * j + 1); + } + + wbuf[i].len = i + 1; } - /* Read data */ - if (H5Dread(dset_id, full_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - PART_TEST_ERROR(write_full_read_full); + /* Open dataset */ + if ((dset_float = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_float", H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_float); + + /* Perform write */ + if ((H5Dwrite(dset_float, vlen_float, space_id, H5S_ALL, H5P_DEFAULT, (const void *)wbuf)) < 0) + PART_TEST_ERROR(rw_all_float); + + if (H5Dflush(dset_float) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + /* Close and reopen file objects to flush cache */ + if (H5Dclose(dset_float) < 0) + PART_TEST_ERROR(rw_all_float); + + dset_float = H5I_INVALID_HID; + + if (H5Gclose(container_group) < 0) + PART_TEST_ERROR(rw_all_float); + + container_group = H5I_INVALID_HID; + + if (H5Fclose(file_id) < 0) + PART_TEST_ERROR(rw_all_float); + + file_id = H5I_INVALID_HID; + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_float); + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_float); + + if ((dset_float = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_float", H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_float); + + /* Perform read */ + if ((H5Dread(dset_float, vlen_float, space_id, H5S_ALL, H5P_DEFAULT, (void *)rbuf)) < 0) + PART_TEST_ERROR(rw_all_float); + + /* Close to finalize read */ + if (H5Dclose(dset_float) < 0) + PART_TEST_ERROR(rw_all_float); + dset_float = H5I_INVALID_HID; /* Verify data */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - if (rbuf[i].a != erbuf[i].a) - PART_TEST_ERROR(write_full_read_full); - if (rbuf[i].b != erbuf[i].b) - PART_TEST_ERROR(write_full_read_full); + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if (!rbuf[i].p) + PART_TEST_ERROR(rw_all_float); + + if (rbuf[i].len != wbuf[i].len) + PART_TEST_ERROR(rw_all_float); + + for (size_t j = 0; j < i + 1; j++) { + float expected = ((float *)wbuf[i].p)[j]; + float actual = ((float *)rbuf[i].p)[j]; + + if (!(H5_DBL_REL_EQUAL(expected, actual, 0.001))) + PART_TEST_ERROR(rw_all_float); + } } + /* Reset buffers */ + if (H5Treclaim(vlen_float, space_id, H5P_DEFAULT, rbuf) < 0) + PART_TEST_ERROR(rw_all_float); + + if (H5Treclaim(vlen_float, space_id, H5P_DEFAULT, wbuf) < 0) + PART_TEST_ERROR(rw_all_float); + + memset(wbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + memset(rbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + PASSED(); } - PART_END(write_full_read_full); + PART_END(rw_all_float); - PART_BEGIN(read_a) + PART_BEGIN(rw_all_string) { - TESTING_2("H5Dread with compound member a"); + TESTING_2("write and read entire dataspace with string sequence"); + /* Set up write buffer */ + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if ((wbuf[i].p = calloc(i + 1, DATASET_VLEN_IO_STR_LEN)) == NULL) + PART_TEST_ERROR(rw_all_string); + + for (size_t j = 0; j < i + 1; j++) { + char *str_ptr = ((char *)wbuf[i].p) + DATASET_VLEN_IO_STR_LEN * j; + memcpy(str_ptr, DATASET_VLEN_IO_STR_VALUE, DATASET_VLEN_IO_STR_LEN); + } - /* Initialize rbuf to -1 */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - rbuf[i].a = -1; - rbuf[i].b = -1; + wbuf[i].len = i + 1; } - /* Set erbuf (element a comes from the file, element b in untouched) - */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - erbuf[i].a = fbuf[i].a; - erbuf[i].b = rbuf[i].b; - } + /* Open the dataset */ + if ((dset_string = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_string", H5P_DEFAULT)) < + 0) + PART_TEST_ERROR(rw_all_string); - /* Read data */ - if (H5Dread(dset_id, a_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - PART_TEST_ERROR(read_a); + /* Perform write */ + if ((H5Dwrite(dset_string, vlen_string, space_id, H5S_ALL, H5P_DEFAULT, (const void *)wbuf)) < 0) + PART_TEST_ERROR(rw_all_string); + + if (H5Dflush(dset_string) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + /* Close and reopen file objects to flush cache */ + if (H5Dclose(dset_string) < 0) + PART_TEST_ERROR(rw_all_string); + + dset_string = H5I_INVALID_HID; + + if (H5Gclose(container_group) < 0) + PART_TEST_ERROR(rw_all_string); + + container_group = H5I_INVALID_HID; + + if (H5Fclose(file_id) < 0) + PART_TEST_ERROR(rw_all_string); + + file_id = H5I_INVALID_HID; + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_string); + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_all_string); + + if ((dset_string = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_string", H5P_DEFAULT)) < + 0) + PART_TEST_ERROR(rw_all_string); + + /* Perform read */ + if ((H5Dread(dset_string, vlen_string, space_id, H5S_ALL, H5P_DEFAULT, (void *)rbuf)) < 0) + PART_TEST_ERROR(rw_all_string); + + /* Close to finalize read */ + if (H5Dclose(dset_string) < 0) + PART_TEST_ERROR(rw_all_string); + dset_string = H5I_INVALID_HID; /* Verify data */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - if (rbuf[i].a != erbuf[i].a) - PART_TEST_ERROR(read_a); - if (rbuf[i].b != erbuf[i].b) - PART_TEST_ERROR(read_a); + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if (!rbuf[i].p) + PART_TEST_ERROR(rw_all_string); + + if (rbuf[i].len != wbuf[i].len) + PART_TEST_ERROR(rw_all_string); + + for (size_t j = 0; j < i + 1; j++) { + char str_buf[DATASET_VLEN_IO_STR_LEN + 1]; + char *str_ptr = (char *)rbuf[i].p + DATASET_VLEN_IO_STR_LEN * j; + memcpy(str_buf, str_ptr, DATASET_VLEN_IO_STR_LEN); + str_buf[DATASET_VLEN_IO_STR_LEN] = '\0'; + + if (strcmp(str_buf, DATASET_VLEN_IO_STR_VALUE)) + PART_TEST_ERROR(rw_all_string); + } } + /* Reset buffers */ + if (H5Treclaim(vlen_string, space_id, H5P_DEFAULT, rbuf) < 0) + PART_TEST_ERROR(rw_all_string); + + if (H5Treclaim(vlen_string, space_id, H5P_DEFAULT, wbuf) < 0) + PART_TEST_ERROR(rw_all_string); + + memset(wbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + memset(rbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + PASSED(); } - PART_END(read_a); + PART_END(rw_all_string); - PART_BEGIN(write_b_read_full) + PART_BEGIN(rw_point_selection) { - TESTING_2("H5Dwrite with compound member b then H5Dread with all compound members"); + TESTING_2("write with point selection"); + /* Select even-indexed points */ + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS / 2; i++) + point_coords[i] = i * 2; + + /* Select points on dataspace */ + if (H5Sselect_elements(space_id, H5S_SELECT_SET, DATASET_VLEN_IO_DSET_DIMS / 2, + (const hsize_t *)point_coords) < 0) + PART_TEST_ERROR(rw_point_selection); + + /* Set up write buffer */ + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if ((wbuf[i].p = calloc(i + 1, sizeof(int) * (i + 1))) == NULL) + PART_TEST_ERROR(rw_point_selection); + + for (size_t j = 0; j < i + 1; j++) { + ((int *)wbuf[i].p)[j] = (int)(i * j + 1); + } - /* Initialize wbuf */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - wbuf[i].a = (int)(2 * DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS + 2 * i); - wbuf[i].b = (int)(2 * DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS + 2 * i + 1); + wbuf[i].len = i + 1; } - /* Write data */ - if (H5Dwrite(dset_id, b_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) - PART_TEST_ERROR(write_full_read_full); + /* Open dataset */ + if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_point_selection); - /* Update fbuf to match file state - only element b was updated */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - fbuf[i].b = wbuf[i].b; - } + /* Perform write */ + if ((H5Dwrite(dset_int, vlen_int, space_id, space_id, H5P_DEFAULT, (const void *)wbuf)) < 0) + PART_TEST_ERROR(rw_point_selection); - /* Initialize rbuf to -1 */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - rbuf[i].a = -1; - rbuf[i].b = -1; + if (H5Dflush(dset_int) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + /* Close and reopen file objects to flush cache */ + if (H5Dclose(dset_int) < 0) + PART_TEST_ERROR(rw_point_selection); + dset_int = H5I_INVALID_HID; + + if (H5Gclose(container_group) < 0) + PART_TEST_ERROR(rw_point_selection); + container_group = H5I_INVALID_HID; + + if (H5Fclose(file_id) < 0) + PART_TEST_ERROR(rw_point_selection); + file_id = H5I_INVALID_HID; + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_point_selection); + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_point_selection); + + if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_point_selection); + + /* Perform read */ + if ((H5Dread(dset_int, vlen_int, space_id, space_id, H5P_DEFAULT, (void *)rbuf)) < 0) + PART_TEST_ERROR(rw_point_selection); + + /* Close to finalize read */ + if (H5Dclose(dset_int) < 0) + PART_TEST_ERROR(rw_point_selection); + dset_int = H5I_INVALID_HID; + + /* Verify data */ + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if (i % 2 == 0) { + if (!rbuf[i].p) + PART_TEST_ERROR(rw_point_selection); + + if (rbuf[i].len != wbuf[i].len) + PART_TEST_ERROR(rw_point_selection); + + for (size_t j = 0; j < i + 1; j++) + if (((int *)rbuf[i].p)[j] != ((int *)wbuf[i].p)[j]) + PART_TEST_ERROR(rw_point_selection); + } + else { + /* Odd positions in buffer should still read 0 */ + if (rbuf[i].p) + PART_TEST_ERROR(rw_point_selection); + if (rbuf[i].len) + PART_TEST_ERROR(rw_point_selection); + } } - /* Set erbuf (simply match file state since we're reading the whole - * thing) */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - erbuf[i].a = fbuf[i].a; - erbuf[i].b = fbuf[i].b; + /* Reset buffers */ + if (H5Treclaim(vlen_int, space_id, H5P_DEFAULT, rbuf) < 0) + PART_TEST_ERROR(rw_point_selection); + + if (H5Treclaim(vlen_int, space_id, H5P_DEFAULT, wbuf) < 0) + PART_TEST_ERROR(rw_point_selection); + + memset(wbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + memset(rbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + + PASSED(); + } + PART_END(rw_point_selection); + + PART_BEGIN(rw_hyperslab_selection) + { + TESTING_2("write with hyperslab selection"); + /* Select hyperslab of every 3rd element */ + const hsize_t start[1] = {0}; + const hsize_t stride[1] = {3}; + const hsize_t count[1] = {1 + (DATASET_VLEN_IO_DSET_DIMS / stride[0])}; + const hsize_t block[1] = {1}; + + if ((H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, stride, count, block)) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + /* Set up write buffer */ + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if ((wbuf[i].p = calloc(i + 1, sizeof(int) * (i + 1))) == NULL) + PART_TEST_ERROR(rw_hyperslab_selection); + + for (size_t j = 0; j < i + 1; j++) { + ((int *)wbuf[i].p)[j] = (int)(i * j + 1); + } + + wbuf[i].len = i + 1; } - /* Read data */ - if (H5Dread(dset_id, full_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - PART_TEST_ERROR(write_b_read_full); + /* Open dataset */ + if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + /* Perform write */ + if ((H5Dwrite(dset_int, vlen_int, space_id, space_id, H5P_DEFAULT, (const void *)wbuf)) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + if (H5Dflush(dset_int) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + /* Close and reopen file objects to flush cache */ + if (H5Dclose(dset_int) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + dset_int = H5I_INVALID_HID; + + if (H5Gclose(container_group) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + container_group = H5I_INVALID_HID; + + if (H5Fclose(file_id) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + file_id = H5I_INVALID_HID; + + if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + /* Perform read */ + if ((H5Dread(dset_int, vlen_int, space_id, space_id, H5P_DEFAULT, (void *)rbuf)) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + /* Close to finalize read */ + if (H5Dclose(dset_int) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + dset_int = H5I_INVALID_HID; /* Verify data */ - for (i = 0; i < DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS; i++) { - if (rbuf[i].a != erbuf[i].a) - PART_TEST_ERROR(write_b_read_full); - if (rbuf[i].b != erbuf[i].b) - PART_TEST_ERROR(write_b_read_full); + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if (i % stride[0] == 0) { + if (!rbuf[i].p) + PART_TEST_ERROR(rw_hyperslab_selection); + + if (rbuf[i].len != wbuf[i].len) + PART_TEST_ERROR(rw_hyperslab_selection); + + for (size_t j = 0; j < i + 1; j++) + if (((int *)rbuf[i].p)[j] != ((int *)wbuf[i].p)[j]) + PART_TEST_ERROR(rw_hyperslab_selection); + } + else { + /* Unread positions should still be 0 */ + if (rbuf[i].p) + PART_TEST_ERROR(rw_hyperslab_selection); + if (rbuf[i].len) + PART_TEST_ERROR(rw_hyperslab_selection); + } } + /* Reset buffers */ + if (H5Treclaim(vlen_int, space_id, H5P_DEFAULT, rbuf) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + if (H5Treclaim(vlen_int, space_id, H5P_DEFAULT, wbuf) < 0) + PART_TEST_ERROR(rw_hyperslab_selection); + + memset(wbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + memset(rbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS); + PASSED(); } - PART_END(write_b_read_full); + PART_END(rw_hyperslab_selection); } END_MULTIPART; @@ -7052,40 +10416,52 @@ test_dataset_compound_partial_io(void) if (H5Sclose(space_id) < 0) TEST_ERROR; - if (H5Dclose(dset_id) < 0) + if (H5Tclose(vlen_int) < 0) TEST_ERROR; - if (H5Gclose(group_id) < 0) + if (H5Tclose(vlen_float) < 0) + TEST_ERROR; + if (H5Tclose(vlen_string) < 0) TEST_ERROR; if (H5Gclose(container_group) < 0) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; - if (H5Tclose(full_type_id) < 0) - TEST_ERROR; - if (H5Tclose(a_type_id) < 0) - TEST_ERROR; - if (H5Tclose(b_type_id) < 0) - TEST_ERROR; PASSED(); - return 0; + return; error: H5E_BEGIN_TRY { + H5Dclose(dset_int); + H5Dclose(dset_float); + H5Dclose(dset_string); H5Sclose(space_id); - H5Dclose(dset_id); - H5Gclose(group_id); + /* In case of memory allocation error, not all hvl_t buffers in array may be allocated. + * Free one-by-one */ + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if (wbuf[i].p) { + free(wbuf[i].p); + wbuf[i].p = NULL; + } + } + + for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) { + if (rbuf[i].p) { + free(rbuf[i].p); + rbuf[i].p = NULL; + } + } + H5Tclose(vlen_int); + H5Tclose(vlen_float); + H5Tclose(vlen_string); H5Gclose(container_group); H5Fclose(file_id); - H5Tclose(full_type_id); - H5Tclose(a_type_id); - H5Tclose(b_type_id); } H5E_END_TRY - return 1; + return; } /* @@ -7094,7 +10470,7 @@ test_dataset_compound_partial_io(void) * dimensions for the dataset, so the dimensionality of the * dataset may both shrink and grow. */ -static int +static void test_dataset_set_extent_chunked_unlimited(void) { hsize_t dims[DATASET_SET_EXTENT_CHUNKED_UNLIMITED_TEST_SPACE_RANK]; @@ -7113,11 +10489,12 @@ test_dataset_set_extent_chunked_unlimited(void) /* Make sure the connector supports the API functions being tested */ if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) || - !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) { SKIPPED(); printf(" API functions for basic file, group, basic or more dataset aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -7146,10 +10523,10 @@ test_dataset_set_extent_chunked_unlimited(void) } if ((fspace_id = generate_random_dataspace(DATASET_SET_EXTENT_CHUNKED_UNLIMITED_TEST_SPACE_RANK, max_dims, - dims, FALSE)) < 0) + dims, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -7302,7 +10679,7 @@ test_dataset_set_extent_chunked_unlimited(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -7317,7 +10694,7 @@ test_dataset_set_extent_chunked_unlimited(void) } H5E_END_TRY - return 1; + return; } /* @@ -7326,7 +10703,7 @@ test_dataset_set_extent_chunked_unlimited(void) * dimensions for the dataset, so the dimensionality of the * dataset may only shrink. */ -static int +static void test_dataset_set_extent_chunked_fixed(void) { hsize_t dims[DATASET_SET_EXTENT_CHUNKED_FIXED_TEST_SPACE_RANK]; @@ -7349,7 +10726,7 @@ test_dataset_set_extent_chunked_fixed(void) SKIPPED(); printf(" API functions for basic file, group, basic or more dataset aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -7385,7 +10762,7 @@ test_dataset_set_extent_chunked_fixed(void) if ((fspace_id2 = H5Screate_simple(DATASET_SET_EXTENT_CHUNKED_FIXED_TEST_SPACE_RANK, dims2, NULL)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -7417,14 +10794,14 @@ test_dataset_set_extent_chunked_fixed(void) } for (i = 0; i < DATASET_SET_EXTENT_CHUNKED_FIXED_TEST_NUM_PASSES; i++) { - hbool_t skip_iterations = FALSE; - size_t j; + bool skip_iterations = false; + size_t j; for (j = 0; j < DATASET_SET_EXTENT_CHUNKED_FIXED_TEST_SPACE_RANK; j++) { /* Ensure that the new dimensionality is less than the old dimensionality. */ do { if (dims[j] == 1) { - skip_iterations = TRUE; + skip_iterations = true; break; } else @@ -7486,14 +10863,14 @@ test_dataset_set_extent_chunked_fixed(void) * of the changes to the dataset's dimensionality. */ for (i = 0; i < DATASET_SET_EXTENT_CHUNKED_FIXED_TEST_NUM_PASSES; i++) { - hbool_t skip_iterations = FALSE; - size_t j; + bool skip_iterations = false; + size_t j; for (j = 0; j < DATASET_SET_EXTENT_CHUNKED_FIXED_TEST_SPACE_RANK; j++) { /* Ensure that the new dimensionality is less than the old dimensionality. */ do { if (dims2[j] == 1) { - skip_iterations = TRUE; + skip_iterations = true; break; } else @@ -7580,7 +10957,7 @@ test_dataset_set_extent_chunked_fixed(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -7597,14 +10974,14 @@ test_dataset_set_extent_chunked_fixed(void) } H5E_END_TRY - return 1; + return; } /* * A test to check the data is correct after expanding * and shrinking the dataset with H5Dset_extent */ -static int +static void test_dataset_set_extent_data(void) { hsize_t dims_origin[DATASET_SET_EXTENT_DATA_TEST_SPACE_RANK] = {DATASET_SET_EXTENT_DATA_TEST_SPACE_DIM, @@ -7638,7 +11015,7 @@ test_dataset_set_extent_data(void) SKIPPED(); printf(" API functions for basic file, group, basic or more dataset aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -7921,7 +11298,7 @@ test_dataset_set_extent_data(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -7936,7 +11313,7 @@ test_dataset_set_extent_data(void) } H5E_END_TRY - return 1; + return; } /* test_dataset_set_extent_data */ /* @@ -7944,7 +11321,7 @@ test_dataset_set_extent_data(void) * used to extend the dataset, then the other handle should * return the new size when queried. */ -static int +static void test_dataset_set_extent_double_handles(void) { hsize_t dims_origin[DATASET_SET_EXTENT_DOUBLE_HANDLES_TEST_SPACE_RANK] = { @@ -7972,7 +11349,7 @@ test_dataset_set_extent_double_handles(void) SKIPPED(); printf(" API functions for basic file, group, basic or more dataset aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -8062,7 +11439,7 @@ test_dataset_set_extent_double_handles(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -8078,14 +11455,14 @@ test_dataset_set_extent_double_handles(void) } H5E_END_TRY - return 1; + return; } /* test_dataset_set_extent_double_handles */ /* * A test to check that a dataset's extent can't be * changed when H5Dset_extent is passed invalid parameters. */ -static int +static void test_dataset_set_extent_invalid_params(void) { hsize_t dims[DATASET_SET_EXTENT_INVALID_PARAMS_TEST_SPACE_RANK]; @@ -8102,7 +11479,6 @@ test_dataset_set_extent_invalid_params(void) hid_t chunked_dcpl_id = H5I_INVALID_HID, compact_dcpl_id = H5I_INVALID_HID, contiguous_dcpl_id = H5I_INVALID_HID; hid_t fspace_id = H5I_INVALID_HID, compact_fspace_id = H5I_INVALID_HID; - char vol_name[5]; TESTING_MULTIPART("H5Dset_extent with invalid parameters"); @@ -8112,7 +11488,7 @@ test_dataset_set_extent_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, basic or more dataset aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -8123,19 +11499,6 @@ test_dataset_set_extent_invalid_params(void) goto error; } - /** for DAOS VOL, this test is problematic since auto chunking can be selected, so skip for now */ - if (H5VLget_connector_name(file_id, vol_name, 5) < 0) { - H5_FAILED(); - printf(" couldn't get VOL connector name\n"); - goto error; - } - if (strcmp(vol_name, "daos") == 0) { - if (H5Fclose(file_id) < 0) - TEST_ERROR; - SKIPPED(); - return 0; - } - if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't open container group '%s'\n", DATASET_TEST_GROUP_NAME); @@ -8151,7 +11514,7 @@ test_dataset_set_extent_invalid_params(void) } if ((fspace_id = generate_random_dataspace(DATASET_SET_EXTENT_INVALID_PARAMS_TEST_SPACE_RANK, NULL, dims, - FALSE)) < 0) + false)) < 0) TEST_ERROR; for (i = 0; i < DATASET_SET_EXTENT_INVALID_PARAMS_TEST_SPACE_RANK; i++) { @@ -8163,7 +11526,7 @@ test_dataset_set_extent_invalid_params(void) } while (chunk_dims[i] > dims[i]); } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; /* Create a compact dataset */ @@ -8335,7 +11698,7 @@ test_dataset_set_extent_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -8355,67 +11718,67 @@ test_dataset_set_extent_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* test_dataset_set_extent_invalid_params */ /* * A test for H5Dflush. */ -static int +static void test_flush_dataset(void) { TESTING("H5Dflush"); SKIPPED(); - return 0; + return; } /* * A test to check that H5Dflush fails when it is * passed invalid parameters. */ -static int +static void test_flush_dataset_invalid_params(void) { TESTING("H5Dflush with invalid parameters"); SKIPPED(); - return 0; + return; } /* * A test for H5Drefresh. */ -static int +static void test_refresh_dataset(void) { TESTING("H5Drefresh"); SKIPPED(); - return 0; + return; } /* * A test to check that H5Drefresh fails when it is * passed invalid parameters. */ -static int +static void test_refresh_dataset_invalid_params(void) { - TESTING("H5Drefresh"); + TESTING("H5Drefresh with invalid parameters"); SKIPPED(); - return 0; + return; } /* * A test to create a dataset composed of a single chunk. */ -static int +static void test_create_single_chunk_dataset(void) { hsize_t dims[DATASET_SINGLE_CHUNK_TEST_SPACE_RANK]; @@ -8436,7 +11799,7 @@ test_create_single_chunk_dataset(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -8458,9 +11821,9 @@ test_create_single_chunk_dataset(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATASET_SINGLE_CHUNK_TEST_SPACE_RANK, NULL, dims, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(DATASET_SINGLE_CHUNK_TEST_SPACE_RANK, NULL, dims, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -8571,7 +11934,7 @@ test_create_single_chunk_dataset(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -8586,14 +11949,14 @@ test_create_single_chunk_dataset(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a single-chunk dataset can be written * and read correctly. */ -static int +static void test_write_single_chunk_dataset(void) { hssize_t space_npoints; @@ -8617,7 +11980,7 @@ test_write_single_chunk_dataset(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -8640,7 +12003,7 @@ test_write_single_chunk_dataset(void) } if ((fspace_id = generate_random_dataspace(DATASET_SINGLE_CHUNK_WRITE_TEST_DSET_SPACE_RANK, NULL, dims, - FALSE)) < 0) + false)) < 0) TEST_ERROR; if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -8789,7 +12152,7 @@ test_write_single_chunk_dataset(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -8807,13 +12170,13 @@ test_write_single_chunk_dataset(void) } H5E_END_TRY - return 1; + return; } /* * A test to create a dataset composed of multiple chunks. */ -static int +static void test_create_multi_chunk_dataset(void) { hsize_t dims[DATASET_MULTI_CHUNK_TEST_SPACE_RANK] = {100, 100}; @@ -8835,7 +12198,7 @@ test_create_multi_chunk_dataset(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -8859,7 +12222,7 @@ test_create_multi_chunk_dataset(void) if ((fspace_id = H5Screate_simple(DATASET_MULTI_CHUNK_TEST_SPACE_RANK, dims, NULL)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -8970,7 +12333,7 @@ test_create_multi_chunk_dataset(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -8985,7 +12348,7 @@ test_create_multi_chunk_dataset(void) } H5E_END_TRY - return 1; + return; } /* @@ -8994,7 +12357,7 @@ test_create_multi_chunk_dataset(void) * chunks of the dataset, the file dataspace and memory dataspace * used are the same shape. */ -static int +static void test_write_multi_chunk_dataset_same_shape_read(void) { hsize_t dims[DATASET_MULTI_CHUNK_WRITE_SAME_SPACE_READ_TEST_DSET_SPACE_RANK] = {100, 100}; @@ -9021,7 +12384,7 @@ test_write_multi_chunk_dataset_same_shape_read(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -9234,6 +12597,8 @@ test_write_multi_chunk_dataset_same_shape_read(void) for (i = 0; i < data_size / chunk_size; i++) { size_t j, k; + printf("\r Reading chunk %zu", i); + for (j = 0; j < DATASET_MULTI_CHUNK_WRITE_SAME_SPACE_READ_TEST_DSET_SPACE_RANK; j++) { if (dims[j] == chunk_dims[j]) start[j] = 0; @@ -9293,7 +12658,7 @@ test_write_multi_chunk_dataset_same_shape_read(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -9310,7 +12675,7 @@ test_write_multi_chunk_dataset_same_shape_read(void) } H5E_END_TRY - return 1; + return; } /* @@ -9319,7 +12684,7 @@ test_write_multi_chunk_dataset_same_shape_read(void) * chunks of the dataset, the file dataspace and memory dataspace * used are differently shaped. */ -static int +static void test_write_multi_chunk_dataset_diff_shape_read(void) { hsize_t dims[DATASET_MULTI_CHUNK_WRITE_DIFF_SPACE_READ_TEST_DSET_SPACE_RANK] = {100, 100}; @@ -9345,7 +12710,7 @@ test_write_multi_chunk_dataset_diff_shape_read(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -9567,6 +12932,8 @@ test_write_multi_chunk_dataset_diff_shape_read(void) for (i = 0; i < data_size / chunk_size; i++) { size_t j; + printf("\r Reading chunk %zu", i); + for (j = 0; j < DATASET_MULTI_CHUNK_WRITE_DIFF_SPACE_READ_TEST_DSET_SPACE_RANK; j++) { if (dims[j] == chunk_dims[j]) start[j] = 0; @@ -9626,7 +12993,7 @@ test_write_multi_chunk_dataset_diff_shape_read(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -9645,7 +13012,7 @@ test_write_multi_chunk_dataset_diff_shape_read(void) } H5E_END_TRY - return 1; + return; } /* @@ -9654,7 +13021,7 @@ test_write_multi_chunk_dataset_diff_shape_read(void) * When reading back the chunks of the dataset, the file * dataspace and memory dataspace used are the same shape. */ -static int +static void test_overwrite_multi_chunk_dataset_same_shape_read(void) { hsize_t dims[DATASET_MULTI_CHUNK_OVERWRITE_SAME_SPACE_READ_TEST_DSET_SPACE_RANK] = {100, 100}; @@ -9681,7 +13048,7 @@ test_overwrite_multi_chunk_dataset_same_shape_read(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -9896,6 +13263,7 @@ test_overwrite_multi_chunk_dataset_same_shape_read(void) for (i = 0; i < data_size / chunk_size; i++) { size_t j, k; + printf("\r Reading chunk %zu", i); for (j = 0; j < DATASET_MULTI_CHUNK_OVERWRITE_SAME_SPACE_READ_TEST_DSET_SPACE_RANK; j++) { if (dims[j] == chunk_dims[j]) @@ -9962,7 +13330,7 @@ test_overwrite_multi_chunk_dataset_same_shape_read(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -9979,7 +13347,7 @@ test_overwrite_multi_chunk_dataset_same_shape_read(void) } H5E_END_TRY - return 1; + return; } /* @@ -9988,7 +13356,7 @@ test_overwrite_multi_chunk_dataset_same_shape_read(void) * When reading back the chunks of the dataset, the file * dataspace and memory dataspace used are differently shaped. */ -static int +static void test_overwrite_multi_chunk_dataset_diff_shape_read(void) { hsize_t dims[DATASET_MULTI_CHUNK_OVERWRITE_DIFF_SPACE_READ_TEST_DSET_SPACE_RANK] = {100, 100}; @@ -10015,7 +13383,7 @@ test_overwrite_multi_chunk_dataset_diff_shape_read(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -10239,6 +13607,8 @@ test_overwrite_multi_chunk_dataset_diff_shape_read(void) for (i = 0; i < data_size / chunk_size; i++) { size_t j; + printf("\r Reading chunk %zu", i); + for (j = 0; j < DATASET_MULTI_CHUNK_OVERWRITE_DIFF_SPACE_READ_TEST_DSET_SPACE_RANK; j++) { if (dims[j] == chunk_dims[j]) start[j] = 0; @@ -10305,7 +13675,7 @@ test_overwrite_multi_chunk_dataset_diff_shape_read(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10324,7 +13694,7 @@ test_overwrite_multi_chunk_dataset_diff_shape_read(void) } H5E_END_TRY - return 1; + return; } /* @@ -10334,7 +13704,7 @@ test_overwrite_multi_chunk_dataset_diff_shape_read(void) */ #define FIXED_DIMSIZE 25 #define FIXED_CHUNK_DIMSIZE 10 -static int +static void test_read_partial_chunk_all_selection(void) { DATASET_PARTIAL_CHUNK_READ_ALL_SEL_TEST_DSET_CTYPE write_buf[FIXED_DIMSIZE][FIXED_DIMSIZE]; @@ -10358,7 +13728,7 @@ test_read_partial_chunk_all_selection(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -10471,10 +13841,10 @@ test_read_partial_chunk_all_selection(void) for (j = 0; j < FIXED_DIMSIZE; j++) if (read_buf[i][j] != (int)((i * FIXED_DIMSIZE) + j)) { H5_FAILED(); - printf( - " data verification failed for read buffer element %lld: expected %lld but was %lld\n", - (long long)((i * FIXED_DIMSIZE) + j), (long long)((i * FIXED_DIMSIZE) + j), - (long long)read_buf[i][j]); + printf(" data verification failed for read buffer element %lld: expected %lld but was " + "%lld\n", + (long long)((i * FIXED_DIMSIZE) + j), (long long)((i * FIXED_DIMSIZE) + j), + (long long)read_buf[i][j]); goto error; } @@ -10493,7 +13863,7 @@ test_read_partial_chunk_all_selection(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10507,7 +13877,7 @@ test_read_partial_chunk_all_selection(void) } H5E_END_TRY - return 1; + return; } #undef FIXED_DIMSIZE #undef FIXED_CHUNK_DIMSIZE @@ -10520,7 +13890,7 @@ test_read_partial_chunk_all_selection(void) #define FIXED_DIMSIZE 25 #define FIXED_CHUNK_DIMSIZE 10 #define FIXED_NCHUNKS 9 /* For convenience - make sure to adjust this as necessary */ -static int +static void test_read_partial_chunk_hyperslab_selection(void) { DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_CTYPE write_buf[FIXED_CHUNK_DIMSIZE][FIXED_CHUNK_DIMSIZE]; @@ -10545,7 +13915,7 @@ test_read_partial_chunk_hyperslab_selection(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or get property list aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -10648,10 +14018,11 @@ test_read_partial_chunk_hyperslab_selection(void) /* * Write and read each chunk in the dataset. */ + printf("\n"); for (i = 0; i < FIXED_NCHUNKS; i++) { hsize_t start[DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_SPACE_RANK]; hsize_t count[DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_SPACE_RANK]; - hbool_t on_partial_edge_chunk = FALSE; + bool on_partial_edge_chunk = false; size_t n_chunks_per_dim = (dims[1] / chunk_dims[1]) + (((dims[1] % chunk_dims[1]) > 0) ? 1 : 0); on_partial_edge_chunk = @@ -10746,6 +14117,8 @@ test_read_partial_chunk_hyperslab_selection(void) goto error; } + printf("\r Reading chunk %zu", i); + if (H5Dread(dset_id, DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_DTYPE, mspace_id, fspace_id, H5P_DEFAULT, read_buf) < 0) { H5_FAILED(); @@ -10782,7 +14155,7 @@ test_read_partial_chunk_hyperslab_selection(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10797,7 +14170,7 @@ test_read_partial_chunk_hyperslab_selection(void) } H5E_END_TRY - return 1; + return; } #undef FIXED_DIMSIZE #undef FIXED_CHUNK_DIMSIZE @@ -10808,24 +14181,24 @@ test_read_partial_chunk_hyperslab_selection(void) * then read correctly when the selection used in a chunked * dataset's file dataspace is a point selection. */ -#define FIXED_DIMSIZE 25 -#define FIXED_CHUNK_DIMSIZE 10 -static int +/* #define FIXED_DIMSIZE 25 */ +/* #define FIXED_CHUNK_DIMSIZE 10 */ +static void test_read_partial_chunk_point_selection(void) { TESTING("reading a partial chunk using a point selection in file dataspace"); SKIPPED(); - return 1; + return; } -#undef FIXED_DIMSIZE -#undef FIXED_CHUNK_DIMSIZE +/* #undef FIXED_DIMSIZE */ +/* #undef FIXED_CHUNK_DIMSIZE */ /* * A test to verify that H5Dvlen_get_buf_size returns * correct size */ -static int +static void test_get_vlen_buf_size(void) { hvl_t wdata[DATASET_GET_VLEN_BUF_SIZE_DSET_SPACE_DIM]; /* Information to write */ @@ -10835,7 +14208,7 @@ test_get_vlen_buf_size(void) hid_t dataset = H5I_INVALID_HID; hid_t dspace_id = H5I_INVALID_HID; hid_t dtype_id = H5I_INVALID_HID; - hbool_t freed_wdata = FALSE; + bool freed_wdata = false; hsize_t dims1[] = {DATASET_GET_VLEN_BUF_SIZE_DSET_SPACE_DIM}; hsize_t size; /* Number of bytes which will be used */ unsigned i, j; @@ -10848,7 +14221,7 @@ test_get_vlen_buf_size(void) SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this " "connector\n"); - return 0; + return; } /* Allocate and initialize VL data to write */ @@ -10915,7 +14288,7 @@ test_get_vlen_buf_size(void) if (H5Treclaim(dtype_id, dspace_id, H5P_DEFAULT, wdata) < 0) TEST_ERROR; - freed_wdata = TRUE; + freed_wdata = true; if (H5Dclose(dataset) < 0) TEST_ERROR; @@ -10937,7 +14310,7 @@ test_get_vlen_buf_size(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10953,26 +14326,157 @@ test_get_vlen_buf_size(void) } H5E_END_TRY - return 1; + return; } /* end test_get_vlen_buf_size() */ -int -H5_api_dataset_test(void) +void +H5_api_dataset_test_add(void) { - size_t i; - int nerrors; - - printf("**********************************************\n"); - printf("* *\n"); - printf("* API Dataset Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); - - for (i = 0, nerrors = 0; i < ARRAY_LENGTH(dataset_tests); i++) { - nerrors += (*dataset_tests[i])() ? 1 : 0; - } - - printf("\n"); - - return nerrors; + /* Add a fake test to print out a header to distinguish different test interfaces */ + AddTest("print_dataset_test_header", print_dataset_test_header, NULL, "Prints header for dataset tests", NULL); + AddTest("test_create_dataset_under_root", MT_API_TEST_FUNC_OUTER(test_create_dataset_under_root), NULL, + "dataset creation under root group", NULL); + AddTest("test_create_dataset_under_existing_group", MT_API_TEST_FUNC_OUTER(test_create_dataset_under_existing_group), NULL, + "dataset creation under an existing group", NULL); + AddTest("test_create_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_dataset_invalid_params), NULL, + "H5Dcreate with invalid parameters", NULL); + AddTest("test_create_anonymous_dataset", MT_API_TEST_FUNC_OUTER(test_create_anonymous_dataset), NULL, + "anonymous dataset creation", NULL); + AddTest("test_create_anonymous_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_anonymous_dataset_invalid_params), + NULL, "anonymous dataset creation with invalid parameters", NULL); + AddTest("test_create_dataset_null_space", MT_API_TEST_FUNC_OUTER(test_create_dataset_null_space), NULL, + "dataset creation with a NULL dataspace", NULL); + AddTest("test_create_dataset_scalar_space", MT_API_TEST_FUNC_OUTER(test_create_dataset_scalar_space), NULL, + "dataset creation with a SCALAR dataspace", NULL); + AddTest("test_create_zero_dim_dset", MT_API_TEST_FUNC_OUTER(test_create_zero_dim_dset), NULL, "creation of 0-sized dataset", + NULL); + AddTest("test_create_dataset_random_shapes", MT_API_TEST_FUNC_OUTER(test_create_dataset_random_shapes), NULL, + "dataset creation with random dimension sizes", NULL); + AddTest("test_create_dataset_predefined_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_predefined_types), NULL, + "dataset creation with predefined datatypes", NULL); + AddTest("test_create_dataset_string_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_string_types), NULL, + "dataset creation with string types", NULL); + AddTest("test_create_dataset_compound_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_compound_types), NULL, + "dataset creation with compound datatypes", NULL); + AddTest("test_create_dataset_enum_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_enum_types), NULL, + "dataset creation with enum types", NULL); + AddTest("test_create_dataset_array_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_array_types), NULL, + "dataset creation with array types", NULL); + AddTest("test_create_dataset_creation_properties", MT_API_TEST_FUNC_OUTER(test_create_dataset_creation_properties), NULL, + "dataset creation properties", NULL); + AddTest("test_create_many_dataset", MT_API_TEST_FUNC_OUTER(test_create_many_dataset), NULL, "creating many datasets", NULL); + AddTest("test_open_dataset", MT_API_TEST_FUNC_OUTER(test_open_dataset), NULL, "H5Dopen", NULL); + AddTest("test_open_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_dataset_invalid_params), NULL, + "H5Dopen with invalid parameters", NULL); + AddTest("test_close_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_close_dataset_invalid_params), NULL, + "H5Dclose with an invalid dataset ID", NULL); + AddTest("test_get_dataset_space_and_type", MT_API_TEST_FUNC_OUTER(test_get_dataset_space_and_type), NULL, + "retrieval of a dataset's dataspace and datatype", NULL); + AddTest("test_get_dataset_space_and_type_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_dataset_space_and_type_invalid_params), + NULL, "H5Dget_type/H5Dget_space with invalid parameters", NULL); + AddTest("test_get_dataset_space_status", MT_API_TEST_FUNC_OUTER(test_get_dataset_space_status), NULL, "H5Dget_space_status", + NULL); + AddTest("test_get_dataset_space_status_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_dataset_space_status_invalid_params), + NULL, "H5Dget_space_status with invalid parameters", NULL); + AddTest("test_dataset_property_lists", MT_API_TEST_FUNC_OUTER(test_dataset_property_lists), NULL, + "dataset property list operations", NULL); + AddTest("test_get_dataset_storage_size", MT_API_TEST_FUNC_OUTER(test_get_dataset_storage_size), NULL, "H5Dget_storage_size", + NULL); + AddTest("test_get_dataset_storage_size_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_dataset_storage_size_invalid_params), + NULL, "H5Dget_storage_size with invalid parameters", NULL); + AddTest("test_get_dataset_chunk_storage_size", MT_API_TEST_FUNC_OUTER(test_get_dataset_chunk_storage_size), NULL, + "H5Dget_chunk_storage_size", NULL); + AddTest("test_get_dataset_chunk_storage_size_invalid_params", + test_get_dataset_chunk_storage_size_invalid_params, NULL, + "H5Dget_chunk_storage_size with invalid parameters", NULL); + AddTest("test_get_dataset_offset", MT_API_TEST_FUNC_OUTER(test_get_dataset_offset), NULL, "H5Dget_offset", NULL); + AddTest("test_get_dataset_offset_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_dataset_offset_invalid_params), NULL, + "H5Dget_offset with invalid parameters", NULL); + AddTest("test_read_dataset_small_all", MT_API_TEST_FUNC_OUTER(test_read_dataset_small_all), NULL, + "small read from dataset with H5S_ALL", NULL); + AddTest("test_read_dataset_small_hyperslab", MT_API_TEST_FUNC_OUTER(test_read_dataset_small_hyperslab), NULL, + "small read from dataset with a hyperslab selection", NULL); + AddTest("test_read_dataset_small_point_selection", MT_API_TEST_FUNC_OUTER(test_read_dataset_small_point_selection), NULL, + "small read from dataset with a point selection", NULL); + AddTest("test_read_multi_dataset_small_all", MT_API_TEST_FUNC_OUTER(test_read_multi_dataset_small_all), NULL, + "small multi read from datasets with H5S_ALL", NULL); + AddTest("test_read_multi_dataset_small_hyperslab", MT_API_TEST_FUNC_OUTER(test_read_multi_dataset_small_hyperslab), NULL, + "small multi read from datasets with a hyperslab selection", NULL); + AddTest("test_read_multi_dataset_small_point_selection", MT_API_TEST_FUNC_OUTER(test_read_multi_dataset_small_point_selection), + NULL, "small multi read from datasets with point selections", NULL); + AddTest("test_dataset_io_point_selections", MT_API_TEST_FUNC_OUTER(test_dataset_io_point_selections), NULL, + "point selection I/O with all selection in memory and points in file", NULL); + AddTest("test_read_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_read_dataset_invalid_params), NULL, + "H5Dread with invalid parameters", NULL); + AddTest("test_dataset_string_encodings", MT_API_TEST_FUNC_OUTER(test_dataset_string_encodings), NULL, + "string encoding read/write correctness on datasets", NULL); + AddTest("test_write_dataset_small_all", MT_API_TEST_FUNC_OUTER(test_write_dataset_small_all), NULL, + "small write to dataset with H5S_ALL", NULL); + AddTest("test_write_dataset_small_hyperslab", MT_API_TEST_FUNC_OUTER(test_write_dataset_small_hyperslab), NULL, + "small write to dataset with a hyperslab selection", NULL); + AddTest("test_write_dataset_small_point_selection", MT_API_TEST_FUNC_OUTER(test_write_dataset_small_point_selection), NULL, + "small write to dataset with a point selection", NULL); + AddTest("test_write_dataset_data_verification", MT_API_TEST_FUNC_OUTER(test_write_dataset_data_verification), NULL, + "verification of dataset data using H5Dwrite then H5Dread", NULL); + AddTest("test_write_multi_dataset_small_all", MT_API_TEST_FUNC_OUTER(test_write_multi_dataset_small_all), NULL, + "small multi write to datasets with H5S_ALL", NULL); + AddTest("test_write_multi_dataset_small_hyperslab", MT_API_TEST_FUNC_OUTER(test_write_multi_dataset_small_hyperslab), NULL, + "small multi write to datasets with hyperslab selections", NULL); + AddTest("test_write_multi_dataset_small_point_selection", MT_API_TEST_FUNC_OUTER(test_write_multi_dataset_small_point_selection), + NULL, "small multi write to datasets with point selections", NULL); + AddTest("test_write_multi_dataset_data_verification", MT_API_TEST_FUNC_OUTER(test_write_multi_dataset_data_verification), NULL, + "verification of datasets' data using H5Dwrite_multi then H5Dread_multi", NULL); + AddTest("test_write_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_write_dataset_invalid_params), NULL, + "H5Dwrite with invalid parameters", NULL); + AddTest("test_dataset_builtin_type_conversion", MT_API_TEST_FUNC_OUTER(test_dataset_builtin_type_conversion), NULL, + "verification of dataset data using H5Dwrite then H5Dread with type conversion of builtin types", + NULL); + AddTest("test_dataset_real_to_int_conversion", MT_API_TEST_FUNC_OUTER(test_dataset_real_to_int_conversion), NULL, + "verification of dataset data using H5Dwrite then H5Dread with real <-> integer type conversion", + NULL); + AddTest("test_dataset_compound_partial_io", MT_API_TEST_FUNC_OUTER(test_dataset_compound_partial_io), NULL, + "verification of dataset data using H5Dwrite then H5Dread with partial element compound type I/O", + NULL); + AddTest("test_dataset_vlen_io", MT_API_TEST_FUNC_OUTER(test_dataset_vlen_io), NULL, + "verification of dataset data with H5Dwrite and then H5D read with variable length sequence data", + NULL); + AddTest("test_dataset_set_extent_chunked_unlimited", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_chunked_unlimited), NULL, + "H5Dset_extent on chunked dataset with unlimited dimensions", NULL); + AddTest("test_dataset_set_extent_chunked_fixed", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_chunked_fixed), NULL, + "H5Dset_extent on chunked dataset with fixed dimensions", NULL); + AddTest("test_dataset_set_extent_data", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_data), NULL, + "H5Dset_extent on data correctness", NULL); + AddTest("test_dataset_set_extent_double_handles", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_double_handles), NULL, + "H5Dset_extent on double dataset handles", NULL); + AddTest("test_dataset_set_extent_invalid_params", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_invalid_params), NULL, + "H5Dset_extent with invalid parameters", NULL); + AddTest("test_flush_dataset", MT_API_TEST_FUNC_OUTER(test_flush_dataset), NULL, "H5Dflush", NULL); + AddTest("test_flush_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_flush_dataset_invalid_params), NULL, + "H5Dflush with invalid parameters", NULL); + AddTest("test_refresh_dataset", MT_API_TEST_FUNC_OUTER(test_refresh_dataset), NULL, "H5Drefresh", NULL); + AddTest("test_refresh_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_refresh_dataset_invalid_params), NULL, + "H5Drefresh with invalid parameters", NULL); + AddTest("test_create_single_chunk_dataset", MT_API_TEST_FUNC_OUTER(test_create_single_chunk_dataset), NULL, + "creation of dataset with single chunk", NULL); + AddTest("test_write_single_chunk_dataset", MT_API_TEST_FUNC_OUTER(test_write_single_chunk_dataset), NULL, + "write to dataset with single chunk", NULL); + AddTest("test_create_multi_chunk_dataset", MT_API_TEST_FUNC_OUTER(test_create_multi_chunk_dataset), NULL, + "creation of dataset with multiple chunks", NULL); + AddTest("test_write_multi_chunk_dataset_same_shape_read", MT_API_TEST_FUNC_OUTER(test_write_multi_chunk_dataset_same_shape_read), + NULL, "write to dataset with multiple chunks using same shaped dataspaces", NULL); + AddTest("test_write_multi_chunk_dataset_diff_shape_read", MT_API_TEST_FUNC_OUTER(test_write_multi_chunk_dataset_diff_shape_read), + NULL, "write to dataset with multiple chunks using differently shaped dataspaces", NULL); + AddTest("test_overwrite_multi_chunk_dataset_same_shape_read", + MT_API_TEST_FUNC_OUTER(test_overwrite_multi_chunk_dataset_same_shape_read), NULL, + "several overwrites to dataset with multiple chunks using same shaped dataspaces", NULL); + AddTest("test_overwrite_multi_chunk_dataset_diff_shape_read", + MT_API_TEST_FUNC_OUTER(test_overwrite_multi_chunk_dataset_diff_shape_read), NULL, + "several overwrites to dataset with multiple chunks using differently shaped dataspaces", NULL); + AddTest("test_read_partial_chunk_all_selection", MT_API_TEST_FUNC_OUTER(test_read_partial_chunk_all_selection), NULL, + "reading a partial chunk using H5S_ALL for file dataspace", NULL); + AddTest("test_read_partial_chunk_hyperslab_selection", MT_API_TEST_FUNC_OUTER(test_read_partial_chunk_hyperslab_selection), NULL, + "reading a partial chunk using a hyperslab selection in file dataspace", NULL); + AddTest("test_read_partial_chunk_point_selection", MT_API_TEST_FUNC_OUTER(test_read_partial_chunk_point_selection), NULL, + "reading a partial chunk using a point selection in file dataspace", NULL); + AddTest("test_get_vlen_buf_size", MT_API_TEST_FUNC_OUTER(test_get_vlen_buf_size), NULL, "H5Dvlen_get_buf_size", NULL); } diff --git a/test/API/H5_api_dataset_test.h b/test/API/H5_api_dataset_test.h index 5d18c4d7d58..63b1eb6b61f 100644 --- a/test/API/H5_api_dataset_test.h +++ b/test/API/H5_api_dataset_test.h @@ -15,7 +15,7 @@ #include "H5_api_test.h" -int H5_api_dataset_test(void); +void H5_api_dataset_test_add(void); /************************************************ * * @@ -42,6 +42,13 @@ int H5_api_dataset_test(void); #define DATASET_CREATE_ANONYMOUS_INVALID_PARAMS_GROUP_NAME "anon_dset_creation_invalid_params_test" #define DATASET_CREATE_ANONYMOUS_INVALID_PARAMS_SPACE_RANK 2 +#define DATASET_STRING_ENCODINGS_RANK 1 +#define DATASET_STRING_ENCODINGS_EXTENT 1 +#define DATASET_STRING_ENCODINGS_DSET_NAME1 "encoding_dset1" +#define DATASET_STRING_ENCODINGS_DSET_NAME2 "encoding_dset2" +#define DATASET_STRING_ENCODINGS_ASCII_STRING "asciistr" +#define DATASET_STRING_ENCODINGS_UTF8_STRING "αaααaaaα" + #define DATASET_CREATE_NULL_DATASPACE_TEST_SUBGROUP_NAME "dataset_with_null_space_test" #define DATASET_CREATE_NULL_DATASPACE_TEST_DSET_NAME "dataset_with_null_space" @@ -53,7 +60,7 @@ int H5_api_dataset_test(void); #define ZERO_DIM_DSET_TEST_DSET_NAME "zero_dim_dset" #define DATASET_MANY_CREATE_GROUP_NAME "group_for_many_datasets" -#define DSET_NAME_BUF_SIZE 64u +#define DSET_NAME_BUF_SIZE 64 #define DATASET_NUMB 100u #define DATASET_SHAPE_TEST_DSET_BASE_NAME "dataset_shape_test" @@ -106,6 +113,10 @@ int H5_api_dataset_test(void); #define DATASET_CREATION_PROPERTIES_TEST_MAX_COMPACT 12 #define DATASET_CREATION_PROPERTIES_TEST_MIN_DENSE 8 #define DATASET_CREATION_PROPERTIES_TEST_SHAPE_RANK 3 +#define DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_ID 32004 +#define DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NAME "lz4" +#define DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_DSET_NAME "ud_filter_test" +#define DATASET_CREATION_PROPERTIES_TEST_UD_FILTER_NUM_PARAMS 3 #define DATASET_OPEN_INVALID_PARAMS_SPACE_RANK 2 #define DATASET_OPEN_INVALID_PARAMS_GROUP_NAME "dataset_open_test" @@ -126,6 +137,24 @@ int H5_api_dataset_test(void); #define DATASET_PROPERTY_LIST_TEST_DSET_NAME3 "property_list_test_dataset3" #define DATASET_PROPERTY_LIST_TEST_DSET_NAME4 "property_list_test_dataset4" +#define DATASET_STORAGE_SIZE_TEST_ALL_DSET_SPACE_RANK 2 +#define DATASET_STORAGE_SIZE_TEST_ALL_DSET_EXTENT 10 +#define DATASET_STORAGE_SIZE_TEST_GROUP_NAME "dataset_get_storage_size_test" +#define DATASET_STORAGE_SIZE_TEST_DSET_CONTIGUOUS_NAME "dataset_contiguous" +#define DATASET_STORAGE_SIZE_TEST_DSET_CHUNKED_NAME "dataset_chunked" +#define DATASET_STORAGE_SIZE_TEST_DSET_FILTERED_NAME "dataset_filtered" +#define DATASET_STORAGE_SIZE_TEST_TYPE H5T_NATIVE_INT + +#define DATASET_FILL_VALUE_TEST_DSET_NAME1 "dataset_fill_value_test_dataset1" +#define DATASET_FILL_VALUE_TEST_DSET_NAME2 "dataset_fill_value_test_dataset2" +#define DATASET_FILL_VALUE_TEST_DSET_NAME3 "dataset_fill_value_test_dataset3" +#define DATASET_FILL_VALUE_TEST_INT_TYPE H5T_NATIVE_INT +#define DATASET_FILL_VALUE_TEST_INT_FILL_VALUE 1 +#define DATASET_FILL_VALUE_TEST_DOUBLE_TYPE H5T_NATIVE_DOUBLE +#define DATASET_FILL_VALUE_TEST_DOUBLE_FILL_VALUE 2.002 +#define DATASET_FILL_VALUE_TEST_STRING_FILL_VALUE "abcdefgh" +#define DATASET_FILL_VALUE_TEST_STRING_SIZE 8 /* No null terminator for fixed length string*/ + #define DATASET_SMALL_READ_TEST_ALL_DSET_SPACE_RANK 3 #define DATASET_SMALL_READ_TEST_ALL_DSET_DTYPESIZE sizeof(int) #define DATASET_SMALL_READ_TEST_ALL_DSET_DTYPE H5T_NATIVE_INT @@ -145,6 +174,12 @@ int H5_api_dataset_test(void); #define DATASET_SMALL_READ_TEST_POINT_SELECTION_GROUP_NAME "dataset_small_read_point_selection_test" #define DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_NAME "dataset_small_read_point_selection_dset" +#define DATASET_MULTI_COUNT 10 +#define DATASET_SMALL_READ_MULTI_TEST_ALL_GROUP_NAME "dataset_small_read_multi_all_test" +#define DATASET_SMALL_READ_MULTI_TEST_HYPERSLAB_GROUP_NAME "dataset_small_read_multi_hyperslab_test" +#define DATASET_SMALL_READ_MULTI_TEST_POINT_SELECTION_GROUP_NAME \ + "dataset_small_read_multi_point_selection_test" + #define DATASET_IO_POINT_GROUP_NAME "dataset_io_point_selection_test" #define DATASET_IO_POINT_DSET_NAME_NOCHUNK "dataset_io_point_selection_dset_nochunk" #define DATASET_IO_POINT_DSET_NAME_CHUNK "dataset_io_point_selection_dset_chunk" @@ -181,6 +216,20 @@ int H5_api_dataset_test(void); #define DATASET_DATA_VERIFY_WRITE_TEST_GROUP_NAME "dataset_data_write_verification_test" #define DATASET_DATA_VERIFY_WRITE_TEST_DSET_NAME "dataset_data_write_verification_dset" +#define DATASET_SMALL_WRITE_MULTI_TEST_ALL_GROUP_NAME "dataset_small_write_multi_all_test" +#define DATASET_SMALL_WRITE_MULTI_TEST_ALL_DSET_NAME "dataset_small_write_multi_all_dset" + +#define DATASET_SMALL_WRITE_MULTI_TEST_HYPERSLAB_GROUP_NAME "dataset_small_write_multi_hyperslab_test" +#define DATASET_SMALL_WRITE_MULTI_TEST_HYPERSLAB_DSET_NAME "dataset_small_write_multi_hyperslab_dset" + +#define DATASET_SMALL_WRITE_MULTI_TEST_POINT_SELECTION_GROUP_NAME \ + "dataset_small_write_multi_point_selection_test" +#define DATASET_SMALL_WRITE_MULTI_TEST_POINT_SELECTION_DSET_NAME \ + "dataset_small_write_multi_point_selection_dset" + +#define DATASET_DATA_VERIFY_WRITE_MULTI_TEST_GROUP_NAME "dataset_data_write_multi_verification_test" +#define DATASET_DATA_VERIFY_WRITE_MULTI_TEST_DSET_NAME "dataset_data_write_multi_verification_dset" + #define DATASET_WRITE_INVALID_PARAMS_TEST_DSET_SPACE_RANK 3 #define DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPESIZE sizeof(int) #define DATASET_WRITE_INVALID_PARAMS_TEST_DSET_DTYPE H5T_NATIVE_INT @@ -194,10 +243,24 @@ int H5_api_dataset_test(void); #define DATASET_DATA_BUILTIN_CONVERSION_TEST_GROUP_NAME "dataset_builtin_conversion_verification_test" #define DATASET_DATA_BUILTIN_CONVERSION_TEST_DSET_NAME "dataset_builtin_conversion_verification_dset" +#define DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK 3 +#define DATASET_DATA_REAL_CONVERSION_TEST_NUM_POINTS 10 +#define DATASET_DATA_REAL_CONVERSION_TEST_GROUP_NAME "dataset_real_conversion_verification_test" +#define DATASET_DATA_REAL_CONVERSION_TEST_DSET_NAME "dataset_real_conversion_verification_dset" +#define DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE sizeof(int) +#define DATASET_DATA_REAL_CONVERSION_TEST_INT_TYPE H5T_NATIVE_INT +#define DATASET_DATA_REAL_CONVERSION_TEST_REAL_DTYPESIZE sizeof(double) +#define DATASET_DATA_REAL_CONVERSION_TEST_REAL_TYPE H5T_NATIVE_DOUBLE + #define DATASET_COMPOUND_PARTIAL_IO_DSET_DIMS 10 #define DATASET_DATA_COMPOUND_PARTIAL_IO_TEST_GROUP_NAME "dataset_compound_partial_io_test" #define DATASET_DATA_COMPOUND_PARTIAL_IO_TEST_DSET_NAME "dataset_compound_partial_io_test" +#define DATASET_VLEN_IO_DSET_DIMS 100 +#define DATASET_VLEN_IO_DSET_NAME "vlen_dset" +#define DATASET_VLEN_IO_STR_LEN 8 +#define DATASET_VLEN_IO_STR_VALUE "abcdefgh" + #define DATASET_SET_EXTENT_CHUNKED_UNLIMITED_TEST_SPACE_RANK 2 #define DATASET_SET_EXTENT_CHUNKED_UNLIMITED_TEST_NUM_PASSES 3 #define DATASET_SET_EXTENT_CHUNKED_UNLIMITED_TEST_GROUP_NAME "set_extent_chunked_unlimited_test" diff --git a/test/API/H5_api_datatype_test.c b/test/API/H5_api_datatype_test.c index 7afcdbe28dd..147f03b58f9 100644 --- a/test/API/H5_api_datatype_test.c +++ b/test/API/H5_api_datatype_test.c @@ -17,67 +17,74 @@ */ #define PROBLEMATIC_TESTS -static int test_create_committed_datatype(void); -static int test_create_committed_datatype_invalid_params(void); -static int test_create_anonymous_committed_datatype(void); -static int test_create_anonymous_committed_datatype_invalid_params(void); +static void print_datatype_test_header(void); +static void test_create_committed_datatype(void); +static void test_create_committed_datatype_invalid_params(void); +static void test_create_anonymous_committed_datatype(void); +static void test_create_anonymous_committed_datatype_invalid_params(void); #ifndef PROBLEMATIC_TESTS -static int test_create_committed_datatype_empty_types(void); +static void test_create_committed_datatype_empty_types(void); #endif -static int test_recommit_committed_type(void); -static int test_open_committed_datatype(void); -static int test_open_committed_datatype_invalid_params(void); -static int test_reopen_committed_datatype_indirect(void); -static int test_close_committed_datatype_invalid_id(void); -static int test_datatype_property_lists(void); -static int test_create_dataset_with_committed_type(void); -static int test_create_attribute_with_committed_type(void); -static int test_delete_committed_type(void); -static int test_resurrect_datatype(void); -static int test_flush_committed_datatype(void); -static int test_flush_committed_datatype_invalid_params(void); -static int test_refresh_committed_datatype(void); -static int test_refresh_committed_datatype_invalid_params(void); +static void test_recommit_committed_type(void); +static void test_open_committed_datatype(void); +static void test_open_committed_datatype_invalid_params(void); +static void test_reopen_committed_datatype_indirect(void); +static void test_close_committed_datatype_invalid_id(void); +static void test_datatype_property_lists(void); +static void test_create_dataset_with_committed_type(void); +static void test_create_attribute_with_committed_type(void); +static void test_delete_committed_type(void); +static void test_resurrect_datatype(void); +static void test_flush_committed_datatype(void); +static void test_flush_committed_datatype_invalid_params(void); +static void test_refresh_committed_datatype(void); +static void test_refresh_committed_datatype_invalid_params(void); #ifndef PROBLEMATIC_TESTS -static int test_cant_commit_predefined(void); +static void test_cant_commit_predefined(void); #endif -static int test_cant_modify_committed_type(void); +static void test_cant_modify_committed_type(void); -/* - * The array of datatype tests to be performed. - */ -static int (*datatype_tests[])(void) = { - test_create_committed_datatype, - test_create_committed_datatype_invalid_params, - test_create_anonymous_committed_datatype, - test_create_anonymous_committed_datatype_invalid_params, +MULTI_DECLARE(test_create_committed_datatype) +MULTI_DECLARE(test_create_committed_datatype_invalid_params) +MULTI_DECLARE(test_create_anonymous_committed_datatype) +MULTI_DECLARE(test_create_anonymous_committed_datatype_invalid_params) #ifndef PROBLEMATIC_TESTS - test_create_committed_datatype_empty_types, +MULTI_DECLARE(test_create_committed_datatype_empty_types) #endif - test_recommit_committed_type, - test_open_committed_datatype, - test_open_committed_datatype_invalid_params, - test_reopen_committed_datatype_indirect, - test_close_committed_datatype_invalid_id, - test_datatype_property_lists, - test_create_dataset_with_committed_type, - test_create_attribute_with_committed_type, - test_delete_committed_type, - test_resurrect_datatype, - test_flush_committed_datatype, - test_flush_committed_datatype_invalid_params, - test_refresh_committed_datatype, - test_refresh_committed_datatype_invalid_params, +MULTI_DECLARE(test_recommit_committed_type) +MULTI_DECLARE(test_open_committed_datatype) +MULTI_DECLARE(test_open_committed_datatype_invalid_params) +MULTI_DECLARE(test_reopen_committed_datatype_indirect) +MULTI_DECLARE(test_close_committed_datatype_invalid_id) +MULTI_DECLARE(test_datatype_property_lists) +MULTI_DECLARE(test_create_dataset_with_committed_type) +MULTI_DECLARE(test_create_attribute_with_committed_type) +MULTI_DECLARE(test_delete_committed_type) +MULTI_DECLARE(test_resurrect_datatype) +MULTI_DECLARE(test_flush_committed_datatype) +MULTI_DECLARE(test_flush_committed_datatype_invalid_params) +MULTI_DECLARE(test_refresh_committed_datatype) +MULTI_DECLARE(test_refresh_committed_datatype_invalid_params) #ifndef PROBLEMATIC_TESTS - test_cant_commit_predefined, +MULTI_DECLARE(test_cant_commit_predefined) #endif - test_cant_modify_committed_type, -}; +MULTI_DECLARE(test_cant_modify_committed_type) + +static void +print_datatype_test_header(void) +{ + printf("\n"); + printf("**********************************************\n"); + printf("* *\n"); + printf("* API Datatype Tests *\n"); + printf("* *\n"); + printf("**********************************************\n\n"); +} /* * A test to check that a committed datatype can be created. */ -static int +static void test_create_committed_datatype(void) { hid_t file_id = H5I_INVALID_HID; @@ -92,7 +99,7 @@ test_create_committed_datatype(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -114,7 +121,7 @@ test_create_committed_datatype(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype to commit\n"); goto error; @@ -138,7 +145,7 @@ test_create_committed_datatype(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -150,14 +157,14 @@ test_create_committed_datatype(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a committed datatype can't be * created when H5Tcommit2 is passed invalid parameters. */ -static int +static void test_create_committed_datatype_invalid_params(void) { herr_t err_ret = -1; @@ -173,7 +180,7 @@ test_create_committed_datatype_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -198,7 +205,7 @@ test_create_committed_datatype_invalid_params(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype to commit\n"); goto error; @@ -360,7 +367,7 @@ test_create_committed_datatype_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -372,14 +379,14 @@ test_create_committed_datatype_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an anonymous committed datatype * can be created with H5Tcommit_anon. */ -static int +static void test_create_anonymous_committed_datatype(void) { hid_t file_id = H5I_INVALID_HID; @@ -394,7 +401,7 @@ test_create_anonymous_committed_datatype(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -416,7 +423,7 @@ test_create_anonymous_committed_datatype(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -439,7 +446,7 @@ test_create_anonymous_committed_datatype(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -451,14 +458,14 @@ test_create_anonymous_committed_datatype(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a committed datatype can't be * created when H5Tcommit_anon is passed invalid parameters. */ -static int +static void test_create_anonymous_committed_datatype_invalid_params(void) { herr_t err_ret = -1; @@ -474,7 +481,7 @@ test_create_anonymous_committed_datatype_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -499,7 +506,7 @@ test_create_anonymous_committed_datatype_invalid_params(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -604,7 +611,7 @@ test_create_anonymous_committed_datatype_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -616,7 +623,7 @@ test_create_anonymous_committed_datatype_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* @@ -624,7 +631,7 @@ test_create_anonymous_committed_datatype_invalid_params(void) * compound and enum datatypes. */ #ifndef PROBLEMATIC_TESTS -static int +static void test_create_committed_datatype_empty_types(void) { herr_t err_ret = FAIL; @@ -640,7 +647,7 @@ test_create_committed_datatype_empty_types(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -791,17 +798,17 @@ test_create_committed_datatype_empty_types(void) } H5E_END_TRY - return 1; + return; } #endif /* * A test to check that a committed datatype can't be re-committed. */ -static int +static void test_recommit_committed_type(void) { - htri_t is_committed = FALSE; + htri_t is_committed = false; herr_t err_ret; hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; @@ -815,7 +822,7 @@ test_recommit_committed_type(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -886,7 +893,7 @@ test_recommit_committed_type(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -898,14 +905,14 @@ test_recommit_committed_type(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a committed datatype * can be opened using H5Topen2. */ -static int +static void test_open_committed_datatype(void) { hid_t file_id = H5I_INVALID_HID; @@ -920,7 +927,7 @@ test_open_committed_datatype(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -942,7 +949,7 @@ test_open_committed_datatype(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype to commit\n"); goto error; @@ -975,7 +982,7 @@ test_open_committed_datatype(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -987,14 +994,14 @@ test_open_committed_datatype(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a committed datatype can't * be opened when H5Topen2 is passed invalid parameters. */ -static int +static void test_open_committed_datatype_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -1009,7 +1016,7 @@ test_open_committed_datatype_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1034,7 +1041,7 @@ test_open_committed_datatype_invalid_params(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype to commit\n"); goto error; @@ -1143,7 +1150,7 @@ test_open_committed_datatype_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1155,14 +1162,14 @@ test_open_committed_datatype_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that open named datatypes can be reopened indirectly * through H5Dget_type without causing problems. */ -static int +static void test_reopen_committed_datatype_indirect(void) { size_t dt_size = 0; @@ -1183,7 +1190,7 @@ test_reopen_committed_datatype_indirect(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or stored datatype aren't supported with " "this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1207,7 +1214,7 @@ test_reopen_committed_datatype_indirect(void) goto error; } - if ((space_id = generate_random_dataspace(DATATYPE_REOPEN_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((space_id = generate_random_dataspace(DATATYPE_REOPEN_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; PASSED(); @@ -1611,7 +1618,7 @@ test_reopen_committed_datatype_indirect(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1627,14 +1634,14 @@ test_reopen_committed_datatype_indirect(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Tclose fails when * it is passed an invalid datatype ID. */ -static int +static void test_close_committed_datatype_invalid_id(void) { herr_t err_ret = -1; @@ -1647,7 +1654,7 @@ test_close_committed_datatype_invalid_id(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_STORED_DATATYPES)) { SKIPPED(); printf(" API functions for basic file or stored datatype aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1673,7 +1680,7 @@ test_close_committed_datatype_invalid_id(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1682,7 +1689,7 @@ test_close_committed_datatype_invalid_id(void) } H5E_END_TRY - return 1; + return; } /* @@ -1690,7 +1697,7 @@ test_close_committed_datatype_invalid_id(void) * can be persisted and that a valid copy of that TCPL can * be retrieved later with a call to H5Tget_create_plist. */ -static int +static void test_datatype_property_lists(void) { hid_t file_id = H5I_INVALID_HID; @@ -1706,7 +1713,7 @@ test_datatype_property_lists(void) SKIPPED(); printf(" API functions for basic file, group, stored datatype, or getting property list aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1730,13 +1737,13 @@ test_datatype_property_lists(void) goto error; } - if ((type_id1 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id1 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; } - if ((type_id2 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id2 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -1883,7 +1890,7 @@ test_datatype_property_lists(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1898,14 +1905,14 @@ test_datatype_property_lists(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a dataset can be created using * a committed datatype. */ -static int +static void test_create_dataset_with_committed_type(void) { hid_t file_id = H5I_INVALID_HID; @@ -1923,7 +1930,7 @@ test_create_dataset_with_committed_type(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or stored datatype aren't supported with " "this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1945,7 +1952,7 @@ test_create_dataset_with_committed_type(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -1992,7 +1999,7 @@ test_create_dataset_with_committed_type(void) goto error; } - if ((fspace_id = generate_random_dataspace(DATATYPE_CREATE_TEST_DATASET_DIMS, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(DATATYPE_CREATE_TEST_DATASET_DIMS, NULL, NULL, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, DATASET_CREATE_WITH_DATATYPE_TEST_DSET_NAME, type_id, fspace_id, @@ -2027,7 +2034,7 @@ test_create_dataset_with_committed_type(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2041,14 +2048,14 @@ test_create_dataset_with_committed_type(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an attribute can be created * using a committed datatype. */ -static int +static void test_create_attribute_with_committed_type(void) { htri_t attr_exists; @@ -2067,7 +2074,7 @@ test_create_attribute_with_committed_type(void) SKIPPED(); printf(" API functions for basic file, group, attribute, or stored datatype aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2089,7 +2096,7 @@ test_create_attribute_with_committed_type(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, true)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -2112,7 +2119,7 @@ test_create_attribute_with_committed_type(void) } if ((space_id = - generate_random_dataspace(ATTRIBUTE_CREATE_WITH_DATATYPE_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + generate_random_dataspace(ATTRIBUTE_CREATE_WITH_DATATYPE_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, ATTRIBUTE_CREATE_WITH_DATATYPE_TEST_ATTR_NAME, type_id, space_id, @@ -2160,7 +2167,7 @@ test_create_attribute_with_committed_type(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2174,14 +2181,14 @@ test_create_attribute_with_committed_type(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a committed datatype can * be deleted. */ -static int +static void test_delete_committed_type(void) { htri_t type_exists; @@ -2198,7 +2205,7 @@ test_delete_committed_type(void) SKIPPED(); printf(" API functions for basic file, group, attribute, or stored datatype aren't supported " "with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2220,7 +2227,7 @@ test_delete_committed_type(void) goto error; } - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -2274,7 +2281,7 @@ test_delete_committed_type(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2286,14 +2293,14 @@ test_delete_committed_type(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a committed datatype can still be opened when * the link to the datatype is deleted and then a new one is created. */ -static int +static void test_resurrect_datatype(void) { hid_t file_id = H5I_INVALID_HID; @@ -2310,7 +2317,7 @@ test_resurrect_datatype(void) SKIPPED(); printf(" API functions for basic file, group, link, hard link, or stored datatype aren't " "supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2415,7 +2422,7 @@ test_resurrect_datatype(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2427,47 +2434,47 @@ test_resurrect_datatype(void) } H5E_END_TRY - return 1; + return; } -static int +static void test_flush_committed_datatype(void) { TESTING("H5Tflush"); SKIPPED(); - return 0; + return; } -static int +static void test_flush_committed_datatype_invalid_params(void) { TESTING("H5Tflush with invalid parameters"); SKIPPED(); - return 0; + return; } -static int +static void test_refresh_committed_datatype(void) { TESTING("H5Trefresh"); SKIPPED(); - return 0; + return; } -static int +static void test_refresh_committed_datatype_invalid_params(void) { TESTING("H5Trefresh with invalid parameters"); SKIPPED(); - return 0; + return; } /* @@ -2476,7 +2483,7 @@ test_refresh_committed_datatype_invalid_params(void) * copied datatype. */ #ifndef PROBLEMATIC_TESTS -static int +static void test_cant_commit_predefined(void) { herr_t err_ret; @@ -2492,7 +2499,7 @@ test_cant_commit_predefined(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2536,7 +2543,7 @@ test_cant_commit_predefined(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2547,17 +2554,17 @@ test_cant_commit_predefined(void) } H5E_END_TRY - return 1; + return; } #endif /* * A test to check that a datatype cannot be modified once it has been committed. */ -static int +static void test_cant_modify_committed_type(void) { - htri_t is_committed = FALSE; + htri_t is_committed = false; herr_t err_ret; hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID; @@ -2572,7 +2579,7 @@ test_cant_modify_committed_type(void) SKIPPED(); printf(" API functions for basic file, group, or stored datatype aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2643,7 +2650,7 @@ test_cant_modify_committed_type(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2655,26 +2662,62 @@ test_cant_modify_committed_type(void) } H5E_END_TRY - return 1; + return; } -int -H5_api_datatype_test(void) +void +H5_api_datatype_test_add(void) { - size_t i; - int nerrors; + /* Add a fake test to print out a header to distinguish different test interfaces */ + AddTest("print_datatype_test_header", print_datatype_test_header, NULL, + "Prints header for datatype tests", NULL); + + AddTest("test_create_committed_datatype", MT_API_TEST_FUNC_OUTER(test_create_committed_datatype), NULL, + "creation of a committed datatype", NULL); + AddTest("test_create_committed_datatype_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_committed_datatype_invalid_params), + NULL, "H5Tcommit2 with invalid parameters", NULL); + AddTest("test_create_anonymous_committed_datatype", MT_API_TEST_FUNC_OUTER(test_create_anonymous_committed_datatype), NULL, + "creation of anonymous committed datatype", NULL); + AddTest("test_create_anonymous_committed_datatype_invalid_params", + MT_API_TEST_FUNC_OUTER(test_create_anonymous_committed_datatype_invalid_params), NULL, + "H5Tcommit_anon with invalid parameters", NULL); - printf("**********************************************\n"); - printf("* *\n"); - printf("* API Datatype Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); +#ifndef PROBLEMATIC_TESTS + AddTest("test_create_committed_datatype_empty_types", MT_API_TEST_FUNC_OUTER(test_create_committed_datatype_empty_types), NULL, + "creation of committed datatype with empty types", NULL); +#endif - for (i = 0, nerrors = 0; i < ARRAY_LENGTH(datatype_tests); i++) { - nerrors += (*datatype_tests[i])() ? 1 : 0; - } + AddTest("test_recommit_committed_type", MT_API_TEST_FUNC_OUTER(test_recommit_committed_type), NULL, + "inability to re-commit a committed datatype", NULL); + AddTest("test_open_committed_datatype", MT_API_TEST_FUNC_OUTER(test_open_committed_datatype), NULL, "H5Topen2", NULL); + AddTest("test_open_committed_datatype_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_committed_datatype_invalid_params), NULL, + "H5Topen2 with invalid parameters", NULL); + AddTest("test_reopen_committed_datatype_indirect", MT_API_TEST_FUNC_OUTER(test_reopen_committed_datatype_indirect), NULL, + "reopening open committed datatypes using H5Dget_type", NULL); + AddTest("test_close_committed_datatype_invalid_id", MT_API_TEST_FUNC_OUTER(test_close_committed_datatype_invalid_id), NULL, + "H5Tclose with an invalid committed datatype ID", NULL); + AddTest("test_datatype_property_lists", MT_API_TEST_FUNC_OUTER(test_datatype_property_lists), NULL, + "datatype property list operations", NULL); + AddTest("test_create_dataset_with_committed_type", MT_API_TEST_FUNC_OUTER(test_create_dataset_with_committed_type), NULL, + "dataset creation with a committed datatype", NULL); + AddTest("test_create_attribute_with_committed_type", MT_API_TEST_FUNC_OUTER(test_create_attribute_with_committed_type), NULL, + "attribute creation with a committed datatype", NULL); + AddTest("test_delete_committed_type", MT_API_TEST_FUNC_OUTER(test_delete_committed_type), NULL, "committed datatype deletion", + NULL); + AddTest("test_resurrect_datatype", MT_API_TEST_FUNC_OUTER(test_resurrect_datatype), NULL, "resurrecting datatype after deletion", + NULL); + AddTest("test_flush_committed_datatype", MT_API_TEST_FUNC_OUTER(test_flush_committed_datatype), NULL, "H5Tflush", NULL); + AddTest("test_flush_committed_datatype_invalid_params", MT_API_TEST_FUNC_OUTER(test_flush_committed_datatype_invalid_params), + NULL, "H5Tflush with invalid parameters", NULL); + AddTest("test_refresh_committed_datatype", MT_API_TEST_FUNC_OUTER(test_refresh_committed_datatype), NULL, "H5Trefresh", NULL); + AddTest("test_refresh_committed_datatype_invalid_params", MT_API_TEST_FUNC_OUTER(test_refresh_committed_datatype_invalid_params), + NULL, "H5Trefresh with invalid parameters", NULL); - printf("\n"); +#ifndef PROBLEMATIC_TESTS + AddTest("test_cant_commit_predefined", MT_API_TEST_FUNC_OUTER(test_cant_commit_predefined), NULL, + "inability to commit predefined types directly", NULL); +#endif - return nerrors; + AddTest("test_cant_modify_committed_type", MT_API_TEST_FUNC_OUTER(test_cant_modify_committed_type), NULL, + "inability to modify a committed datatype", NULL); } diff --git a/test/API/H5_api_datatype_test.h b/test/API/H5_api_datatype_test.h index 2088ef1d174..ed195c95453 100644 --- a/test/API/H5_api_datatype_test.h +++ b/test/API/H5_api_datatype_test.h @@ -15,7 +15,7 @@ #include "H5_api_test.h" -int H5_api_datatype_test(void); +void H5_api_datatype_test_add(void); /************************************************* * * diff --git a/test/API/H5_api_file_test.c b/test/API/H5_api_file_test.c index 19ac3e076a2..8088099c85b 100644 --- a/test/API/H5_api_file_test.c +++ b/test/API/H5_api_file_test.c @@ -12,52 +12,59 @@ #include "H5_api_file_test.h" -static int test_create_file(void); -static int test_create_file_invalid_params(void); -static int test_create_file_excl(void); -static int test_open_file(void); -static int test_open_file_invalid_params(void); -static int test_open_nonexistent_file(void); -static int test_file_open_overlap(void); -static int test_file_permission(void); -static int test_reopen_file(void); -static int test_close_file_invalid_id(void); -static int test_flush_file(void); -static int test_file_is_accessible(void); -static int test_file_property_lists(void); -static int test_get_file_intent(void); -static int test_get_file_obj_count(void); -static int test_file_mounts(void); -static int test_get_file_name(void); -herr_t check_open_obj_count(ssize_t obj_count, int expected); +static void print_file_test_header(void); +static void test_create_file(void); +static void test_create_file_invalid_params(void); +static void test_create_file_excl(void); +static void test_open_file(void); +static void test_open_file_invalid_params(void); +static void test_open_nonexistent_file(void); +static void test_file_open_overlap(void); +static void test_file_permission(void); +static void test_reopen_file(void); +static void test_close_file_invalid_id(void); +static void test_flush_file(void); +static void test_file_is_accessible(void); +static void test_file_property_lists(void); +static void test_get_file_intent(void); +static void test_get_file_obj_count(void); +static void test_file_mounts(void); +static void test_get_file_name(void); +static herr_t check_open_obj_count(ssize_t obj_count, int expected); + +MULTI_DECLARE(test_create_file) +MULTI_DECLARE(test_create_file_invalid_params) +MULTI_DECLARE(test_create_file_excl) +MULTI_DECLARE(test_open_file) +MULTI_DECLARE(test_open_file_invalid_params) +MULTI_DECLARE(test_open_nonexistent_file) +MULTI_DECLARE(test_file_open_overlap) +MULTI_DECLARE(test_file_permission) +MULTI_DECLARE(test_reopen_file) +MULTI_DECLARE(test_close_file_invalid_id) +MULTI_DECLARE(test_flush_file) +MULTI_DECLARE(test_file_is_accessible) +MULTI_DECLARE(test_file_property_lists) +MULTI_DECLARE(test_get_file_intent) +MULTI_DECLARE(test_get_file_obj_count) +MULTI_DECLARE(test_file_mounts) +MULTI_DECLARE(test_get_file_name) -/* - * The array of file tests to be performed. - */ -static int (*file_tests[])(void) = { - test_create_file, - test_create_file_invalid_params, - test_create_file_excl, - test_open_file, - test_open_file_invalid_params, - test_open_nonexistent_file, - test_file_open_overlap, - test_file_permission, - test_reopen_file, - test_close_file_invalid_id, - test_flush_file, - test_file_is_accessible, - test_file_property_lists, - test_get_file_intent, - test_get_file_obj_count, - test_file_mounts, - test_get_file_name, -}; +static void +print_file_test_header(void) +{ + printf("\n"); + printf("**********************************************\n"); + printf("* *\n"); + printf("* API File Tests *\n"); + printf("* *\n"); + printf("**********************************************\n\n"); +} /* * Tests that a file can be created. */ -static int +static void test_create_file(void) { hid_t file_id = H5I_INVALID_HID; @@ -69,7 +76,7 @@ test_create_file(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC)) { SKIPPED(); printf(" API functions for basic file aren't supported with this connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, FILE_CREATE_TEST_FILENAME, &prefixed_filename) < 0) { @@ -86,31 +93,34 @@ test_create_file(void) if (H5Fclose(file_id) < 0) TEST_ERROR; + if (H5Fdelete(prefixed_filename, H5P_DEFAULT) < 0) + TEST_ERROR; free(prefixed_filename); prefixed_filename = NULL; PASSED(); - return 0; + return; error: H5E_BEGIN_TRY { H5Fclose(file_id); + H5Fdelete(prefixed_filename, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename); - return 1; + return; } /* * Tests that a file can't be created when H5Fcreate is passed * invalid parameters. */ -static int +static void test_create_file_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -122,7 +132,7 @@ test_create_file_invalid_params(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC)) { SKIPPED(); printf(" API functions for basic file aren't supported with this connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, FILE_CREATE_INVALID_PARAMS_FILE_NAME, &prefixed_filename) < 0) { @@ -240,7 +250,7 @@ test_create_file_invalid_params(void) free(prefixed_filename); prefixed_filename = NULL; - return 0; + return; error: H5E_BEGIN_TRY @@ -254,14 +264,14 @@ test_create_file_invalid_params(void) free(prefixed_filename); - return 1; + return; } /* * Tests that file creation will fail when a file is created * using the H5F_ACC_EXCL flag while the file already exists. */ -static int +static void test_create_file_excl(void) { hid_t file_id = H5I_INVALID_HID; @@ -274,7 +284,7 @@ test_create_file_excl(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC)) { SKIPPED(); printf(" API functions for basic file aren't supported with this connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, FILE_CREATE_EXCL_FILE_NAME, &prefixed_filename) < 0) { @@ -317,31 +327,34 @@ test_create_file_excl(void) if (H5Fclose(file_id) < 0) TEST_ERROR; + if (H5Fdelete(prefixed_filename, H5P_DEFAULT) < 0) + TEST_ERROR; free(prefixed_filename); prefixed_filename = NULL; PASSED(); - return 0; + return; error: H5E_BEGIN_TRY { H5Fclose(file_id); H5Fclose(file_id2); + H5Fdelete(prefixed_filename, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename); - return 1; + return; } /* * Tests that a file can be opened. */ -static int +static void test_open_file(void) { hid_t file_id = H5I_INVALID_HID; @@ -352,7 +365,7 @@ test_open_file(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC)) { SKIPPED(); printf(" API functions for basic file aren't supported with this connector\n"); - return 0; + return; } BEGIN_MULTIPART @@ -409,7 +422,7 @@ test_open_file(void) } END_MULTIPART; - return 0; + return; error: H5E_BEGIN_TRY @@ -418,14 +431,14 @@ test_open_file(void) } H5E_END_TRY - return 1; + return; } /* * Tests that a file can't be opened when H5Fopen is given * invalid parameters. */ -static int +static void test_open_file_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -436,7 +449,7 @@ test_open_file_invalid_params(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC)) { SKIPPED(); printf(" API functions for basic file aren't supported with this connector\n"); - return 0; + return; } BEGIN_MULTIPART @@ -511,7 +524,7 @@ test_open_file_invalid_params(void) } END_MULTIPART; - return 0; + return; error: H5E_BEGIN_TRY @@ -520,13 +533,13 @@ test_open_file_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to ensure that opening a file which doesn't exist will fail. */ -static int +static void test_open_nonexistent_file(void) { hid_t file_id = H5I_INVALID_HID; @@ -538,7 +551,7 @@ test_open_nonexistent_file(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC)) { SKIPPED(); printf(" API functions for basic file aren't supported with this connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, NONEXISTENT_FILENAME, &prefixed_filename) < 0) { @@ -547,7 +560,12 @@ test_open_nonexistent_file(void) goto error; } - /* XXX: Make sure to first delete the file so we know for sure it doesn't exist */ + /* Make sure to first delete the file so we know for sure it doesn't exist */ + H5E_BEGIN_TRY + { + H5Fdelete(prefixed_filename, H5P_DEFAULT); + } + H5E_END_TRY; H5E_BEGIN_TRY { @@ -566,7 +584,7 @@ test_open_nonexistent_file(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -577,14 +595,14 @@ test_open_nonexistent_file(void) free(prefixed_filename); - return 1; + return; } /* * Tests that a file can be opened read-only or read-write * and things are handled appropriately. */ -static int +static void test_file_permission(void) { hid_t file_id = H5I_INVALID_HID; @@ -605,7 +623,7 @@ test_file_permission(void) SKIPPED(); printf(" API functions for basic file, group, dataset, attribute, or stored datatype aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -791,13 +809,15 @@ test_file_permission(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (H5Fdelete(prefixed_filename, H5P_DEFAULT) < 0) + TEST_ERROR; free(prefixed_filename); prefixed_filename = NULL; PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -808,18 +828,19 @@ test_file_permission(void) H5Tclose(dtype_id); H5Gclose(group_id); H5Fclose(file_id); + H5Fdelete(prefixed_filename, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename); - return 1; + return; } /* * A test to check that a file can be re-opened with H5Freopen. */ -static int +static void test_reopen_file(void) { hid_t file_id = H5I_INVALID_HID; @@ -831,7 +852,7 @@ test_reopen_file(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC)) { SKIPPED(); printf(" API functions for basic file aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -853,7 +874,7 @@ test_reopen_file(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -863,13 +884,13 @@ test_reopen_file(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Fclose doesn't succeed for an * invalid file ID */ -static int +static void test_close_file_invalid_id(void) { herr_t err_ret = -1; @@ -880,7 +901,7 @@ test_close_file_invalid_id(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC)) { SKIPPED(); printf(" API functions for basic file aren't supported with this connector\n"); - return 0; + return; } H5E_BEGIN_TRY @@ -897,16 +918,16 @@ test_close_file_invalid_id(void) PASSED(); - return 0; + return; error: - return 1; + return; } /* * A test to check that a file can be flushed using H5Fflush. */ -static int +static void test_flush_file(void) { hid_t file_id = H5I_INVALID_HID; @@ -924,7 +945,7 @@ test_flush_file(void) SKIPPED(); printf(" API functions for basic file, dataset, or file flush aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -949,7 +970,7 @@ test_flush_file(void) } for (u = 0; u < 10; u++) { - HDsprintf(dset_name, "Dataset %u", u); + snprintf(dset_name, sizeof(dset_name), "Dataset %u", u); if ((dset_id = H5Dcreate2(file_id, dset_name, H5T_STD_U32LE, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -1002,13 +1023,15 @@ test_flush_file(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (H5Fdelete(prefixed_filename, H5P_DEFAULT) < 0) + TEST_ERROR; free(prefixed_filename); prefixed_filename = NULL; PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1016,18 +1039,19 @@ test_flush_file(void) H5Sclose(dspace_id); H5Dclose(dset_id); H5Fclose(file_id); + H5Fdelete(prefixed_filename, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename); - return 1; + return; } /* * A test for H5Fis_accessible. */ -static int +static void test_file_is_accessible(void) { const char *const fake_filename = "nonexistent_file.h5"; @@ -1040,7 +1064,7 @@ test_file_is_accessible(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC)) { SKIPPED(); printf(" API functions for basic file aren't supported with this connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, fake_filename, &prefixed_filename) < 0) { @@ -1100,12 +1124,12 @@ test_file_is_accessible(void) free(prefixed_filename); prefixed_filename = NULL; - return 0; + return; error: free(prefixed_filename); - return 1; + return; } /* @@ -1115,7 +1139,7 @@ test_file_is_accessible(void) * tests that a valid copy of a FAPL used for file access * can be retrieved with a call to H5Fget_access_plist. */ -static int +static void test_file_property_lists(void) { hsize_t prop_val = 0; @@ -1136,7 +1160,7 @@ test_file_property_lists(void) SKIPPED(); printf(" API functions for basic or more file or get property list aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1386,6 +1410,10 @@ test_file_property_lists(void) TEST_ERROR; if (H5Fclose(file_id2) < 0) TEST_ERROR; + if (H5Fdelete(prefixed_filename1, H5P_DEFAULT) < 0) + TEST_ERROR; + if (H5Fdelete(prefixed_filename2, H5P_DEFAULT) < 0) + TEST_ERROR; free(prefixed_filename1); prefixed_filename1 = NULL; @@ -1394,7 +1422,7 @@ test_file_property_lists(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1405,19 +1433,21 @@ test_file_property_lists(void) H5Pclose(fapl_id2); H5Fclose(file_id1); H5Fclose(file_id2); + H5Fdelete(prefixed_filename1, H5P_DEFAULT); + H5Fdelete(prefixed_filename2, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename1); free(prefixed_filename2); - return 1; + return; } /* * A test to check that the file intent flags can be retrieved. */ -static int +static void test_get_file_intent(void) { unsigned file_intent; @@ -1430,7 +1460,7 @@ test_get_file_intent(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_MORE)) { SKIPPED(); printf(" API functions for basic or more file aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1554,28 +1584,32 @@ test_get_file_intent(void) } END_MULTIPART; + if (H5Fdelete(prefixed_filename, H5P_DEFAULT) < 0) + TEST_ERROR; + free(prefixed_filename); prefixed_filename = NULL; - return 0; + return; error: H5E_BEGIN_TRY { H5Fclose(file_id); + H5Fdelete(prefixed_filename, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename); - return 1; + return; } /* * A test to check that the number of open objects and IDs of objects in a file * can be retrieved. */ -static int +static void test_get_file_obj_count(void) { ssize_t obj_count; @@ -1601,7 +1635,7 @@ test_get_file_obj_count(void) printf( " API functions for basic or more file, basic dataset, group, stored datatypes, or attribute " "aren't supported with this connector\n"); - return 0; + return; } if (active_thread_ct == 0) { @@ -1716,6 +1750,7 @@ test_get_file_obj_count(void) PART_ERROR(H5Fget_obj_count_grps_single_file); } + /* Only querying single file, no need to accomodate for possible multi-threading */ if (obj_count != 1) { H5_FAILED(); printf(" number of open groups (%ld) did not match expected number (1)\n", obj_count); @@ -1741,7 +1776,7 @@ test_get_file_obj_count(void) H5_FAILED(); printf(" number of open groups (%ld) did not match %s expected number (1)\n", obj_count, active_thread_ct > 1 ? "or exceed" : ""); - PART_ERROR(H5Fget_obj_count_grps); + PART_ERROR(H5Fget_obj_count_types); } PASSED(); @@ -1897,6 +1932,10 @@ test_get_file_obj_count(void) TEST_ERROR; if (H5Fclose(file_id2) < 0) TEST_ERROR; + if (H5Fdelete(prefixed_filename1, H5P_DEFAULT) < 0) + TEST_ERROR; + if (H5Fdelete(prefixed_filename2, H5P_DEFAULT) < 0) + TEST_ERROR; free(prefixed_filename1); prefixed_filename1 = NULL; @@ -1905,7 +1944,7 @@ test_get_file_obj_count(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1917,20 +1956,22 @@ test_get_file_obj_count(void) H5Dclose(dset_id); H5Fclose(file_id); H5Fclose(file_id2); + H5Fdelete(prefixed_filename1, H5P_DEFAULT); + H5Fdelete(prefixed_filename2, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename1); free(prefixed_filename2); - return 1; + return; } /* * A test to check that opening files in an overlapping way * works correctly. */ -static int +static void test_file_open_overlap(void) { ssize_t obj_count; @@ -1949,7 +1990,7 @@ test_file_open_overlap(void) SKIPPED(); printf(" API functions for basic or more file, dataset, or group aren't supported with this " "connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, OVERLAPPING_FILENAME, &prefixed_filename) < 0) { @@ -2040,13 +2081,15 @@ test_file_open_overlap(void) TEST_ERROR; if (H5Fclose(file_id2) < 0) TEST_ERROR; + if (H5Fdelete(prefixed_filename, H5P_DEFAULT) < 0) + TEST_ERROR; free(prefixed_filename); prefixed_filename = NULL; PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2056,19 +2099,20 @@ test_file_open_overlap(void) H5Dclose(dset_id); H5Fclose(file_id); H5Fclose(file_id2); + H5Fdelete(prefixed_filename, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename); - return 1; + return; } /* * A test to check that file mounting and unmounting works * correctly. */ -static int +static void test_file_mounts(void) { hid_t file_id = H5I_INVALID_HID; @@ -2084,7 +2128,7 @@ test_file_mounts(void) SKIPPED(); printf(" API functions for basic file, file mount, or basic group aren't supported with this " "connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, FILE_MOUNT_TEST_FILENAME, &prefixed_filename) < 0) { @@ -2131,13 +2175,15 @@ test_file_mounts(void) TEST_ERROR; if (H5Fclose(child_fid) < 0) TEST_ERROR; + if (H5Fdelete(prefixed_filename, H5P_DEFAULT) < 0) + TEST_ERROR; free(prefixed_filename); prefixed_filename = NULL; PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2145,18 +2191,19 @@ test_file_mounts(void) H5Gclose(group_id); H5Fclose(file_id); H5Fclose(child_fid); + H5Fdelete(prefixed_filename, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename); - return 1; + return; } /* * A test to ensure that a file's name can be retrieved. */ -static int +static void test_get_file_name(void) { ssize_t file_name_buf_len = 0; @@ -2180,7 +2227,7 @@ test_get_file_name(void) printf( " API functions for basic or more file, basic dataset, group, stored datatypes, or attribute " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -2222,7 +2269,7 @@ test_get_file_name(void) PART_ERROR(H5Fget_name_file_id); } - if (HDstrncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { + if (strncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { H5_FAILED(); printf(" file name '%s' didn't match expected name '%s'\n", file_name_buf, prefixed_filename); @@ -2253,7 +2300,7 @@ test_get_file_name(void) PART_ERROR(H5Fget_name_grp_id); } - if (HDstrncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { + if (strncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { H5_FAILED(); printf(" file name '%s' didn't match expected name '%s'\n", file_name_buf, prefixed_filename); @@ -2298,7 +2345,7 @@ test_get_file_name(void) PART_ERROR(H5Fget_name_dset_id); } - if (HDstrncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { + if (strncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { H5_FAILED(); printf(" file name '%s' didn't match expected name '%s'\n", file_name_buf, prefixed_filename); @@ -2351,7 +2398,7 @@ test_get_file_name(void) PART_ERROR(H5Fget_name_attr_id); } - if (HDstrncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { + if (strncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { H5_FAILED(); printf(" file name '%s' didn't match expected name '%s'\n", file_name_buf, prefixed_filename); @@ -2404,7 +2451,7 @@ test_get_file_name(void) PART_ERROR(H5Fget_name_dtype_id); } - if (HDstrncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { + if (strncmp(file_name_buf, prefixed_filename, (size_t)file_name_buf_len)) { H5_FAILED(); printf(" file name '%s' didn't match expected name '%s'\n", file_name_buf, prefixed_filename); @@ -2474,13 +2521,15 @@ test_get_file_name(void) if (H5Fclose(file_id) < 0) TEST_ERROR; + if (H5Fdelete(prefixed_filename, H5P_DEFAULT) < 0) + TEST_ERROR; free(prefixed_filename); prefixed_filename = NULL; PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2493,12 +2542,13 @@ test_get_file_name(void) H5Aclose(attr_id); H5Gclose(group_id); H5Fclose(file_id); + H5Fdelete(prefixed_filename, H5P_DEFAULT); } H5E_END_TRY free(prefixed_filename); - return 1; + return; } /* @@ -2524,51 +2574,36 @@ check_open_obj_count(ssize_t obj_count, int expected) { return ret_value; } -/* - * Cleanup temporary test files - */ -static void -cleanup_files(void) -{ - remove_test_file(test_path_prefix, FILE_CREATE_TEST_FILENAME); - remove_test_file(test_path_prefix, FILE_CREATE_EXCL_FILE_NAME); - - /* The below file should not get created */ - /* remove_test_file(test_path_prefix, FILE_CREATE_INVALID_PARAMS_FILE_NAME); */ - - remove_test_file(test_path_prefix, OVERLAPPING_FILENAME); - remove_test_file(test_path_prefix, FILE_PERMISSION_TEST_FILENAME); - remove_test_file(test_path_prefix, FILE_FLUSH_TEST_FILENAME); - remove_test_file(test_path_prefix, FILE_PROPERTY_LIST_TEST_FNAME1); - remove_test_file(test_path_prefix, FILE_PROPERTY_LIST_TEST_FNAME2); - remove_test_file(test_path_prefix, FILE_INTENT_TEST_FILENAME); - remove_test_file(test_path_prefix, GET_OBJ_COUNT_TEST_FILENAME1); - remove_test_file(test_path_prefix, GET_OBJ_COUNT_TEST_FILENAME2); - remove_test_file(test_path_prefix, FILE_MOUNT_TEST_FILENAME); - remove_test_file(test_path_prefix, GET_FILE_NAME_TEST_FNAME); -} - -int -H5_api_file_test(void) +void +H5_api_file_test_add(void) { - size_t i; - int nerrors; - - printf("**********************************************\n"); - printf("* *\n"); - printf("* API File Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); - - for (i = 0, nerrors = 0; i < ARRAY_LENGTH(file_tests); i++) { - nerrors += (*file_tests[i])() ? 1 : 0; - } - - printf("\n"); - - printf("Cleaning up testing files\n"); - cleanup_files(); - - return nerrors; + /* Add a fake test to print out a header to distinguish different test interfaces */ + AddTest("print_file_test_header", print_file_test_header, NULL, "Prints header for file tests", NULL); + + AddTest("test_create_file", MT_API_TEST_FUNC_OUTER(test_create_file), NULL, "H5Fcreate", NULL); + AddTest("test_create_file_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_file_invalid_params), NULL, + "H5Fcreate with invalid parameters", NULL); + AddTest("test_create_file_excl", MT_API_TEST_FUNC_OUTER(test_create_file_excl), NULL, + "H5Fcreate with H5F_ACC_EXCL/H5F_ACC_TRUNC flag", NULL); + AddTest("test_open_file", MT_API_TEST_FUNC_OUTER(test_open_file), NULL, "H5Fopen", NULL); + AddTest("test_open_file_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_file_invalid_params), NULL, + "H5Fopen with invalid parameters", NULL); + AddTest("test_open_nonexistent_file", MT_API_TEST_FUNC_OUTER(test_open_nonexistent_file), NULL, + "for invalid opening of a non-existent file", NULL); + AddTest("test_file_open_overlap", MT_API_TEST_FUNC_OUTER(test_file_open_overlap), NULL, "overlapping file opens", NULL); + AddTest("test_file_permission", MT_API_TEST_FUNC_OUTER(test_file_permission), NULL, + "file permissions (invalid creation of objects in read-only file)", NULL); + AddTest("test_reopen_file", MT_API_TEST_FUNC_OUTER(test_reopen_file), NULL, "re-open of a file with H5Freopen", NULL); + AddTest("test_close_file_invalid_id", MT_API_TEST_FUNC_OUTER(test_close_file_invalid_id), NULL, "H5Fclose with an invalid ID", + NULL); + AddTest("test_flush_file", MT_API_TEST_FUNC_OUTER(test_flush_file), NULL, "H5Fflush", NULL); + AddTest("test_file_is_accessible", MT_API_TEST_FUNC_OUTER(test_file_is_accessible), NULL, "H5Fis_accessible", NULL); + AddTest("test_file_property_lists", MT_API_TEST_FUNC_OUTER(test_file_property_lists), NULL, "file property list operations", + NULL); + AddTest("test_get_file_intent", MT_API_TEST_FUNC_OUTER(test_get_file_intent), NULL, "retrieval of file intent with H5Fget_intent", + NULL); + AddTest("test_get_file_obj_count", MT_API_TEST_FUNC_OUTER(test_get_file_obj_count), NULL, + "retrieval of open object number and IDs", NULL); + AddTest("test_file_mounts", MT_API_TEST_FUNC_OUTER(test_file_mounts), NULL, "file mounting/unmounting", NULL); + AddTest("test_get_file_name", MT_API_TEST_FUNC_OUTER(test_get_file_name), NULL, "retrieval of file name", NULL); } - diff --git a/test/API/H5_api_file_test.h b/test/API/H5_api_file_test.h index 368d037f46f..e46aecbb0e0 100644 --- a/test/API/H5_api_file_test.h +++ b/test/API/H5_api_file_test.h @@ -15,7 +15,7 @@ #include "H5_api_test.h" -int H5_api_file_test(void); +void H5_api_file_test_add(void); /********************************************* * * diff --git a/test/API/H5_api_group_test.c b/test/API/H5_api_group_test.c index ff07e879bf8..010e5a05376 100644 --- a/test/API/H5_api_group_test.c +++ b/test/API/H5_api_group_test.c @@ -12,54 +12,61 @@ #include "H5_api_group_test.h" -static int test_create_group_under_root(void); -static int test_create_group_under_existing_group(void); -static int test_create_many_groups(void); -static int test_create_deep_groups(void); -static int test_create_intermediate_group(void); -static int test_create_group_invalid_params(void); -static int test_create_anonymous_group(void); -static int test_create_anonymous_group_invalid_params(void); -static int test_open_nonexistent_group(void); -static int test_open_group_invalid_params(void); -static int test_close_group_invalid_id(void); -static int test_group_property_lists(void); -static int test_get_group_info(void); -static int test_get_group_info_invalid_params(void); -static int test_flush_group(void); -static int test_flush_group_invalid_params(void); -static int test_refresh_group(void); -static int test_refresh_group_invalid_params(void); -static int create_group_recursive(hid_t parent_gid, unsigned counter); - -/* - * The array of group tests to be performed. - */ -static int (*group_tests[])(void) = { - test_create_group_under_root, - test_create_group_under_existing_group, - test_create_many_groups, - test_create_deep_groups, - test_create_intermediate_group, - test_create_group_invalid_params, - test_create_anonymous_group, - test_create_anonymous_group_invalid_params, - test_open_nonexistent_group, - test_open_group_invalid_params, - test_close_group_invalid_id, - test_group_property_lists, - test_get_group_info, - test_get_group_info_invalid_params, - test_flush_group, - test_flush_group_invalid_params, - test_refresh_group, - test_refresh_group_invalid_params, -}; +static void print_group_test_header(void); +static void test_create_group_under_root(void); +static void test_create_group_under_existing_group(void); +static void test_create_many_groups(void); +static void test_create_deep_groups(void); +static void test_create_intermediate_group(void); +static void test_create_group_invalid_params(void); +static void test_create_anonymous_group(void); +static void test_create_anonymous_group_invalid_params(void); +static void test_open_nonexistent_group(void); +static void test_open_group_invalid_params(void); +static void test_close_group_invalid_id(void); +static void test_group_property_lists(void); +static void test_get_group_info(void); +static void test_get_group_info_invalid_params(void); +static void test_flush_group(void); +static void test_flush_group_invalid_params(void); +static void test_refresh_group(void); +static void test_refresh_group_invalid_params(void); +static int create_group_recursive(hid_t parent_gid, unsigned counter); + +MULTI_DECLARE(test_create_group_under_root) +MULTI_DECLARE(test_create_group_under_existing_group) +MULTI_DECLARE(test_create_many_groups) +MULTI_DECLARE(test_create_deep_groups) +MULTI_DECLARE(test_create_intermediate_group) +MULTI_DECLARE(test_create_group_invalid_params) +MULTI_DECLARE(test_create_anonymous_group) +MULTI_DECLARE(test_create_anonymous_group_invalid_params) +MULTI_DECLARE(test_open_nonexistent_group) +MULTI_DECLARE(test_open_group_invalid_params) +MULTI_DECLARE(test_close_group_invalid_id) +MULTI_DECLARE(test_group_property_lists) +MULTI_DECLARE(test_get_group_info) +MULTI_DECLARE(test_get_group_info_invalid_params) +MULTI_DECLARE(test_flush_group) +MULTI_DECLARE(test_flush_group_invalid_params) +MULTI_DECLARE(test_refresh_group) +MULTI_DECLARE(test_refresh_group_invalid_params) + +static void +print_group_test_header(void) +{ + printf("\n"); + printf("**********************************************\n"); + printf("* *\n"); + printf("* API Group Tests *\n"); + printf("* *\n"); + printf("**********************************************\n\n"); +} /* * A test to check that a group can be created under the root group. */ -static int +static void test_create_group_under_root(void) { hid_t file_id = H5I_INVALID_HID; @@ -71,7 +78,7 @@ test_create_group_under_root(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -95,7 +102,7 @@ test_create_group_under_root(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -105,14 +112,14 @@ test_create_group_under_root(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a group can be created under an existing * group which is not the root group. */ -static int +static void test_create_group_under_existing_group(void) { hid_t file_id = H5I_INVALID_HID; @@ -125,7 +132,7 @@ test_create_group_under_existing_group(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -170,7 +177,7 @@ test_create_group_under_existing_group(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -182,13 +189,13 @@ test_create_group_under_existing_group(void) } H5E_END_TRY - return 1; + return; } /* * A test to create many (one million) groups */ -static int +static void test_create_many_groups(void) { hid_t file_id = H5I_INVALID_HID; @@ -203,7 +210,7 @@ test_create_many_groups(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -229,7 +236,7 @@ test_create_many_groups(void) printf("\n"); for (i = 0; i < GROUP_NUMB_MANY; i++) { printf("\r %u/%u", i + 1, GROUP_NUMB_MANY); - sprintf(group_name, "group %02u", i); + snprintf(group_name, sizeof(group_name), "group %02u", i); if ((child_group_id = H5Gcreate2(parent_group_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -250,7 +257,7 @@ test_create_many_groups(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -262,13 +269,13 @@ test_create_many_groups(void) } H5E_END_TRY - return 1; + return; } /* * A test to create groups of the depth GROUP_DEPTH. */ -static int +static void test_create_deep_groups(void) { hid_t file_id = H5I_INVALID_HID; @@ -281,7 +288,7 @@ test_create_deep_groups(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -317,7 +324,7 @@ test_create_deep_groups(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -328,7 +335,7 @@ test_create_deep_groups(void) } H5E_END_TRY - return 1; + return; } /* @@ -342,11 +349,11 @@ create_group_recursive(hid_t parent_gid, unsigned counter) printf("\r %u/%u", counter, GROUP_DEPTH); if (counter == 1) - sprintf(gname, "2nd_child_group"); + snprintf(gname, sizeof(gname), "2nd_child_group"); else if (counter == 2) - sprintf(gname, "3rd_child_group"); + snprintf(gname, sizeof(gname), "3rd_child_group"); else - sprintf(gname, "%dth_child_group", counter + 1); + snprintf(gname, sizeof(gname), "%dth_child_group", counter + 1); if ((child_gid = H5Gcreate2(parent_gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't create group '%s'\n", gname); @@ -376,7 +383,7 @@ create_group_recursive(hid_t parent_gid, unsigned counter) /* * A test to create groups automatically using H5Pset_create_intermediate_group */ -static int +static void test_create_intermediate_group(void) { hid_t file_id = H5I_INVALID_HID; @@ -390,7 +397,7 @@ test_create_intermediate_group(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -408,7 +415,7 @@ test_create_intermediate_group(void) /* Set up plist for creating intermediate groups */ if ((crt_intmd_lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR; - if (H5Pset_create_intermediate_group(crt_intmd_lcpl_id, TRUE) < 0) + if (H5Pset_create_intermediate_group(crt_intmd_lcpl_id, true) < 0) TEST_ERROR; /* Create an intermediate group using a relative path */ @@ -506,7 +513,7 @@ test_create_intermediate_group(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -518,14 +525,14 @@ test_create_intermediate_group(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a group can't be created when H5Gcreate * is passed invalid parameters. */ -static int +static void test_create_group_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -537,7 +544,7 @@ test_create_group_invalid_params(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -683,7 +690,7 @@ test_create_group_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -693,14 +700,14 @@ test_create_group_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an anonymous group can be created with * H5Gcreate_anon. */ -static int +static void test_create_anonymous_group(void) { hid_t file_id = H5I_INVALID_HID; @@ -712,7 +719,7 @@ test_create_anonymous_group(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -742,7 +749,7 @@ test_create_anonymous_group(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -753,14 +760,14 @@ test_create_anonymous_group(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an anonymous group can't be created * when H5Gcreate_anon is passed invalid parameters. */ -static int +static void test_create_anonymous_group_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -772,7 +779,7 @@ test_create_anonymous_group_invalid_params(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -867,7 +874,7 @@ test_create_anonymous_group_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -878,14 +885,14 @@ test_create_anonymous_group_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a group which doesn't exist cannot * be opened. */ -static int +static void test_open_nonexistent_group(void) { hid_t file_id = H5I_INVALID_HID; @@ -897,7 +904,7 @@ test_open_nonexistent_group(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -923,7 +930,7 @@ test_open_nonexistent_group(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -933,14 +940,14 @@ test_open_nonexistent_group(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a group can't be opened when H5Gopen * is passed invalid parameters. */ -static int +static void test_open_group_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -952,7 +959,7 @@ test_open_group_invalid_params(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1052,7 +1059,7 @@ test_open_group_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1062,14 +1069,14 @@ test_open_group_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Gclose doesn't succeed for an * invalid group ID. */ -static int +static void test_close_group_invalid_id(void) { herr_t err_ret = -1; @@ -1080,7 +1087,7 @@ test_close_group_invalid_id(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC)) { SKIPPED(); printf(" API functions for basic group aren't supported with this connector\n"); - return 0; + return; } H5E_BEGIN_TRY @@ -1097,10 +1104,10 @@ test_close_group_invalid_id(void) PASSED(); - return 0; + return; error: - return 1; + return; } /* @@ -1108,7 +1115,7 @@ test_close_group_invalid_id(void) * be persisted and that a valid copy of that GCPL can be * retrieved later with a call to H5Gget_create_plist. */ -static int +static void test_group_property_lists(void) { unsigned dummy_prop_val = GROUP_PROPERTY_LIST_TEST_DUMMY_VAL; @@ -1125,7 +1132,7 @@ test_group_property_lists(void) SKIPPED(); printf(" API functions for basic file, group, property list, or creation order aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1358,7 +1365,7 @@ test_group_property_lists(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1372,13 +1379,13 @@ test_group_property_lists(void) } H5E_END_TRY - return 1; + return; } /* * A test for the functionality of H5Gget_info(_by_idx). */ -static int +static void test_get_group_info(void) { H5G_info_t group_info; @@ -1396,7 +1403,7 @@ test_get_group_info(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_MORE)) { SKIPPED(); printf(" API functions for basic file or group aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1437,8 +1444,7 @@ test_get_group_info(void) /* Create multiple groups under the parent group */ for (i = 0; i < GROUP_GET_INFO_TEST_GROUP_NUMB; i++) { /* Create the groups with a reverse-ordering naming scheme to test creation order */ - HDsnprintf(group_name, NAME_BUF_SIZE, "group %02u", - (unsigned)(GROUP_GET_INFO_TEST_GROUP_NUMB - i - 1)); + snprintf(group_name, NAME_BUF_SIZE, "group %02u", (unsigned)(GROUP_GET_INFO_TEST_GROUP_NUMB - i - 1)); if ((group_id = H5Gcreate2(parent_group_id, group_name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -1474,15 +1480,17 @@ test_get_group_info(void) PART_ERROR(H5Gget_info); } - /* - * For the purpose of this test, the max creation order should match - * the number of links in the group. - */ - if (group_info.max_corder != GROUP_GET_INFO_TEST_GROUP_NUMB) { - H5_FAILED(); - printf(" group's max creation order '%lld' doesn't match expected value '%lld'\n", - (long long)group_info.max_corder, (long long)GROUP_GET_INFO_TEST_GROUP_NUMB); - PART_ERROR(H5Gget_info); + if (vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) { + /* + * For the purpose of this test, the max creation order should match + * the number of links in the group. + */ + if (group_info.max_corder != GROUP_GET_INFO_TEST_GROUP_NUMB) { + H5_FAILED(); + printf(" group's max creation order '%lld' doesn't match expected value '%lld'\n", + (long long)group_info.max_corder, (long long)GROUP_GET_INFO_TEST_GROUP_NUMB); + PART_ERROR(H5Gget_info); + } } /* Ensure that the storage_type field is at least set to a meaningful value */ @@ -1495,10 +1503,10 @@ test_get_group_info(void) PART_ERROR(H5Gget_info); } - /* Assume that mounted should be FALSE in this case */ - if (group_info.mounted != FALSE) { + /* Assume that mounted should be false in this case */ + if (group_info.mounted != false) { H5_FAILED(); - printf(" group info's 'mounted' field was TRUE when it should have been FALSE\n"); + printf(" group info's 'mounted' field was true when it should have been false\n"); PART_ERROR(H5Gget_info); } @@ -1527,15 +1535,17 @@ test_get_group_info(void) PART_ERROR(H5Gget_info_by_name); } - /* - * For the purpose of this test, the max creation order should match - * the number of links in the group. - */ - if (group_info.max_corder != GROUP_GET_INFO_TEST_GROUP_NUMB) { - H5_FAILED(); - printf(" group's max creation order '%lld' doesn't match expected value '%lld'\n", - (long long)group_info.max_corder, (long long)GROUP_GET_INFO_TEST_GROUP_NUMB); - PART_ERROR(H5Gget_info_by_name); + if (vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) { + /* + * For the purpose of this test, the max creation order should match + * the number of links in the group. + */ + if (group_info.max_corder != GROUP_GET_INFO_TEST_GROUP_NUMB) { + H5_FAILED(); + printf(" group's max creation order '%lld' doesn't match expected value '%lld'\n", + (long long)group_info.max_corder, (long long)GROUP_GET_INFO_TEST_GROUP_NUMB); + PART_ERROR(H5Gget_info_by_name); + } } /* Ensure that the storage_type field is at least set to a meaningful value */ @@ -1548,10 +1558,10 @@ test_get_group_info(void) PART_ERROR(H5Gget_info_by_name); } - /* Assume that mounted should be FALSE in this case */ - if (group_info.mounted != FALSE) { + /* Assume that mounted should be false in this case */ + if (group_info.mounted != false) { H5_FAILED(); - printf(" group info's 'mounted' field was TRUE when it should have been FALSE\n"); + printf(" group info's 'mounted' field was true when it should have been false\n"); PART_ERROR(H5Gget_info_by_name); } @@ -1604,10 +1614,10 @@ test_get_group_info(void) PART_ERROR(H5Gget_info_by_idx_crt_order_increasing); } - /* Assume that mounted should be FALSE in this case */ - if (group_info.mounted != FALSE) { + /* Assume that mounted should be false in this case */ + if (group_info.mounted != false) { H5_FAILED(); - printf(" group info's 'mounted' field was TRUE when it should have been FALSE\n"); + printf(" group info's 'mounted' field was true when it should have been false\n"); PART_ERROR(H5Gget_info_by_idx_crt_order_increasing); } } @@ -1661,10 +1671,10 @@ test_get_group_info(void) PART_ERROR(H5Gget_info_by_idx_crt_order_decreasing); } - /* Assume that mounted should be FALSE in this case */ - if (group_info.mounted != FALSE) { + /* Assume that mounted should be false in this case */ + if (group_info.mounted != false) { H5_FAILED(); - printf(" group info's 'mounted' field was TRUE when it should have been FALSE\n"); + printf(" group info's 'mounted' field was true when it should have been false\n"); PART_ERROR(H5Gget_info_by_idx_crt_order_decreasing); } } @@ -1712,10 +1722,10 @@ test_get_group_info(void) PART_ERROR(H5Gget_info_by_idx_name_order_increasing); } - /* Assume that mounted should be FALSE in this case */ - if (group_info.mounted != FALSE) { + /* Assume that mounted should be false in this case */ + if (group_info.mounted != false) { H5_FAILED(); - printf(" group info's 'mounted' field was TRUE when it should have been FALSE\n"); + printf(" group info's 'mounted' field was true when it should have been false\n"); PART_ERROR(H5Gget_info_by_idx_name_order_increasing); } } @@ -1763,10 +1773,10 @@ test_get_group_info(void) PART_ERROR(H5Gget_info_by_idx_name_order_decreasing); } - /* Assume that mounted should be FALSE in this case */ - if (group_info.mounted != FALSE) { + /* Assume that mounted should be false in this case */ + if (group_info.mounted != false) { H5_FAILED(); - printf(" group info's 'mounted' field was TRUE when it should have been FALSE\n"); + printf(" group info's 'mounted' field was true when it should have been false\n"); PART_ERROR(H5Gget_info_by_idx_name_order_decreasing); } } @@ -1790,7 +1800,7 @@ test_get_group_info(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1803,14 +1813,14 @@ test_get_group_info(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a group's info can't be retrieved when * H5Gget_info(_by_name/_by_idx) is passed invalid parameters. */ -static int +static void test_get_group_info_invalid_params(void) { H5G_info_t group_info; @@ -1824,7 +1834,7 @@ test_get_group_info_invalid_params(void) SKIPPED(); printf(" API functions for basic file, or more group aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -2151,7 +2161,7 @@ test_get_group_info_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2160,13 +2170,13 @@ test_get_group_info_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Gflush. */ -static int +static void test_flush_group(void) { hid_t file_id = H5I_INVALID_HID; @@ -2181,7 +2191,7 @@ test_flush_group(void) SKIPPED(); printf(" API functions for basic file, group, or flush refresh aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2219,7 +2229,7 @@ test_flush_group(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2230,14 +2240,14 @@ test_flush_group(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Gflush fails when it * is passed invalid parameters. */ -static int +static void test_flush_group_invalid_params(void) { herr_t status; @@ -2248,7 +2258,7 @@ test_flush_group_invalid_params(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH)) { SKIPPED(); printf(" API functions for group flush aren't supported with this connector\n"); - return 0; + return; } H5E_BEGIN_TRY @@ -2265,16 +2275,16 @@ test_flush_group_invalid_params(void) PASSED(); - return 0; + return; error: - return 1; + return; } /* * A test for H5Grefresh. */ -static int +static void test_refresh_group(void) { hid_t file_id = H5I_INVALID_HID; @@ -2289,7 +2299,7 @@ test_refresh_group(void) SKIPPED(); printf(" API functions for basic file, group, or flush refresh aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2327,7 +2337,7 @@ test_refresh_group(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2338,14 +2348,14 @@ test_refresh_group(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Grefresh fails when it * is passed invalid parameters. */ -static int +static void test_refresh_group_invalid_params(void) { herr_t status; @@ -2356,7 +2366,7 @@ test_refresh_group_invalid_params(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FLUSH_REFRESH)) { SKIPPED(); printf(" API functions for group refresh aren't supported with this connector\n"); - return 0; + return; } H5E_BEGIN_TRY @@ -2373,29 +2383,48 @@ test_refresh_group_invalid_params(void) PASSED(); - return 0; + return; error: - return 1; + return; } -int -H5_api_group_test(void) +void +H5_api_group_test_add(void) { - size_t i; - int nerrors; - - printf("**********************************************\n"); - printf("* *\n"); - printf("* API Group Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); - - for (i = 0, nerrors = 0; i < ARRAY_LENGTH(group_tests); i++) { - nerrors += (*group_tests[i])() ? 1 : 0; - } - - printf("\n"); - - return nerrors; + /* Add a fake test to print out a header to distinguish different test interfaces */ + AddTest("print_group_test_header", print_group_test_header, NULL, "Prints header for group tests", NULL); + + AddTest("test_create_group_under_root", MT_API_TEST_FUNC_OUTER(test_create_group_under_root), NULL, + "creation of group under the root group", NULL); + AddTest("test_create_group_under_existing_group", MT_API_TEST_FUNC_OUTER(test_create_group_under_existing_group), NULL, + "creation of group under existing group using a relative path", NULL); + AddTest("test_create_many_groups", MT_API_TEST_FUNC_OUTER(test_create_many_groups), NULL, "H5Gcreate many groups", NULL); + AddTest("test_create_deep_groups", MT_API_TEST_FUNC_OUTER(test_create_deep_groups), NULL, "H5Gcreate groups of great depths", + NULL); + AddTest("test_create_intermediate_group", MT_API_TEST_FUNC_OUTER(test_create_intermediate_group), NULL, + "H5Gcreate group with intermediate group creation", NULL); + AddTest("test_create_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_group_invalid_params), NULL, + "H5Gcreate with invalid parameters", NULL); + AddTest("test_create_anonymous_group", MT_API_TEST_FUNC_OUTER(test_create_anonymous_group), NULL, "creation of anonymous group", + NULL); + AddTest("test_create_anonymous_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_anonymous_group_invalid_params), NULL, + "H5Gcreate_anon with invalid parameters", NULL); + AddTest("test_open_nonexistent_group", MT_API_TEST_FUNC_OUTER(test_open_nonexistent_group), NULL, + "for invalid opening of a nonexistent group", NULL); + AddTest("test_open_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_group_invalid_params), NULL, + "H5Gopen with invalid parameters", NULL); + AddTest("test_close_group_invalid_id", MT_API_TEST_FUNC_OUTER(test_close_group_invalid_id), NULL, + "H5Gclose with an invalid group ID", NULL); + AddTest("test_group_property_lists", MT_API_TEST_FUNC_OUTER(test_group_property_lists), NULL, "group property list operations", + NULL); + AddTest("test_get_group_info", MT_API_TEST_FUNC_OUTER(test_get_group_info), NULL, "retrieval of group info", NULL); + AddTest("test_get_group_info_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_group_info_invalid_params), NULL, + "retrieval of group info with invalid parameters", NULL); + AddTest("test_flush_group", MT_API_TEST_FUNC_OUTER(test_flush_group), NULL, "H5Gflush", NULL); + AddTest("test_flush_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_flush_group_invalid_params), NULL, + "H5Gflush with invalid parameters", NULL); + AddTest("test_refresh_group", MT_API_TEST_FUNC_OUTER(test_refresh_group), NULL, "H5Grefresh", NULL); + AddTest("test_refresh_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_refresh_group_invalid_params), NULL, + "H5Grefresh with invalid parameters", NULL); } diff --git a/test/API/H5_api_group_test.h b/test/API/H5_api_group_test.h index b1cbc68455e..e5d0f546a61 100644 --- a/test/API/H5_api_group_test.h +++ b/test/API/H5_api_group_test.h @@ -15,7 +15,7 @@ #include "H5_api_test.h" -int H5_api_group_test(void); +void H5_api_group_test_add(void); /********************************************** * * diff --git a/test/API/H5_api_link_test.c b/test/API/H5_api_link_test.c index 647e33a66a2..7f0ae37f867 100644 --- a/test/API/H5_api_link_test.c +++ b/test/API/H5_api_link_test.c @@ -16,62 +16,120 @@ * TODO: add link tests for short-circuit success in operator callback */ -static int test_create_hard_link(void); -static int test_create_hard_link_long_name(void); -static int test_create_hard_link_many(void); -static int test_create_hard_link_same_loc(void); -static int test_create_hard_link_invalid_params(void); -static int test_create_soft_link_existing_relative(void); -static int test_create_soft_link_existing_absolute(void); -static int test_create_soft_link_dangling_relative(void); -static int test_create_soft_link_dangling_absolute(void); -static int test_create_soft_link_long_name(void); -static int test_create_soft_link_many(void); -static int test_create_soft_link_invalid_params(void); -static int test_create_external_link(void); -static int test_create_external_link_dangling(void); -static int test_create_external_link_multi(void); -static int test_create_external_link_ping_pong(void); -static int test_create_external_link_invalid_params(void); -static int test_create_user_defined_link(void); -static int test_create_user_defined_link_invalid_params(void); -static int test_delete_link(void); -static int test_delete_link_reset_grp_max_crt_order(void); -static int test_delete_link_invalid_params(void); -static int test_copy_link(void); -static int test_copy_links_into_group_with_links(void); -static int test_copy_link_across_files(void); -static int test_copy_link_invalid_params(void); -static int test_move_link(void); -static int test_move_links_into_group_with_links(void); -static int test_move_link_across_files(void); -static int test_move_link_reset_grp_max_crt_order(void); -static int test_move_link_invalid_params(void); -static int test_get_link_val(void); -static int test_get_link_val_invalid_params(void); -static int test_get_link_info(void); -static int test_get_link_info_invalid_params(void); -static int test_get_link_name(void); -static int test_get_link_name_invalid_params(void); -static int test_link_iterate_hard_links(void); -static int test_link_iterate_soft_links(void); -static int test_link_iterate_external_links(void); -static int test_link_iterate_ud_links(void); -static int test_link_iterate_mixed_links(void); -static int test_link_iterate_invalid_params(void); -static int test_link_iterate_0_links(void); -static int test_link_visit_hard_links_no_cycles(void); -static int test_link_visit_soft_links_no_cycles(void); -static int test_link_visit_external_links_no_cycles(void); -static int test_link_visit_ud_links_no_cycles(void); -static int test_link_visit_mixed_links_no_cycles(void); -static int test_link_visit_hard_links_cycles(void); -static int test_link_visit_soft_links_cycles(void); -static int test_link_visit_external_links_cycles(void); -static int test_link_visit_ud_links_cycles(void); -static int test_link_visit_mixed_links_cycles(void); -static int test_link_visit_invalid_params(void); -static int test_link_visit_0_links(void); +static void print_link_test_header(void); +static void test_create_hard_link(void); +static void test_create_hard_link_long_name(void); +static void test_create_hard_link_many(void); +static void test_create_hard_link_same_loc(void); +static void test_create_hard_link_invalid_params(void); +static void test_create_soft_link_existing_relative(void); +static void test_create_soft_link_existing_absolute(void); +static void test_create_soft_link_dangling_relative(void); +static void test_create_soft_link_dangling_absolute(void); +static void test_create_soft_link_long_name(void); +static void test_create_soft_link_many(void); +static void test_create_soft_link_invalid_params(void); +static void test_create_external_link(void); +static void test_create_external_link_dangling(void); +static void test_create_external_link_multi(void); +static void test_create_external_link_ping_pong(void); +static void test_create_external_link_invalid_params(void); +static void test_create_user_defined_link(void); +static void test_create_user_defined_link_invalid_params(void); +static void test_delete_link(void); +static void test_delete_link_reset_grp_max_crt_order(void); +static void test_delete_link_invalid_params(void); +static void test_copy_link(void); +static void test_copy_links_into_group_with_links(void); +static void test_copy_link_across_files(void); +static void test_copy_link_invalid_params(void); +static void test_move_link(void); +static void test_move_links_into_group_with_links(void); +static void test_move_link_across_files(void); +static void test_move_link_reset_grp_max_crt_order(void); +static void test_move_link_invalid_params(void); +static void test_get_link_val(void); +static void test_get_link_val_invalid_params(void); +static void test_get_link_info(void); +static void test_get_link_info_invalid_params(void); +static void test_get_link_name(void); +static void test_get_link_name_invalid_params(void); +static void test_link_iterate_hard_links(void); +static void test_link_iterate_soft_links(void); +static void test_link_iterate_external_links(void); +static void test_link_iterate_ud_links(void); +static void test_link_iterate_mixed_links(void); +static void test_link_iterate_invalid_params(void); +static void test_link_iterate_0_links(void); +static void test_link_visit_hard_links_no_cycles(void); +static void test_link_visit_soft_links_no_cycles(void); +static void test_link_visit_external_links_no_cycles(void); +static void test_link_visit_ud_links_no_cycles(void); +static void test_link_visit_mixed_links_no_cycles(void); +static void test_link_visit_hard_links_cycles(void); +static void test_link_visit_soft_links_cycles(void); +static void test_link_visit_external_links_cycles(void); +static void test_link_visit_ud_links_cycles(void); +static void test_link_visit_mixed_links_cycles(void); +static void test_link_visit_invalid_params(void); +static void test_link_visit_0_links(void); + +MULTI_DECLARE(test_create_hard_link) +MULTI_DECLARE(test_create_hard_link_long_name) +MULTI_DECLARE(test_create_hard_link_many) +MULTI_DECLARE(test_create_hard_link_same_loc) +MULTI_DECLARE(test_create_hard_link_invalid_params) +MULTI_DECLARE(test_create_soft_link_existing_relative) +MULTI_DECLARE(test_create_soft_link_existing_absolute) +MULTI_DECLARE(test_create_soft_link_dangling_relative) +MULTI_DECLARE(test_create_soft_link_dangling_absolute) +MULTI_DECLARE(test_create_soft_link_long_name) +MULTI_DECLARE(test_create_soft_link_many) +MULTI_DECLARE(test_create_soft_link_invalid_params) +MULTI_DECLARE(test_create_external_link) +MULTI_DECLARE(test_create_external_link_dangling) +MULTI_DECLARE(test_create_external_link_multi) +MULTI_DECLARE(test_create_external_link_ping_pong) +MULTI_DECLARE(test_create_external_link_invalid_params) +MULTI_DECLARE(test_create_user_defined_link) +MULTI_DECLARE(test_create_user_defined_link_invalid_params) +MULTI_DECLARE(test_delete_link) +MULTI_DECLARE(test_delete_link_reset_grp_max_crt_order) +MULTI_DECLARE(test_delete_link_invalid_params) +MULTI_DECLARE(test_copy_link) +MULTI_DECLARE(test_copy_links_into_group_with_links) +MULTI_DECLARE(test_copy_link_across_files) +MULTI_DECLARE(test_copy_link_invalid_params) +MULTI_DECLARE(test_move_link) +MULTI_DECLARE(test_move_links_into_group_with_links) +MULTI_DECLARE(test_move_link_across_files) +MULTI_DECLARE(test_move_link_reset_grp_max_crt_order) +MULTI_DECLARE(test_move_link_invalid_params) +MULTI_DECLARE(test_get_link_val) +MULTI_DECLARE(test_get_link_val_invalid_params) +MULTI_DECLARE(test_get_link_info) +MULTI_DECLARE(test_get_link_info_invalid_params) +MULTI_DECLARE(test_get_link_name) +MULTI_DECLARE(test_get_link_name_invalid_params) +MULTI_DECLARE(test_link_iterate_hard_links) +MULTI_DECLARE(test_link_iterate_soft_links) +MULTI_DECLARE(test_link_iterate_external_links) +MULTI_DECLARE(test_link_iterate_ud_links) +MULTI_DECLARE(test_link_iterate_mixed_links) +MULTI_DECLARE(test_link_iterate_invalid_params) +MULTI_DECLARE(test_link_iterate_0_links) +MULTI_DECLARE(test_link_visit_hard_links_no_cycles) +MULTI_DECLARE(test_link_visit_soft_links_no_cycles) +MULTI_DECLARE(test_link_visit_external_links_no_cycles) +MULTI_DECLARE(test_link_visit_ud_links_no_cycles) +MULTI_DECLARE(test_link_visit_mixed_links_no_cycles) +MULTI_DECLARE(test_link_visit_hard_links_cycles) +MULTI_DECLARE(test_link_visit_soft_links_cycles) +MULTI_DECLARE(test_link_visit_external_links_cycles) +MULTI_DECLARE(test_link_visit_ud_links_cycles) +MULTI_DECLARE(test_link_visit_mixed_links_cycles) +MULTI_DECLARE(test_link_visit_invalid_params) +MULTI_DECLARE(test_link_visit_0_links) static herr_t link_iter_hard_links_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void *op_data); @@ -106,73 +164,22 @@ static herr_t link_visit_invalid_params_cb(hid_t group_id, const char *name, con void *op_data); static herr_t link_visit_0_links_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void *op_data); -/* - * The array of link tests to be performed. - */ -static int (*link_tests[])(void) = { - test_create_hard_link, - test_create_hard_link_long_name, - test_create_hard_link_many, - test_create_hard_link_same_loc, - test_create_hard_link_invalid_params, - test_create_soft_link_existing_relative, - test_create_soft_link_existing_absolute, - test_create_soft_link_dangling_relative, - test_create_soft_link_dangling_absolute, - test_create_soft_link_long_name, - test_create_soft_link_many, - test_create_soft_link_invalid_params, - test_create_external_link, - test_create_external_link_dangling, - test_create_external_link_multi, - test_create_external_link_ping_pong, - test_create_external_link_invalid_params, - test_create_user_defined_link, - test_create_user_defined_link_invalid_params, - test_delete_link, - test_delete_link_reset_grp_max_crt_order, - test_delete_link_invalid_params, - test_copy_link, - test_copy_links_into_group_with_links, - test_copy_link_across_files, - test_copy_link_invalid_params, - test_move_link, - test_move_links_into_group_with_links, - test_move_link_across_files, - test_move_link_reset_grp_max_crt_order, - test_move_link_invalid_params, - test_get_link_val, - test_get_link_val_invalid_params, - test_get_link_info, - test_get_link_info_invalid_params, - test_get_link_name, - test_get_link_name_invalid_params, - test_link_iterate_hard_links, - test_link_iterate_soft_links, - test_link_iterate_external_links, - test_link_iterate_ud_links, - test_link_iterate_mixed_links, - test_link_iterate_invalid_params, - test_link_iterate_0_links, - test_link_visit_hard_links_no_cycles, - test_link_visit_soft_links_no_cycles, - test_link_visit_external_links_no_cycles, - test_link_visit_ud_links_no_cycles, - test_link_visit_mixed_links_no_cycles, - test_link_visit_hard_links_cycles, - test_link_visit_soft_links_cycles, - test_link_visit_external_links_cycles, - test_link_visit_ud_links_cycles, - test_link_visit_mixed_links_cycles, - test_link_visit_invalid_params, - test_link_visit_0_links, -}; +static void +print_link_test_header(void) +{ + printf("\n"); + printf("**********************************************\n"); + printf("* *\n"); + printf("* API Link Tests *\n"); + printf("* *\n"); + printf("**********************************************\n\n"); +} /* * A test to check that a hard link can be created * using H5Lcreate_hard. */ -static int +static void test_create_hard_link(void) { htri_t link_exists; @@ -187,7 +194,7 @@ test_create_hard_link(void) SKIPPED(); printf(" API functions for basic file, group, link, or hard link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -237,7 +244,7 @@ test_create_hard_link(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -248,14 +255,14 @@ test_create_hard_link(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a hard link with a long name can be created * using H5Lcreate_hard. */ -static int +static void test_create_hard_link_long_name(void) { htri_t link_exists; @@ -274,7 +281,7 @@ test_create_hard_link_long_name(void) SKIPPED(); printf(" API functions for basic file, group, link, or hard link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -302,10 +309,6 @@ test_create_hard_link_long_name(void) goto error; } - /** for DAOS VOL, max link name supported is 99 (Lexical key) */ - if (strcmp(vol_name, "daos") == 0) - name_len = 99; - /* Construct very long file name */ if ((objname = (char *)malloc((size_t)(name_len + 1))) == NULL) TEST_ERROR; @@ -346,7 +349,7 @@ test_create_hard_link_long_name(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -360,20 +363,21 @@ test_create_hard_link_long_name(void) if (objname) free(objname); - return 1; + return; } /* * A test to check that many hard links can be created * using H5Lcreate_hard. */ -static int +static void test_create_hard_link_many(void) { htri_t link_exists; hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID; hid_t group_id = H5I_INVALID_HID, group_id2 = H5I_INVALID_HID; + bool valid_name_matched = FALSE; char objname[HARD_LINK_TEST_GROUP_MANY_NAME_BUF_SIZE]; /* Object name */ TESTING("hard link creation of many links"); @@ -384,7 +388,7 @@ test_create_hard_link_many(void) SKIPPED(); printf( " API functions for basic file, group, or hard link aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -505,6 +509,7 @@ test_create_hard_link_many(void) HARD_LINK_TEST_GROUP_MANY_FINAL_NAME); goto error; } + /* Check name */ if (H5Iget_name(group_id2, objname, (size_t)HARD_LINK_TEST_GROUP_MANY_NAME_BUF_SIZE) < 0) { H5_FAILED(); @@ -512,9 +517,23 @@ test_create_hard_link_many(void) goto error; } - if (HDstrcmp(objname, "/" LINK_TEST_GROUP_NAME "/" HARD_LINK_TEST_GROUP_MANY_NAME "/hard21")) { + for (size_t i = 1; (i < HARD_LINK_TEST_GROUP_MANY_NUM_HARD_LINKS + 1 && !valid_name_matched); i++) { + char name_possibility[H5_API_TEST_FILENAME_MAX_LENGTH]; + + snprintf(name_possibility, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%zu", + "/" LINK_TEST_GROUP_NAME "/" HARD_LINK_TEST_GROUP_MANY_NAME "/hard", i); + + valid_name_matched |= !strcmp(objname, name_possibility); + } + + valid_name_matched |= !strcmp(objname, "/" LINK_TEST_GROUP_NAME "/" HARD_LINK_TEST_GROUP_MANY_NAME + "/" HARD_LINK_TEST_GROUP_MANY_FINAL_NAME); + + if (!valid_name_matched) { H5_FAILED(); - printf(" wrong name of the object '%s'\n", objname); + printf(" H5Iget_name failed to retrieve a valid name for '%s'\n", + HARD_LINK_TEST_GROUP_MANY_FINAL_NAME); + goto error; } @@ -529,7 +548,7 @@ test_create_hard_link_many(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -541,14 +560,14 @@ test_create_hard_link_many(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that behavior is correct when using * the H5L_SAME_LOC macro for H5Lcreate_hard(). */ -static int +static void test_create_hard_link_same_loc(void) { htri_t link_exists; @@ -563,7 +582,7 @@ test_create_hard_link_same_loc(void) SKIPPED(); printf(" API functions for basic file, group, link, or hard link aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -661,7 +680,7 @@ test_create_hard_link_same_loc(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -672,22 +691,22 @@ test_create_hard_link_same_loc(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a hard link can't be created when * H5Lcreate_hard is passed invalid parameters. */ -static int +static void test_create_hard_link_invalid_params(void) { herr_t err_ret = -1; htri_t link_exists; hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; - hid_t ext_file_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; + hid_t ext_file_id = H5I_INVALID_HID; TESTING_MULTIPART("hard link creation with invalid parameters"); @@ -697,7 +716,7 @@ test_create_hard_link_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, link, or hard link aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -721,6 +740,18 @@ test_create_hard_link_invalid_params(void) goto error; } + if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + H5_FAILED(); + printf(" couldn't create external link test file name\n"); + goto error; + } + + if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); + goto error; + } + PASSED(); BEGIN_MULTIPART @@ -900,18 +931,6 @@ test_create_hard_link_invalid_params(void) { TESTING_2("H5Lcreate_hard across files"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { - H5_FAILED(); - printf(" couldn't create external link test file name\n"); - PART_ERROR(H5Lcreate_hard_across_files); - } - - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lcreate_hard_across_files); - } - H5E_BEGIN_TRY { err_ret = H5Lcreate_hard(file_id, "/", ext_file_id, HARD_LINK_INVALID_PARAMS_TEST_LINK_NAME, @@ -977,11 +996,13 @@ test_create_hard_link_invalid_params(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -990,18 +1011,19 @@ test_create_hard_link_invalid_params(void) H5Gclose(container_group); H5Fclose(ext_file_id); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* test_create_hard_link_invalid_params */ /* * A test to check that a soft link, which points to an * existing object with a relative path, can be created. */ -static int +static void test_create_soft_link_existing_relative(void) { htri_t link_exists; @@ -1017,7 +1039,7 @@ test_create_soft_link_existing_relative(void) SKIPPED(); printf(" API functions for basic file, group, link, or soft link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1089,7 +1111,7 @@ test_create_soft_link_existing_relative(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1101,14 +1123,14 @@ test_create_soft_link_existing_relative(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a soft link, which points to an * existing object using an absolute path, can be created. */ -static int +static void test_create_soft_link_existing_absolute(void) { htri_t link_exists; @@ -1123,7 +1145,7 @@ test_create_soft_link_existing_absolute(void) SKIPPED(); printf(" API functions for basic file, group, link, or soft link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1184,7 +1206,7 @@ test_create_soft_link_existing_absolute(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1196,7 +1218,7 @@ test_create_soft_link_existing_absolute(void) } H5E_END_TRY - return 1; + return; } /* @@ -1204,7 +1226,7 @@ test_create_soft_link_existing_absolute(void) * an object that doesn't exist by using a relative * path, can be created. */ -static int +static void test_create_soft_link_dangling_relative(void) { htri_t link_exists; @@ -1220,7 +1242,7 @@ test_create_soft_link_dangling_relative(void) SKIPPED(); printf(" API functions for basic file, group, link, or soft link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1305,7 +1327,7 @@ test_create_soft_link_dangling_relative(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1317,7 +1339,7 @@ test_create_soft_link_dangling_relative(void) } H5E_END_TRY - return 1; + return; } /* @@ -1325,7 +1347,7 @@ test_create_soft_link_dangling_relative(void) * object that doesn't exist by using an absolute path, * can be created. */ -static int +static void test_create_soft_link_dangling_absolute(void) { htri_t link_exists; @@ -1341,7 +1363,7 @@ test_create_soft_link_dangling_absolute(void) SKIPPED(); printf(" API functions for basic file, group, link, or soft link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1427,7 +1449,7 @@ test_create_soft_link_dangling_absolute(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1439,14 +1461,14 @@ test_create_soft_link_dangling_absolute(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a soft link with a long name can be created * using H5Lcreate_soft. */ -static int +static void test_create_soft_link_long_name(void) { htri_t link_exists; @@ -1465,7 +1487,7 @@ test_create_soft_link_long_name(void) SKIPPED(); printf(" API functions for basic file, group, link, or soft link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1493,10 +1515,6 @@ test_create_soft_link_long_name(void) goto error; } - /** for DAOS VOL, max link name supported is 99 (Lexical key) */ - if (strcmp(vol_name, "daos") == 0) - name_len = 99; - /* Construct very long file name */ if ((objname = (char *)malloc((size_t)(name_len + 1))) == NULL) TEST_ERROR; @@ -1537,7 +1555,7 @@ test_create_soft_link_long_name(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1551,21 +1569,22 @@ test_create_soft_link_long_name(void) if (objname) free(objname); - return 1; + return; } /* * A test to check that many soft links can be created * using H5Lcreate_soft. */ -static int +static void test_create_soft_link_many(void) { - htri_t link_exists; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID; - hid_t group_id = H5I_INVALID_HID; - hid_t object_id = H5I_INVALID_HID; + htri_t link_exists = FAIL; + bool valid_name_matched = FALSE; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID; + hid_t group_id = H5I_INVALID_HID; + hid_t object_id = H5I_INVALID_HID; char objname[SOFT_LINK_TEST_GROUP_MANY_NAME_BUF_SIZE]; /* Object name */ TESTING("soft link creation of many links"); @@ -1576,7 +1595,7 @@ test_create_soft_link_many(void) SKIPPED(); printf(" API functions for basic file, group, link, or soft link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -1715,9 +1734,23 @@ test_create_soft_link_many(void) goto error; } - if (HDstrcmp(objname, "/" LINK_TEST_GROUP_NAME "/" SOFT_LINK_TEST_GROUP_MANY_NAME "/soft16")) { + for (size_t i = 1; (i < SOFT_LINK_TEST_GROUP_MANY_NAME_SOFT_LINK_COUNT + 1 && !valid_name_matched); i++) { + char name_possibility[H5_API_TEST_FILENAME_MAX_LENGTH]; + + snprintf(name_possibility, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%zu", + "/" LINK_TEST_GROUP_NAME "/" SOFT_LINK_TEST_GROUP_MANY_NAME "/soft", i); + + valid_name_matched |= !strcmp(objname, name_possibility); + } + + valid_name_matched |= !strcmp(objname, "/" LINK_TEST_GROUP_NAME "/" SOFT_LINK_TEST_GROUP_MANY_NAME + "/" SOFT_LINK_TEST_GROUP_MANY_FINAL_NAME); + + if (!valid_name_matched) { H5_FAILED(); - printf(" wrong name of the object '%s'\n", objname); + printf(" H5Iget_name failed to retrieve a valid name for '%s'\n", + "/" LINK_TEST_GROUP_NAME "/" SOFT_LINK_TEST_GROUP_MANY_NAME + "/" SOFT_LINK_TEST_GROUP_MANY_FINAL_NAME); goto error; } @@ -1732,7 +1765,7 @@ test_create_soft_link_many(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1744,14 +1777,14 @@ test_create_soft_link_many(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a soft link can't be created * when H5Lcreate_soft is passed invalid parameters. */ -static int +static void test_create_soft_link_invalid_params(void) { herr_t err_ret = -1; @@ -1767,7 +1800,7 @@ test_create_soft_link_invalid_params(void) SKIPPED(); printf( " API functions for basic file, group, or soft link aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1967,7 +2000,7 @@ test_create_soft_link_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1978,21 +2011,21 @@ test_create_soft_link_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that an external link can be created * using H5Lcreate_external. */ -static int +static void test_create_external_link(void) { htri_t link_exists; hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t root_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t root_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING("external link creation to existing object"); @@ -2002,7 +2035,7 @@ test_create_external_link(void) SKIPPED(); printf(" API functions for basic file, group, link, or external link aren't supported " "with this connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { @@ -2074,11 +2107,13 @@ test_create_external_link(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2087,11 +2122,12 @@ test_create_external_link(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* @@ -2099,14 +2135,14 @@ test_create_external_link(void) * object that doesn't exist by using an absolute path, can * be created. */ -static int +static void test_create_external_link_dangling(void) { htri_t link_exists; hid_t file_id = H5I_INVALID_HID, ext_file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t object_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t object_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING("dangling external link creation"); @@ -2116,7 +2152,7 @@ test_create_external_link_dangling(void) SKIPPED(); printf(" API functions for basic file, group, link, or external link aren't supported " "with this connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { @@ -2212,11 +2248,12 @@ test_create_external_link_dangling(void) TEST_ERROR; if (H5Fclose(ext_file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); - PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2226,27 +2263,28 @@ test_create_external_link_dangling(void) H5Gclose(container_group); H5Fclose(file_id); H5Fclose(ext_file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that an external link to an object * that crosses several files using H5Lcreate_external. */ -static int +static void test_create_external_link_multi(void) { hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t group_id2 = H5I_INVALID_HID, group_id3 = H5I_INVALID_HID; - hid_t root_id = H5I_INVALID_HID; - char *ext_link_filename1 = NULL; - char *ext_link_filename2 = NULL; - char *ext_link_filename3 = NULL; + hid_t root_id = H5I_INVALID_HID; + char *ext_link_filename1 = NULL; + char *ext_link_filename2 = NULL; + char *ext_link_filename3 = NULL; char objname[EXTERNAL_LINK_TEST_MULTI_NAME_BUF_SIZE]; TESTING_MULTIPART("external link creation to an object across several files"); @@ -2257,7 +2295,7 @@ test_create_external_link_multi(void) SKIPPED(); printf(" API functions for basic file, group, or external link aren't supported with this " "connector\n"); - return 0; + return; } BEGIN_MULTIPART @@ -2490,9 +2528,10 @@ test_create_external_link_multi(void) PART_ERROR(H5Lcreate_external_final_file); } - if (HDstrcmp(objname, "/A/B/C")) { + if (strcmp(objname, "/A/B/C") && strcmp(objname, "/D/E/F") && strcmp(objname, "/G/H/I") && + strcmp(objname, "/" LINK_TEST_GROUP_NAME "/" EXTERNAL_LINK_TEST_MULTI_NAME "/ext_link")) { H5_FAILED(); - printf(" wrong name of the object '%s'\n", objname); + printf(" H5Iget_name failed to retrieve a valid name for the object '%s'\n", "/A/B/C"); PART_ERROR(H5Lcreate_external_final_file); } @@ -2560,9 +2599,13 @@ test_create_external_link_multi(void) PART_ERROR(H5Lcreate_external_object_created); } - if (HDstrcmp(objname, "/A/B/C/new_group")) { + if (strcmp(objname, "/A/B/C/new_group") && strcmp(objname, "/D/E/F/new_group") && + strcmp(objname, "/G/H/I/new_group") && + strcmp(objname, + "/" LINK_TEST_GROUP_NAME "/" EXTERNAL_LINK_TEST_MULTI_NAME "/ext_link/new_group")) { H5_FAILED(); - printf(" wrong name of the object '%s'\n", objname); + printf(" H5Iget_name was unable to retrieve a valid name for the object '%s'\n", + "/A/B/C/new_group"); PART_ERROR(H5Lcreate_external_object_created); } @@ -2584,10 +2627,18 @@ test_create_external_link_multi(void) } END_MULTIPART; + if (remove_test_file(NULL, ext_link_filename1) < 0) + TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename2) < 0) + TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename3) < 0) + TEST_ERROR; + free(ext_link_filename1); free(ext_link_filename2); free(ext_link_filename3); - return 0; + + return; error: H5E_BEGIN_TRY @@ -2598,13 +2649,16 @@ test_create_external_link_multi(void) H5Gclose(group_id3); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename1); + remove_test_file(NULL, ext_link_filename2); + remove_test_file(NULL, ext_link_filename3); free(ext_link_filename1); free(ext_link_filename2); free(ext_link_filename3); } H5E_END_TRY - return 1; + return; } /* @@ -2618,14 +2672,15 @@ test_create_external_link_multi(void) * file1:/link5 -> file2: /link6 * file2:/link6 -> file1: /final */ -static int +static void test_create_external_link_ping_pong(void) { - hid_t file_id = H5I_INVALID_HID; - hid_t group_id = H5I_INVALID_HID; - hid_t group_id2 = H5I_INVALID_HID; - char *ext_link_filename1 = NULL; - char *ext_link_filename2 = NULL; + hid_t file_id = H5I_INVALID_HID; + hid_t group_id = H5I_INVALID_HID; + hid_t group_id2 = H5I_INVALID_HID; + bool valid_name_matched = false; + char *ext_link_filename1 = NULL; + char *ext_link_filename2 = NULL; char objname[EXTERNAL_LINK_TEST_MULTI_NAME_BUF_SIZE]; TESTING_MULTIPART("external link creation to an object in ping pong style"); @@ -2636,7 +2691,7 @@ test_create_external_link_ping_pong(void) SKIPPED(); printf(" API functions for basic file, group, or external link aren't supported with this " "connector\n"); - return 0; + return; } if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_PING_PONG_NAME1, &ext_link_filename1) < 0) { @@ -2778,9 +2833,19 @@ test_create_external_link_ping_pong(void) PART_ERROR(H5Lcreate_external_verify); } - if (HDstrcmp(objname, "/final")) { + for (size_t i = 1; i < EXTERNAL_LINK_TEST_PING_PONG_NUM_LINKS + 1 && !valid_name_matched; i++) { + char name_possibility[H5_API_TEST_FILENAME_MAX_LENGTH]; + + snprintf(name_possibility, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%zu", "/link", i); + + valid_name_matched |= !strcmp(name_possibility, objname); + } + + valid_name_matched |= !strcmp(objname, "/final"); + + if (!valid_name_matched) { H5_FAILED(); - printf(" wrong name of the object '%s'\n", objname); + printf(" H5Iget_name was unable to retrieve a valid name for the object '%s'\n", "/final"); PART_ERROR(H5Lcreate_external_verify); } @@ -2838,9 +2903,20 @@ test_create_external_link_ping_pong(void) PART_ERROR(H5Lcreate_external_verify_again); } - if (HDstrcmp(objname, "/final/new_group")) { + for (size_t i = 1; i < EXTERNAL_LINK_TEST_PING_PONG_NUM_LINKS + 1 && !valid_name_matched; i++) { + char name_possibility[H5_API_TEST_FILENAME_MAX_LENGTH]; + + snprintf(name_possibility, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%zu%s", "/link", i, + "/new_group"); + + valid_name_matched |= !strcmp(objname, name_possibility); + } + + valid_name_matched |= !strcmp(objname, "/final/new_group"); + + if (!valid_name_matched) { H5_FAILED(); - printf(" wrong name of the object '%s'\n", objname); + printf(" H5Iget_name was unable to find a valid name for '%s'\n", "/final/new_group"); PART_ERROR(H5Lcreate_external_verify_again); } @@ -2863,10 +2939,15 @@ test_create_external_link_ping_pong(void) } END_MULTIPART; + if (remove_test_file(NULL, ext_link_filename1) < 0) + TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename2) < 0) + TEST_ERROR; + free(ext_link_filename1); free(ext_link_filename2); - return 0; + return; error: H5E_BEGIN_TRY @@ -2874,19 +2955,21 @@ test_create_external_link_ping_pong(void) H5Gclose(group_id); H5Gclose(group_id2); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename1); + remove_test_file(NULL, ext_link_filename2); free(ext_link_filename1); free(ext_link_filename2); } H5E_END_TRY - return 1; + return; } /* * A test to check that an external link can't be created * when H5Lcreate_external is passed invalid parameters. */ -static int +static void test_create_external_link_invalid_params(void) { herr_t err_ret = -1; @@ -2903,7 +2986,7 @@ test_create_external_link_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, link, or external link aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3158,10 +3241,13 @@ test_create_external_link_invalid_params(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); + PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3169,17 +3255,18 @@ test_create_external_link_invalid_params(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that a user-defined link can be created. */ -static int +static void test_create_user_defined_link(void) { ssize_t udata_size; @@ -3197,7 +3284,7 @@ test_create_user_defined_link(void) printf( " API functions for basic file, group, link, or user-defined link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -3219,7 +3306,7 @@ test_create_user_defined_link(void) goto error; } - if ((udata_size = HDsnprintf(udata, UD_LINK_TEST_UDATA_MAX_SIZE, "udata")) < 0) + if ((udata_size = snprintf(udata, UD_LINK_TEST_UDATA_MAX_SIZE, "udata")) < 0) TEST_ERROR; if (H5Lcreate_ud(group_id, UD_LINK_TEST_LINK_NAME, H5L_TYPE_EXTERNAL, udata, (size_t)udata_size, @@ -3251,7 +3338,7 @@ test_create_user_defined_link(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3262,14 +3349,14 @@ test_create_user_defined_link(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Lcreate_ud fails when * it is given invalid parameters. */ -static int +static void test_create_user_defined_link_invalid_params(void) { ssize_t udata_size; @@ -3287,7 +3374,7 @@ test_create_user_defined_link_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, or user-defined link aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3311,7 +3398,7 @@ test_create_user_defined_link_invalid_params(void) goto error; } - if ((udata_size = HDsnprintf(udata, UD_LINK_INVALID_PARAMS_TEST_UDATA_MAX_SIZE, "udata")) < 0) + if ((udata_size = snprintf(udata, UD_LINK_INVALID_PARAMS_TEST_UDATA_MAX_SIZE, "udata")) < 0) TEST_ERROR; PASSED(); @@ -3499,7 +3586,7 @@ test_create_user_defined_link_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3510,23 +3597,23 @@ test_create_user_defined_link_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a link can be deleted * using H5Ldelete and H5Ldelete_by_idx. */ -static int +static void test_delete_link(void) { htri_t link_exists; hid_t file_id = H5I_INVALID_HID, ext_file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t subgroup_id = H5I_INVALID_HID; - hid_t nested_grp_id = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t subgroup_id = H5I_INVALID_HID; + hid_t nested_grp_id = H5I_INVALID_HID; + hid_t gcpl_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING_MULTIPART("link deletion"); @@ -3538,7 +3625,7 @@ test_delete_link(void) SKIPPED(); printf(" API functions for basic file, group, link, hard link, soft link, or external link " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3576,6 +3663,19 @@ test_delete_link(void) goto error; } + if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + H5_FAILED(); + printf(" couldn't create external link filename\n"); + goto error; + } + + /* Create file for external link to reference */ + if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); + goto error; + } + PASSED(); BEGIN_MULTIPART @@ -3804,24 +3904,6 @@ test_delete_link(void) { TESTING_2("H5Ldelete on external link"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { - H5_FAILED(); - printf(" couldn't create external link filename\n"); - PART_ERROR(H5Ldelete_external); - } - - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Ldelete_external); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Ldelete_external); - } - if ((subgroup_id = H5Gcreate2(group_id, LINK_DELETE_TEST_SUBGROUP3_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -3885,8 +3967,6 @@ test_delete_link(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -3912,6 +3992,12 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on hard link by creation order in increasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_hard_crt_order_increasing); + } + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { SKIPPED(); printf(" creation order tracking isn't supported with this VOL connector\n"); @@ -4145,6 +4231,12 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on hard link by creation order in decreasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_hard_crt_order_decreasing); + } + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { SKIPPED(); printf(" creation order tracking isn't supported with this VOL connector\n"); @@ -4378,6 +4470,12 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on hard link by alphabetical order in increasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_hard_name_order_increasing); + } + if ((subgroup_id = H5Gcreate2(group_id, LINK_DELETE_TEST_SUBGROUP7_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -4605,6 +4703,12 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on hard link by alphabetical order in decreasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_hard_name_order_decreasing); + } + if ((subgroup_id = H5Gcreate2(group_id, LINK_DELETE_TEST_SUBGROUP8_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -4832,6 +4936,12 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on soft link by creation order in increasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_soft_crt_order_increasing); + } + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { SKIPPED(); printf(" creation order tracking isn't supported with this VOL connector\n"); @@ -5068,6 +5178,12 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on soft link by creation order in decreasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_soft_crt_order_decreasing); + } + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { SKIPPED(); printf(" creation order tracking isn't supported with this VOL connector\n"); @@ -5304,6 +5420,12 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on soft link by alphabetical order in increasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_soft_name_order_increasing); + } + if ((subgroup_id = H5Gcreate2(group_id, LINK_DELETE_TEST_SUBGROUP11_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -5534,6 +5656,12 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on soft link by alphabetical order in decreasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_soft_name_order_decreasing); + } + if ((subgroup_id = H5Gcreate2(group_id, LINK_DELETE_TEST_SUBGROUP12_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -5764,23 +5892,16 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on external link by creation order in increasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" by index isn't supported with this VOL connector\n"); PART_EMPTY(H5Ldelete_by_idx_external_crt_order_increasing); } - /* Create file for external link to reference */ - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Ldelete_by_idx_external_crt_order_increasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Ldelete_by_idx_external_crt_order_increasing); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + SKIPPED(); + printf(" creation order tracking isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_external_crt_order_increasing); } if ((subgroup_id = H5Gcreate2(group_id, LINK_DELETE_TEST_SUBGROUP13_NAME, H5P_DEFAULT, gcpl_id, @@ -6034,8 +6155,6 @@ test_delete_link(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -6043,23 +6162,16 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on external link by creation order in decreasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" by index isn't supported with this VOL connector\n"); PART_EMPTY(H5Ldelete_by_idx_external_crt_order_decreasing); } - /* Create file for external link to reference */ - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Ldelete_by_idx_external_crt_order_decreasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Ldelete_by_idx_external_crt_order_decreasing); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + SKIPPED(); + printf(" creation order tracking isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_external_crt_order_decreasing); } if ((subgroup_id = H5Gcreate2(group_id, LINK_DELETE_TEST_SUBGROUP14_NAME, H5P_DEFAULT, gcpl_id, @@ -6313,8 +6425,6 @@ test_delete_link(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -6322,17 +6432,10 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on external link by alphabetical order in increasing order"); - /* Create file for external link to reference */ - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Ldelete_by_idx_external_name_order_increasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Ldelete_by_idx_external_name_order_increasing); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_external_name_order_increasing); } if ((subgroup_id = H5Gcreate2(group_id, LINK_DELETE_TEST_SUBGROUP15_NAME, H5P_DEFAULT, gcpl_id, @@ -6586,8 +6689,6 @@ test_delete_link(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -6595,17 +6696,10 @@ test_delete_link(void) { TESTING_2("H5Ldelete_by_idx on external link by alphabetical order in decreasing order"); - /* Create file for external link to reference */ - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Ldelete_by_idx_external_name_order_decreasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Ldelete_by_idx_external_name_order_decreasing); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_BY_IDX)) { + SKIPPED(); + printf(" by index isn't supported with this VOL connector\n"); + PART_EMPTY(H5Ldelete_by_idx_external_name_order_decreasing); } if ((subgroup_id = H5Gcreate2(group_id, LINK_DELETE_TEST_SUBGROUP16_NAME, H5P_DEFAULT, gcpl_id, @@ -6859,8 +6953,6 @@ test_delete_link(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -6948,10 +7040,13 @@ test_delete_link(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); + PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6962,11 +7057,12 @@ test_delete_link(void) H5Gclose(container_group); H5Fclose(ext_file_id); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* @@ -6974,7 +7070,7 @@ test_delete_link(void) * maximum link creation order value gets reset once * all the links have been deleted from the group. */ -static int +static void test_delete_link_reset_grp_max_crt_order(void) { H5G_info_t grp_info; @@ -6994,7 +7090,7 @@ test_delete_link_reset_grp_max_crt_order(void) SKIPPED(); printf(" API functions for basic file, group, link, or creation order " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -7209,7 +7305,7 @@ test_delete_link_reset_grp_max_crt_order(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -7222,10 +7318,10 @@ test_delete_link_reset_grp_max_crt_order(void) } H5E_END_TRY - return 1; + return; } -static int +static void test_delete_link_invalid_params(void) { htri_t link_exists; @@ -7242,7 +7338,7 @@ test_delete_link_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, link, flag by index, or hard link aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -7538,7 +7634,7 @@ test_delete_link_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -7549,20 +7645,20 @@ test_delete_link_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a link can be copied using H5Lcopy. */ -static int +static void test_copy_link(void) { htri_t link_exists; hid_t file_id = H5I_INVALID_HID, ext_file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t src_grp_id = H5I_INVALID_HID, dst_grp_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + char *ext_link_filename = NULL; TESTING_MULTIPART("link copying"); @@ -7574,7 +7670,7 @@ test_copy_link(void) SKIPPED(); printf(" API functions for basic file, group, link, hard link, soft link, or external link aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -7612,6 +7708,18 @@ test_copy_link(void) goto error; } + if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + H5_FAILED(); + printf(" couldn't create external link test file name\n"); + goto error; + } + + if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); + goto error; + } + PASSED(); BEGIN_MULTIPART @@ -8170,7 +8278,7 @@ test_copy_link(void) PART_ERROR(H5Lcopy_soft_check); } - if (HDstrncmp(orig_link_val, new_link_val, COPY_LINK_TEST_LINK_VAL_BUF_SIZE)) { + if (strncmp(orig_link_val, new_link_val, COPY_LINK_TEST_LINK_VAL_BUF_SIZE)) { H5_FAILED(); printf(" copied soft link's value '%s' doesn't match original link's value '%s'\n", new_link_val, orig_link_val); @@ -8303,24 +8411,6 @@ test_copy_link(void) { TESTING_2("H5Lcopy on external link (copied link's properties not checked)"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { - H5_FAILED(); - printf(" couldn't create external link filename\n"); - PART_ERROR(H5Lcopy_external_no_check); - } - - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lcopy_external_no_check); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lcopy_external_no_check); - } - /* Try to copy an external link */ if (H5Lcreate_external(ext_link_filename, "/", src_grp_id, COPY_LINK_TEST_EXTERNAL_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) { @@ -8397,13 +8487,6 @@ test_copy_link(void) } PART_END(H5Lcopy_external_no_check); - H5E_BEGIN_TRY - { - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; - } - H5E_END_TRY - PART_BEGIN(H5Lcopy_external_check) { H5L_info2_t orig_info, new_info; @@ -8414,17 +8497,6 @@ test_copy_link(void) char new_link_val[COPY_LINK_TEST_LINK_VAL_BUF_SIZE]; TESTING_2("H5Lcopy on external link (copied link's properties checked)"); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lcopy_external_check); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lcopy_external_check); - } /* Try to copy an external link */ if (H5Lcreate_external(ext_link_filename, "/", src_grp_id, COPY_LINK_TEST_EXTERNAL_LINK_NAME2, @@ -8584,7 +8656,7 @@ test_copy_link(void) PART_ERROR(H5Lcopy_external_check); } - if (HDstrncmp(new_filename, orig_filename, strlen(orig_filename)) < 0) { + if (strncmp(new_filename, orig_filename, strlen(orig_filename)) < 0) { H5_FAILED(); printf(" copied external link's filename '%s' doesn't match original external link's " "filename '%s'\n", @@ -8592,7 +8664,7 @@ test_copy_link(void) PART_ERROR(H5Lcopy_external_check); } - if (HDstrncmp(new_objname, orig_objname, strlen(orig_objname)) < 0) { + if (strncmp(new_objname, orig_objname, strlen(orig_objname)) < 0) { H5_FAILED(); printf(" copied external link's object name '%s' doesn't match original external link's " "object name '%s'\n", @@ -8604,27 +8676,9 @@ test_copy_link(void) } PART_END(H5Lcopy_external_check); - H5E_BEGIN_TRY - { - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; - } - H5E_END_TRY - PART_BEGIN(H5Lcopy_external_same_loc) { TESTING_2("H5Lcopy on external link using H5L_SAME_LOC"); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lcopy_external_same_loc); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lcopy_external_same_loc); - } /* Try to copy an external link */ if (H5Lcreate_external(ext_link_filename, "/", src_grp_id, COPY_LINK_TEST_EXTERNAL_LINK_NAME3, @@ -8743,13 +8797,6 @@ test_copy_link(void) } PART_END(H5Lcopy_external_same_loc); - H5E_BEGIN_TRY - { - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; - } - H5E_END_TRY - PART_BEGIN(H5Lcopy_ud_no_check) { TESTING_2("H5Lcopy on user-defined link (copied link's properties not checked)"); @@ -8797,10 +8844,13 @@ test_copy_link(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); + PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -8811,11 +8861,12 @@ test_copy_link(void) H5Gclose(container_group); H5Fclose(ext_file_id); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* @@ -8827,14 +8878,14 @@ test_copy_link(void) * H5Lcopy might cause a group to have two links with the same * creation order values. */ -static int +static void test_copy_links_into_group_with_links(void) { TESTING("H5Lcopy adjusting creation order values for copied links"); SKIPPED(); - return 1; + return; } /* @@ -8846,7 +8897,7 @@ test_copy_links_into_group_with_links(void) * copied links retain the properties of the original * links. */ -static int +static void test_copy_link_across_files(void) { TESTING("link copying across files"); @@ -8855,14 +8906,14 @@ test_copy_link_across_files(void) SKIPPED(); - return 0; + return; } /* * A test to check that a link can't be copied * when H5Lcopy is passed invalid parameters. */ -static int +static void test_copy_link_invalid_params(void) { herr_t err_ret = -1; @@ -8870,8 +8921,8 @@ test_copy_link_invalid_params(void) hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t src_grp_id = H5I_INVALID_HID, dst_grp_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; - hid_t ext_file_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; + hid_t ext_file_id = H5I_INVALID_HID; TESTING_MULTIPART("H5Lcopy with invalid parameters"); @@ -8882,7 +8933,7 @@ test_copy_link_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, link, or hard links aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -8942,6 +8993,18 @@ test_copy_link_invalid_params(void) goto error; } + if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + H5_FAILED(); + printf(" couldn't create external link filename\n"); + goto error; + } + + if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); + goto error; + } + PASSED(); BEGIN_MULTIPART @@ -9130,18 +9193,6 @@ test_copy_link_invalid_params(void) { TESTING_2("H5Lcopy invalid across files"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { - H5_FAILED(); - printf(" couldn't create external link filename\n"); - PART_ERROR(H5Lcopy_invalid_across_files); - } - - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lcopy_invalid_across_files); - } - H5E_BEGIN_TRY { err_ret = @@ -9156,12 +9207,6 @@ test_copy_link_invalid_params(void) PART_ERROR(H5Lcopy_invalid_across_files); } - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lcopy_invalid_across_files); - } - PASSED(); } PART_END(H5Lcopy_invalid_across_files); @@ -9180,10 +9225,12 @@ test_copy_link_invalid_params(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -9194,25 +9241,26 @@ test_copy_link_invalid_params(void) H5Gclose(container_group); H5Fclose(ext_file_id); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that a link can be moved with H5Lmove. */ -static int +static void test_move_link(void) { htri_t link_exists; hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t src_grp_id = H5I_INVALID_HID, dst_grp_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; - hid_t ext_file_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; + hid_t ext_file_id = H5I_INVALID_HID; TESTING_MULTIPART("link moving"); @@ -9224,17 +9272,11 @@ test_move_link(void) SKIPPED(); printf(" API functions for basic file, group, link, hard link, soft link, or external link aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { - H5_FAILED(); - printf(" couldn't create external link filename\n"); - goto error; - } - if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't open file '%s'\n", H5_API_TEST_FILENAME); @@ -9268,6 +9310,18 @@ test_move_link(void) goto error; } + if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + H5_FAILED(); + printf(" couldn't create external link filename\n"); + goto error; + } + + if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); + goto error; + } + PASSED(); BEGIN_MULTIPART @@ -9904,7 +9958,7 @@ test_move_link(void) PART_ERROR(H5Lmove_soft_check); } - if (HDstrncmp(orig_link_val, new_link_val, MOVE_LINK_TEST_LINK_VAL_BUF_SIZE)) { + if (strncmp(orig_link_val, new_link_val, MOVE_LINK_TEST_LINK_VAL_BUF_SIZE)) { H5_FAILED(); printf(" moved soft link's value '%s' doesn't match original link's value '%s'\n", new_link_val, orig_link_val); @@ -10113,17 +10167,6 @@ test_move_link(void) PART_BEGIN(H5Lmove_external_no_check) { TESTING_2("H5Lmove on external link (moved link's properties not checked)"); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lmove_external_no_check); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lmove_external_no_check); - } /* Try to move an external link */ if (H5Lcreate_external(ext_link_filename, "/", src_grp_id, MOVE_LINK_TEST_EXTERN_LINK_NAME, @@ -10201,13 +10244,6 @@ test_move_link(void) } PART_END(H5Lmove_external_no_check); - H5E_BEGIN_TRY - { - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; - } - H5E_END_TRY - PART_BEGIN(H5Lmove_external_check) { H5L_info2_t orig_info, new_info; @@ -10218,17 +10254,6 @@ test_move_link(void) char new_link_val[MOVE_LINK_TEST_LINK_VAL_BUF_SIZE]; TESTING_2("H5Lmove on external link (moved link's properties checked)"); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lmove_external_check); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lmove_external_check); - } /* Try to move an external link */ if (H5Lcreate_external(ext_link_filename, "/", src_grp_id, MOVE_LINK_TEST_EXTERN_LINK_NAME2, @@ -10388,7 +10413,7 @@ test_move_link(void) PART_ERROR(H5Lmove_external_check); } - if (HDstrncmp(new_filename, orig_filename, strlen(orig_filename)) < 0) { + if (strncmp(new_filename, orig_filename, strlen(orig_filename)) < 0) { H5_FAILED(); printf(" moved external link's filename '%s' doesn't match original external link's " "filename '%s'\n", @@ -10396,7 +10421,7 @@ test_move_link(void) PART_ERROR(H5Lmove_external_check); } - if (HDstrncmp(new_objname, orig_objname, strlen(orig_objname)) < 0) { + if (strncmp(new_objname, orig_objname, strlen(orig_objname)) < 0) { H5_FAILED(); printf(" moved external link's object name '%s' doesn't match original external link's " "object name '%s'\n", @@ -10408,27 +10433,9 @@ test_move_link(void) } PART_END(H5Lmove_external_check); - H5E_BEGIN_TRY - { - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; - } - H5E_END_TRY - PART_BEGIN(H5Lmove_external_same_loc) { TESTING_2("H5Lmove on external link using H5L_SAME_LOC"); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lmove_external_same_loc); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lmove_external_same_loc); - } /* Try to move an external link */ if (H5Lcreate_external(ext_link_filename, "/", src_grp_id, MOVE_LINK_TEST_EXTERN_LINK_NAME3, @@ -10543,27 +10550,9 @@ test_move_link(void) } PART_END(H5Lmove_external_same_loc); - H5E_BEGIN_TRY - { - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; - } - H5E_END_TRY - PART_BEGIN(H5Lmove_external_rename) { TESTING_2("H5Lmove to rename external link without moving it"); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lmove_external_rename); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lmove_external_rename); - } /* Try to move an external link */ if (H5Lcreate_external(ext_link_filename, "/", src_grp_id, MOVE_LINK_TEST_EXTERN_LINK_NAME4, @@ -10641,13 +10630,6 @@ test_move_link(void) } PART_END(H5Lmove_external_rename); - H5E_BEGIN_TRY - { - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; - } - H5E_END_TRY - PART_BEGIN(H5Lmove_ud_no_check) { TESTING_2("H5Lmove on user-defined link (moved link's properties not checked)"); @@ -10706,10 +10688,12 @@ test_move_link(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10720,11 +10704,12 @@ test_move_link(void) H5Gclose(container_group); H5Fclose(file_id); H5Fclose(ext_file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* @@ -10736,7 +10721,7 @@ test_move_link(void) * H5Lmove might cause a group to have two links with the same * creation order values. */ -static int +static void test_move_links_into_group_with_links(void) { H5L_info2_t link_info; @@ -10756,7 +10741,7 @@ test_move_links_into_group_with_links(void) SKIPPED(); printf(" API functions for basic file, group, link, hard link, or creation order aren't " "supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -10897,7 +10882,7 @@ test_move_links_into_group_with_links(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -10911,7 +10896,7 @@ test_move_links_into_group_with_links(void) } H5E_END_TRY - return 1; + return; } /* @@ -10922,7 +10907,7 @@ test_move_links_into_group_with_links(void) * TODO: Ideally, tests should be written to verify that the * moved links retain their original properties. */ -static int +static void test_move_link_across_files(void) { TESTING("link moving across files"); @@ -10931,7 +10916,7 @@ test_move_link_across_files(void) SKIPPED(); - return 0; + return; } /* @@ -10939,7 +10924,7 @@ test_move_link_across_files(void) * maximum link creation order value gets reset once * all the links have been moved out of the group. */ -static int +static void test_move_link_reset_grp_max_crt_order(void) { H5G_info_t grp_info; @@ -10959,7 +10944,7 @@ test_move_link_reset_grp_max_crt_order(void) SKIPPED(); printf(" API functions for basic file, group, link, hard link, or creation order aren't " "supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -11101,7 +11086,7 @@ test_move_link_reset_grp_max_crt_order(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -11115,14 +11100,14 @@ test_move_link_reset_grp_max_crt_order(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Lmove fails when it is given * invalid parameters. */ -static int +static void test_move_link_invalid_params(void) { htri_t link_exists; @@ -11130,8 +11115,8 @@ test_move_link_invalid_params(void) hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t src_grp_id = H5I_INVALID_HID, dst_grp_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; - hid_t ext_file_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; + hid_t ext_file_id = H5I_INVALID_HID; TESTING_MULTIPART("H5Lmove with invalid parameters"); @@ -11141,7 +11126,7 @@ test_move_link_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, link, or hard link aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -11216,6 +11201,18 @@ test_move_link_invalid_params(void) goto error; } + if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + H5_FAILED(); + printf(" failed to generate external link filename\n"); + goto error; + } + + if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); + goto error; + } + PASSED(); BEGIN_MULTIPART @@ -11436,18 +11433,6 @@ test_move_link_invalid_params(void) { TESTING_2("H5Lmove into another file"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { - H5_FAILED(); - printf(" couldn't create external link filename\n"); - PART_ERROR(H5Lmove_across_files); - } - - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lmove_across_files); - } - /* Move a group across files. */ H5E_BEGIN_TRY { @@ -11478,12 +11463,6 @@ test_move_link_invalid_params(void) PART_ERROR(H5Lmove_across_files); } - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" failed to close a file!\n"); - PART_ERROR(H5Lmove_across_files); - } - PASSED(); } PART_END(H5Lmove_across_files); @@ -11502,10 +11481,13 @@ test_move_link_invalid_params(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); + PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -11516,18 +11498,19 @@ test_move_link_invalid_params(void) H5Gclose(container_group); H5Fclose(ext_file_id); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that a soft or external link's value can * be retrieved by using H5Lget_val and H5Lget_val_by_idx. */ -static int +static void test_get_link_val(void) { H5L_info2_t link_info; @@ -11539,9 +11522,9 @@ test_get_link_val(void) char link_val_buf[GET_LINK_VAL_TEST_LINK_VAL_BUF_SIZE]; hid_t file_id = H5I_INVALID_HID, ext_file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t subgroup_id = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t subgroup_id = H5I_INVALID_HID; + hid_t gcpl_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING_MULTIPART("link value retrieval"); @@ -11552,7 +11535,7 @@ test_get_link_val(void) SKIPPED(); printf(" API functions for basic file, group, link, soft link, external link, or creation " "order aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -11596,6 +11579,12 @@ test_get_link_val(void) goto error; } + if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); + goto error; + } + PASSED(); BEGIN_MULTIPART @@ -11655,7 +11644,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_soft); } - if (HDstrncmp(link_val_buf, link_target, link_val_size)) { + if (strncmp(link_val_buf, link_target, link_val_size)) { H5_FAILED(); printf(" soft link value did not match\n"); PART_ERROR(H5Lget_val_soft); @@ -11686,18 +11675,6 @@ test_get_link_val(void) memset(&link_info, 0, sizeof(link_info)); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_val_external); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_val_external); - } - if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_VAL_TEST_SUBGROUP2_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -11753,14 +11730,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_external); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_external); } - if (HDstrncmp(ext_link_val, ext_obj_name, strlen(ext_obj_name) + 1)) { + if (strncmp(ext_link_val, ext_obj_name, strlen(ext_obj_name) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name); @@ -11781,8 +11758,6 @@ test_get_link_val(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -11912,7 +11887,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_crt_order_increasing); } - if (HDstrncmp(link_val_buf, link_target_a, strlen(link_target_a) + 1)) { + if (strncmp(link_val_buf, link_target_a, strlen(link_target_a) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 0, link_target_a); @@ -11943,7 +11918,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_crt_order_increasing); } - if (HDstrncmp(link_val_buf, link_target_b, strlen(link_target_b) + 1)) { + if (strncmp(link_val_buf, link_target_b, strlen(link_target_b) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 1, link_target_b); @@ -11974,7 +11949,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_crt_order_increasing); } - if (HDstrncmp(link_val_buf, link_target_c, strlen(link_target_c) + 1)) { + if (strncmp(link_val_buf, link_target_c, strlen(link_target_c) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 2, link_target_c); @@ -12106,7 +12081,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_crt_order_decreasing); } - if (HDstrncmp(link_val_buf, link_target_a, strlen(link_target_a) + 1)) { + if (strncmp(link_val_buf, link_target_a, strlen(link_target_a) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 2, link_target_a); @@ -12137,7 +12112,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_crt_order_decreasing); } - if (HDstrncmp(link_val_buf, link_target_b, strlen(link_target_b) + 1)) { + if (strncmp(link_val_buf, link_target_b, strlen(link_target_b) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 1, link_target_b); @@ -12168,7 +12143,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_crt_order_decreasing); } - if (HDstrncmp(link_val_buf, link_target_c, strlen(link_target_c) + 1)) { + if (strncmp(link_val_buf, link_target_c, strlen(link_target_c) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 0, link_target_c); @@ -12294,7 +12269,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_name_order_increasing); } - if (HDstrncmp(link_val_buf, link_target_a, strlen(link_target_a) + 1)) { + if (strncmp(link_val_buf, link_target_a, strlen(link_target_a) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 0, link_target_a); @@ -12325,7 +12300,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_name_order_increasing); } - if (HDstrncmp(link_val_buf, link_target_b, strlen(link_target_b) + 1)) { + if (strncmp(link_val_buf, link_target_b, strlen(link_target_b) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 1, link_target_b); @@ -12356,7 +12331,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_name_order_increasing); } - if (HDstrncmp(link_val_buf, link_target_c, strlen(link_target_c) + 1)) { + if (strncmp(link_val_buf, link_target_c, strlen(link_target_c) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 2, link_target_c); @@ -12482,7 +12457,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_name_order_decreasing); } - if (HDstrncmp(link_val_buf, link_target_a, strlen(link_target_a) + 1)) { + if (strncmp(link_val_buf, link_target_a, strlen(link_target_a) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 2, link_target_a); @@ -12513,7 +12488,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_name_order_decreasing); } - if (HDstrncmp(link_val_buf, link_target_b, strlen(link_target_b) + 1)) { + if (strncmp(link_val_buf, link_target_b, strlen(link_target_b) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 1, link_target_b); @@ -12544,7 +12519,7 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_soft_name_order_decreasing); } - if (HDstrncmp(link_val_buf, link_target_c, strlen(link_target_c) + 1)) { + if (strncmp(link_val_buf, link_target_c, strlen(link_target_c) + 1)) { H5_FAILED(); printf(" link value '%s' for link at index %d did not match expected value '%s'\n", link_val_buf, 0, link_target_c); @@ -12582,18 +12557,6 @@ test_get_link_val(void) PART_EMPTY(H5Lget_val_by_idx_external_crt_order_increasing); } - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_val_by_idx_external_crt_order_increasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_val_by_idx_external_crt_order_increasing); - } - if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_VAL_TEST_SUBGROUP8_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -12692,14 +12655,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_crt_order_increasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_crt_order_increasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_a, strlen(ext_obj_name_a) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_a, strlen(ext_obj_name_a) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_a); @@ -12737,14 +12700,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_crt_order_increasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_crt_order_increasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_b, strlen(ext_obj_name_b) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_b, strlen(ext_obj_name_b) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_b); @@ -12782,14 +12745,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_crt_order_increasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_crt_order_increasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_c, strlen(ext_obj_name_c) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_c, strlen(ext_obj_name_c) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_c); @@ -12810,8 +12773,6 @@ test_get_link_val(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -12829,18 +12790,6 @@ test_get_link_val(void) PART_EMPTY(H5Lget_val_by_idx_external_crt_order_decreasing); } - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_val_by_idx_external_crt_order_decreasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_val_by_idx_external_crt_order_decreasing); - } - if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_VAL_TEST_SUBGROUP9_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -12939,14 +12888,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_crt_order_decreasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_crt_order_decreasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_a, strlen(ext_obj_name_a) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_a, strlen(ext_obj_name_a) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_a); @@ -12984,14 +12933,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_crt_order_decreasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_crt_order_decreasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_b, strlen(ext_obj_name_b) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_b, strlen(ext_obj_name_b) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_b); @@ -13029,14 +12978,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_crt_order_decreasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_crt_order_decreasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_c, strlen(ext_obj_name_c) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_c, strlen(ext_obj_name_c) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_c); @@ -13057,8 +13006,6 @@ test_get_link_val(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -13070,18 +13017,6 @@ test_get_link_val(void) TESTING_2("H5Lget_val_by_idx on external link by alphabetical order in increasing order"); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_val_by_idx_external_name_order_increasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_val_by_idx_external_name_order_increasing); - } - if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_VAL_TEST_SUBGROUP10_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -13180,14 +13115,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_name_order_increasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_name_order_increasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_a, strlen(ext_obj_name_a) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_a, strlen(ext_obj_name_a) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_a); @@ -13225,14 +13160,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_name_order_increasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_name_order_increasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_b, strlen(ext_obj_name_b) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_b, strlen(ext_obj_name_b) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_b); @@ -13270,14 +13205,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_name_order_increasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_name_order_increasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_c, strlen(ext_obj_name_c) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_c, strlen(ext_obj_name_c) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_c); @@ -13298,8 +13233,6 @@ test_get_link_val(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -13307,21 +13240,9 @@ test_get_link_val(void) { const char *ext_obj_name_a = "/A"; const char *ext_obj_name_b = "/B"; - const char *ext_obj_name_c = "/C"; - - TESTING_2("H5Lget_val_by_idx on external link by alphabetical order in decreasing order"); - - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_val_by_idx_external_name_order_decreasing); - } + const char *ext_obj_name_c = "/C"; - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_val_by_idx_external_name_order_decreasing); - } + TESTING_2("H5Lget_val_by_idx on external link by alphabetical order in decreasing order"); if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_VAL_TEST_SUBGROUP11_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { @@ -13421,14 +13342,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_name_order_decreasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_name_order_decreasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_a, strlen(ext_obj_name_a) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_a, strlen(ext_obj_name_a) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_a); @@ -13466,14 +13387,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_name_order_decreasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_name_order_decreasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_b, strlen(ext_obj_name_b) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_b, strlen(ext_obj_name_b) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_b); @@ -13511,14 +13432,14 @@ test_get_link_val(void) PART_ERROR(H5Lget_val_by_idx_external_name_order_decreasing); } - if (HDstrncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { + if (strncmp(ext_link_filepath, ext_link_filename, strlen(ext_link_filename) + 1)) { H5_FAILED(); printf(" external link target file '%s' did not match expected '%s'\n", ext_link_filepath, ext_link_filename); PART_ERROR(H5Lget_val_by_idx_external_name_order_decreasing); } - if (HDstrncmp(ext_link_val, ext_obj_name_c, strlen(ext_obj_name_c) + 1)) { + if (strncmp(ext_link_val, ext_obj_name_c, strlen(ext_obj_name_c) + 1)) { H5_FAILED(); printf(" external link value '%s' did not match expected '%s'\n", ext_link_val, ext_obj_name_c); @@ -13539,8 +13460,6 @@ test_get_link_val(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -13620,10 +13539,12 @@ test_get_link_val(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -13634,18 +13555,19 @@ test_get_link_val(void) H5Gclose(container_group); H5Fclose(ext_file_id); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that a soft or external link's value can't be * retrieved when H5Lget_val(_by_idx) is passed invalid parameters. */ -static int +static void test_get_link_val_invalid_params(void) { H5L_info2_t link_info; @@ -13666,7 +13588,7 @@ test_get_link_val_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, link, soft link, external link, or creation " "order aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -13971,7 +13893,7 @@ test_get_link_val_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -13985,14 +13907,14 @@ test_get_link_val_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check the functionality of H5Lget_info2 and * H5Lget_info_by_idx2. */ -static int +static void test_get_link_info(void) { H5L_info2_t link_info; @@ -14001,9 +13923,9 @@ test_get_link_info(void) size_t link_val_size; hid_t file_id = H5I_INVALID_HID, ext_file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t subgroup_id = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t subgroup_id = H5I_INVALID_HID; + hid_t gcpl_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING_MULTIPART("link info retrieval"); @@ -14015,7 +13937,7 @@ test_get_link_info(void) SKIPPED(); printf(" API functions for basic file, group, link, soft link, hard link, or external link " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -14059,6 +13981,12 @@ test_get_link_info(void) goto error; } + if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); + goto error; + } + PASSED(); BEGIN_MULTIPART @@ -14223,18 +14151,6 @@ test_get_link_info(void) memset(&link_info, 0, sizeof(link_info)); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_info_external); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_info_external); - } - if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_INFO_TEST_SUBGROUP3_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -15786,18 +15702,6 @@ test_get_link_info(void) PART_EMPTY(H5Lget_info_by_idx_external_crt_order_increasing); } - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_info_by_idx_external_crt_order_increasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_info_by_idx_external_crt_order_increasing); - } - if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_INFO_TEST_SUBGROUP13_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -15987,18 +15891,6 @@ test_get_link_info(void) PART_EMPTY(H5Lget_info_by_idx_external_crt_order_decreasing); } - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_info_by_idx_external_crt_order_decreasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_info_by_idx_external_crt_order_decreasing); - } - if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_INFO_TEST_SUBGROUP14_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -16182,18 +16074,6 @@ test_get_link_info(void) { TESTING_2("H5Lget_info_by_idx2 on external link by alphabetical order in increasing order"); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_info_by_idx_external_name_order_increasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_info_by_idx_external_name_order_increasing); - } - if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_INFO_TEST_SUBGROUP15_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -16383,18 +16263,6 @@ test_get_link_info(void) { TESTING_2("H5Lget_info_by_idx2 on external link by alphabetical order in decreasing order"); - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_info_by_idx_external_name_order_decreasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_info_by_idx_external_name_order_decreasing); - } - if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_INFO_TEST_SUBGROUP16_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -16656,10 +16524,12 @@ test_get_link_info(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -16670,18 +16540,19 @@ test_get_link_info(void) H5Gclose(container_group); H5Fclose(ext_file_id); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that a link's info can't be retrieved * when H5Lget_info(_by_idx)2 is passed invalid parameters. */ -static int +static void test_get_link_info_invalid_params(void) { H5L_info2_t link_info; @@ -16700,7 +16571,7 @@ test_get_link_info_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, link, or hard link " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -16994,7 +16865,7 @@ test_get_link_info_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -17006,14 +16877,14 @@ test_get_link_info_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that a link's name can be correctly * retrieved by using H5Lget_name_by_idx. */ -static int +static void test_get_link_name(void) { ssize_t link_name_buf_size = 0; @@ -17023,7 +16894,7 @@ test_get_link_name(void) hid_t subgroup_id = H5I_INVALID_HID; hid_t gcpl_id = H5I_INVALID_HID; char link_name_buf[GET_LINK_NAME_TEST_BUF_SIZE]; - char *ext_link_filename = NULL; + char *ext_link_filename = NULL; TESTING_MULTIPART("link name retrieval"); @@ -17035,7 +16906,7 @@ test_get_link_name(void) SKIPPED(); printf(" API functions for basic file, group, link, soft link, hard link, or external link " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -17079,6 +16950,19 @@ test_get_link_name(void) goto error; } + /* Create file for external link to reference */ + if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); + goto error; + } + + if (H5Fclose(ext_file_id) < 0) { + H5_FAILED(); + printf(" couldn't close file '%s'\n", ext_link_filename); + goto error; + } + PASSED(); BEGIN_MULTIPART @@ -17182,8 +17066,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_crt_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3); @@ -17204,8 +17088,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_crt_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2); @@ -17226,8 +17110,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_crt_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME); @@ -17350,8 +17234,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_crt_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME); @@ -17372,8 +17256,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_crt_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2); @@ -17394,8 +17278,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_crt_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3); @@ -17512,8 +17396,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_name_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME); @@ -17534,8 +17418,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_name_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2); @@ -17556,8 +17440,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_name_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3); @@ -17674,8 +17558,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_name_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME3); @@ -17696,8 +17580,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_name_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME2); @@ -17718,8 +17602,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_hard_name_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME, - strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME, + strlen(GET_LINK_NAME_TEST_HARD_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_HARD_LINK_NAME); @@ -17842,8 +17726,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_crt_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3); @@ -17864,8 +17748,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_crt_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2); @@ -17886,8 +17770,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_crt_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME); @@ -18010,8 +17894,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_crt_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME); @@ -18032,8 +17916,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_crt_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2); @@ -18054,8 +17938,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_crt_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3); @@ -18172,8 +18056,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_name_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME); @@ -18194,8 +18078,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_name_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2); @@ -18216,8 +18100,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_name_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3); @@ -18334,8 +18218,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_name_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME3); @@ -18356,8 +18240,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_name_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME2); @@ -18378,8 +18262,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_soft_name_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME, - strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME, + strlen(GET_LINK_NAME_TEST_SOFT_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_SOFT_LINK_NAME); @@ -18413,19 +18297,6 @@ test_get_link_name(void) PART_EMPTY(H5Lget_name_by_idx_external_crt_order_increasing); } - /* Create file for external link to reference */ - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_name_by_idx_external_crt_order_increasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_name_by_idx_external_crt_order_increasing); - } - /* Create group to hold some links */ if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_NAME_TEST_EXTERNAL_SUBGROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { @@ -18518,8 +18389,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_crt_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3); @@ -18540,8 +18411,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_crt_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2); @@ -18562,8 +18433,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_crt_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME); @@ -18584,8 +18455,6 @@ test_get_link_name(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -18599,19 +18468,6 @@ test_get_link_name(void) PART_EMPTY(H5Lget_name_by_idx_external_crt_order_decreasing); } - /* Create file for external link to reference */ - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_name_by_idx_external_crt_order_decreasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_name_by_idx_external_crt_order_decreasing); - } - /* Create group to hold some links */ if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_NAME_TEST_EXTERNAL_SUBGROUP_NAME2, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { @@ -18704,8 +18560,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_crt_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME); @@ -18726,8 +18582,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_crt_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2); @@ -18748,8 +18604,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_crt_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3); @@ -18770,8 +18626,6 @@ test_get_link_name(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -18779,19 +18633,6 @@ test_get_link_name(void) { TESTING_2("H5Lget_name_by_idx on external link by alphabetical order in increasing order"); - /* Create file for external link to reference */ - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_name_by_idx_external_name_order_increasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_name_by_idx_external_name_order_increasing); - } - /* Create group to hold some links */ if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_NAME_TEST_EXTERNAL_SUBGROUP_NAME3, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { @@ -18884,8 +18725,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_name_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME); @@ -18906,8 +18747,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_name_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2); @@ -18928,8 +18769,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_name_order_increasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3); @@ -18950,8 +18791,6 @@ test_get_link_name(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -18959,19 +18798,6 @@ test_get_link_name(void) { TESTING_2("H5Lget_name_by_idx on external link by alphabetical order in decreasing order"); - /* Create file for external link to reference */ - if ((ext_file_id = H5Fcreate(ext_link_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - printf(" couldn't create file '%s' for external link to reference\n", ext_link_filename); - PART_ERROR(H5Lget_name_by_idx_external_name_order_decreasing); - } - - if (H5Fclose(ext_file_id) < 0) { - H5_FAILED(); - printf(" couldn't close file '%s'\n", ext_link_filename); - PART_ERROR(H5Lget_name_by_idx_external_name_order_decreasing); - } - /* Create group to hold some links */ if ((subgroup_id = H5Gcreate2(group_id, GET_LINK_NAME_TEST_EXTERNAL_SUBGROUP_NAME4, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { @@ -19064,8 +18890,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_name_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME3); @@ -19086,8 +18912,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_name_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME2); @@ -19108,8 +18934,8 @@ test_get_link_name(void) PART_ERROR(H5Lget_name_by_idx_external_name_order_decreasing); } - if (HDstrncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME, - strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME) + 1)) { + if (strncmp(link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME, + strlen(GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME) + 1)) { H5_FAILED(); printf(" link name '%s' did not match expected name '%s'\n", link_name_buf, GET_LINK_NAME_TEST_EXTERNAL_LINK_NAME); @@ -19130,8 +18956,6 @@ test_get_link_name(void) { H5Gclose(subgroup_id); subgroup_id = H5I_INVALID_HID; - H5Fclose(ext_file_id); - ext_file_id = H5I_INVALID_HID; } H5E_END_TRY @@ -19219,10 +19043,12 @@ test_get_link_name(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -19233,18 +19059,19 @@ test_get_link_name(void) H5Gclose(container_group); H5Fclose(ext_file_id); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that a link's name can't be retrieved * when H5Lget_name_by_idx is passed invalid parameters. */ -static int +static void test_get_link_name_invalid_params(void) { ssize_t ret; @@ -19265,7 +19092,7 @@ test_get_link_name_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, link, soft link, hard link, or external link " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -19487,7 +19314,7 @@ test_get_link_name_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -19500,7 +19327,7 @@ test_get_link_name_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* @@ -19510,7 +19337,7 @@ test_get_link_name_invalid_params(void) * increasing and decreasing order of both link * name and link creation order. */ -static int +static void test_link_iterate_hard_links(void) { size_t i; @@ -19531,7 +19358,7 @@ test_link_iterate_hard_links(void) SKIPPED(); printf(" API functions for basic file, group, dataset, link, or iterate aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -19569,19 +19396,19 @@ test_link_iterate_hard_links(void) goto error; } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_dspace = - generate_random_dataspace(LINK_ITER_HARD_LINKS_TEST_DSET_SPACE_RANK, NULL, NULL, FALSE)) < 0) + generate_random_dataspace(LINK_ITER_HARD_LINKS_TEST_DSET_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; for (i = 0; i < LINK_ITER_HARD_LINKS_TEST_NUM_LINKS; i++) { char dset_name[LINK_ITER_HARD_LINKS_TEST_BUF_SIZE]; /* Create the datasets with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(dset_name, LINK_ITER_HARD_LINKS_TEST_BUF_SIZE, LINK_ITER_HARD_LINKS_TEST_LINK_NAME "%d", - (int)(LINK_ITER_HARD_LINKS_TEST_NUM_LINKS - i - 1)); + snprintf(dset_name, LINK_ITER_HARD_LINKS_TEST_BUF_SIZE, LINK_ITER_HARD_LINKS_TEST_LINK_NAME "%d", + (int)(LINK_ITER_HARD_LINKS_TEST_NUM_LINKS - i - 1)); if ((dset_id = H5Dcreate2(group_id, dset_name, dset_dtype, dset_dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -19625,6 +19452,14 @@ test_link_iterate_hard_links(void) { TESTING_2("H5Literate2 by link name in increasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { + SKIPPED(); + printf(" API functions for external or user-defined link aren't supported with this " + "connector\n"); + PART_EMPTY(H5Literate_link_name_increasing); + } + i = 0; /* Test basic link iteration capability using both index types and both index orders */ @@ -19858,7 +19693,7 @@ test_link_iterate_hard_links(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -19873,7 +19708,7 @@ test_link_iterate_hard_links(void) } H5E_END_TRY - return 1; + return; } /* @@ -19883,7 +19718,7 @@ test_link_iterate_hard_links(void) * increasing and decreasing order of both link * name and link creation order. */ -static int +static void test_link_iterate_soft_links(void) { size_t i; @@ -19901,7 +19736,7 @@ test_link_iterate_soft_links(void) SKIPPED(); printf(" API functions for basic file, group, link, soft link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -19944,11 +19779,11 @@ test_link_iterate_soft_links(void) char link_target[LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE]; /* Create the links with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(link_name, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE, LINK_ITER_SOFT_LINKS_TEST_LINK_NAME "%d", - (int)(LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS - i - 1)); + snprintf(link_name, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE, LINK_ITER_SOFT_LINKS_TEST_LINK_NAME "%d", + (int)(LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS - i - 1)); - HDsnprintf(link_target, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE, "target%d", - (int)(LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS - i - 1)); + snprintf(link_target, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE, "target%d", + (int)(LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS - i - 1)); if (H5Lcreate_soft(link_target, group_id, link_name, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); @@ -20214,7 +20049,7 @@ test_link_iterate_soft_links(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -20226,7 +20061,7 @@ test_link_iterate_soft_links(void) } H5E_END_TRY - return 1; + return; } /* @@ -20236,15 +20071,15 @@ test_link_iterate_soft_links(void) * increasing and decreasing order of both link * name and link creation order. */ -static int +static void test_link_iterate_external_links(void) { size_t i; htri_t link_exists; hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t gcpl_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING_MULTIPART("link iteration (only external links)"); @@ -20255,7 +20090,7 @@ test_link_iterate_external_links(void) SKIPPED(); printf(" API functions for basic file, group, link, external link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -20312,8 +20147,8 @@ test_link_iterate_external_links(void) char link_name[LINK_ITER_EXT_LINKS_TEST_BUF_SIZE]; /* Create the links with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(link_name, LINK_ITER_EXT_LINKS_TEST_BUF_SIZE, LINK_ITER_EXT_LINKS_TEST_LINK_NAME "%d", - (int)(LINK_ITER_EXT_LINKS_TEST_NUM_LINKS - i - 1)); + snprintf(link_name, LINK_ITER_EXT_LINKS_TEST_BUF_SIZE, LINK_ITER_EXT_LINKS_TEST_LINK_NAME "%d", + (int)(LINK_ITER_EXT_LINKS_TEST_NUM_LINKS - i - 1)); if (H5Lcreate_external(ext_link_filename, "/", group_id, link_name, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); @@ -20350,6 +20185,12 @@ test_link_iterate_external_links(void) { TESTING_2("H5Literate2 by link name in increasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS)) { + SKIPPED(); + printf(" external link API is not supported with this VOL connector\n"); + PART_EMPTY(H5Literate_link_name_increasing); + } + i = 0; /* Test basic link iteration capability using both index types and both index orders */ @@ -20374,6 +20215,12 @@ test_link_iterate_external_links(void) { TESTING_2("H5Literate2 by link name in decreasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS)) { + SKIPPED(); + printf(" external link API is not supported with this VOL connector\n"); + PART_EMPTY(H5Literate_link_name_decreasing); + } + /* Reset the counter to the appropriate value for the next test */ i = LINK_ITER_EXT_LINKS_TEST_NUM_LINKS; @@ -20398,9 +20245,11 @@ test_link_iterate_external_links(void) { TESTING_2("H5Literate2 by creation order in increasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking or the external link API aren't supported with this VOL " + "connector\n"); PART_EMPTY(H5Literate_link_creation_increasing); } @@ -20428,9 +20277,11 @@ test_link_iterate_external_links(void) { TESTING_2("H5Literate2 by creation order in decreasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking or the external link API aren't supported with this VOL " + "connector\n"); PART_EMPTY(H5Literate_link_creation_decreasing); } @@ -20458,6 +20309,12 @@ test_link_iterate_external_links(void) { TESTING_2("H5Literate_by_name2 by link name in increasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS)) { + SKIPPED(); + printf(" the external link API is not supported with this VOL connector\n"); + PART_EMPTY(H5Literate_by_name_link_name_increasing); + } + /* Reset the counter to the appropriate value for the next test */ i = 0; @@ -20483,6 +20340,13 @@ test_link_iterate_external_links(void) { TESTING_2("H5Literate_by_name2 by link name in decreasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS)) { + SKIPPED(); + printf(" creation order tracking or the external link API aren't supported with this VOL " + "connector\n"); + PART_EMPTY(H5Literate_by_name_creation_decreasing); + } + /* Reset the counter to the appropriate value for the next test */ i = LINK_ITER_EXT_LINKS_TEST_NUM_LINKS; @@ -20508,9 +20372,11 @@ test_link_iterate_external_links(void) { TESTING_2("H5Literate_by_name2 by creation order in increasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking or the external link API aren't supported with this VOL " + "connector\n"); PART_EMPTY(H5Literate_by_name_creation_increasing); } @@ -20540,9 +20406,11 @@ test_link_iterate_external_links(void) { TESTING_2("H5Literate_by_name2 by creation order in decreasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking or the external link API are not supported with this VOL " + "connector\n"); PART_EMPTY(H5Literate_by_name_creation_decreasing); } @@ -20580,10 +20448,12 @@ test_link_iterate_external_links(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -20592,11 +20462,12 @@ test_link_iterate_external_links(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* @@ -20609,14 +20480,14 @@ test_link_iterate_external_links(void) * TODO refactor test so that creation order tests * actually test the order that objects were created in. */ -static int +static void test_link_iterate_ud_links(void) { TESTING("link iteration (only user-defined links)"); SKIPPED(); - return 1; + return; } /* @@ -20633,7 +20504,7 @@ test_link_iterate_ud_links(void) * * TODO refactor link saving portion into its own test */ -static int +static void test_link_iterate_mixed_links(void) { hsize_t saved_idx; @@ -20646,7 +20517,7 @@ test_link_iterate_mixed_links(void) hid_t dset_dtype = H5I_INVALID_HID; hid_t dset_dspace = H5I_INVALID_HID; int halted; - char *ext_link_filename = NULL; + char *ext_link_filename = NULL; TESTING_MULTIPART("link iteration (mixed link types)"); @@ -20657,7 +20528,7 @@ test_link_iterate_mixed_links(void) SKIPPED(); printf(" API functions for basic file, group, link, soft link, external link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -20710,11 +20581,11 @@ test_link_iterate_mixed_links(void) goto error; } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_dspace = - generate_random_dataspace(LINK_ITER_MIXED_LINKS_TEST_DSET_SPACE_RANK, NULL, NULL, FALSE)) < 0) + generate_random_dataspace(LINK_ITER_MIXED_LINKS_TEST_DSET_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, LINK_ITER_MIXED_LINKS_TEST_HARD_LINK_NAME, dset_dtype, dset_dspace, @@ -20791,6 +20662,14 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate2 by link name in increasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { + SKIPPED(); + printf(" creation order tracking, external links, or user-defined links aren't supported " + "with this VOL connector\n"); + PART_EMPTY(H5Literate_link_name_increasing); + } + i = 0; /* Test basic link iteration capability using both index types and both index orders */ @@ -20814,6 +20693,14 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate2 by link name in decreasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { + SKIPPED(); + printf(" creation order tracking, external links, or user-defined links aren't supported " + "with this VOL connector\n"); + PART_EMPTY(H5Literate_link_name_decreasing); + } + /* Reset the counter to the appropriate value for the next test */ i = LINK_ITER_MIXED_LINKS_TEST_NUM_LINKS; @@ -20837,9 +20724,12 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate2 by creation order in increasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking, external links, or user-defined links aren't supported " + "with this VOL connector\n"); PART_EMPTY(H5Literate_link_creation_increasing); } @@ -20867,9 +20757,12 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate2 by creation order in decreasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking, external links, or user-defined links aren't supported " + "with this VOL connector\n"); PART_EMPTY(H5Literate_link_creation_decreasing); } @@ -20897,6 +20790,13 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate_by_name2 by link name in increasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { + SKIPPED(); + printf(" external links or user-defined links aren't supported with this VOL connector\n"); + PART_EMPTY(H5Literate_by_name_link_name_increasing); + } + i = 0; if (H5Literate_by_name2( @@ -20921,6 +20821,13 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate_by_name2 by link name in decreasing order"); + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { + SKIPPED(); + printf(" external links or user-defined links aren't supported with this VOL connector\n"); + PART_EMPTY(H5Literate_by_name_link_name_decreasing); + } + /* Reset the counter to the appropriate value for the next test */ i = LINK_ITER_MIXED_LINKS_TEST_NUM_LINKS; @@ -20946,9 +20853,12 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate_by_name2 by creation order in increasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking, external links, or user-defined links aren't supported " + "with this VOL connector\n"); PART_EMPTY(H5Literate_by_name_creation_increasing); } @@ -20977,9 +20887,12 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate_by_name2 by creation order in decreasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking, external links, or user-defined links aren't supported " + "with this VOL connector\n"); PART_EMPTY(H5Literate_by_name_creation_decreasing); } @@ -21008,9 +20921,12 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate2 index-saving capabilities in increasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking, external links, or user-defined links aren't supported " + "with this VOL connector\n"); PART_EMPTY(H5Literate_index_saving_increasing); } @@ -21046,9 +20962,12 @@ test_link_iterate_mixed_links(void) { TESTING_2("H5Literate2 index-saving capabilities in decreasing order"); - if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER)) { + if (!(vol_cap_flags_g & H5VL_CAP_FLAG_CREATION_ORDER) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || + !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { SKIPPED(); - printf(" creation order tracking isn't supported with this VOL connector\n"); + printf(" creation order tracking, external links, or user-defined links aren't supported " + "with this VOL connector\n"); PART_EMPTY(H5Literate_index_saving_decreasing); } @@ -21098,10 +21017,12 @@ test_link_iterate_mixed_links(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -21113,30 +21034,31 @@ test_link_iterate_mixed_links(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Literate(_by_name)2 fails * when given invalid parameters. */ -static int +static void test_link_iterate_invalid_params(void) { herr_t err_ret = -1; size_t i; htri_t link_exists; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID; - hid_t group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t dset_dtype = H5I_INVALID_HID; - hid_t dset_dspace = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t file_id = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID; + hid_t group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dset_dtype = H5I_INVALID_HID; + hid_t dset_dspace = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING_MULTIPART("link iteration with invalid parameters"); @@ -21148,7 +21070,7 @@ test_link_iterate_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, dataset, link, soft link, external link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -21187,11 +21109,11 @@ test_link_iterate_invalid_params(void) goto error; } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_dspace = - generate_random_dataspace(LINK_ITER_INVALID_PARAMS_TEST_DSET_SPACE_RANK, NULL, NULL, FALSE)) < 0) + generate_random_dataspace(LINK_ITER_INVALID_PARAMS_TEST_DSET_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, LINK_ITER_INVALID_PARAMS_TEST_HARD_LINK_NAME, dset_dtype, dset_dspace, @@ -21513,10 +21435,12 @@ test_link_iterate_invalid_params(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -21527,18 +21451,19 @@ test_link_iterate_invalid_params(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that link iteration performed on a * group with no links in it is not problematic. */ -static int +static void test_link_iterate_0_links(void) { hid_t file_id = H5I_INVALID_HID; @@ -21553,7 +21478,7 @@ test_link_iterate_0_links(void) SKIPPED(); printf(" API functions for basic file, group, or iterate aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -21757,7 +21682,7 @@ test_link_iterate_0_links(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -21769,7 +21694,7 @@ test_link_iterate_0_links(void) } H5E_END_TRY - return 1; + return; } /* @@ -21780,7 +21705,7 @@ test_link_iterate_0_links(void) * decreasing order of both link name and link * creation order. */ -static int +static void test_link_visit_hard_links_no_cycles(void) { size_t i; @@ -21801,7 +21726,7 @@ test_link_visit_hard_links_no_cycles(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or link iterate aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -21840,11 +21765,11 @@ test_link_visit_hard_links_no_cycles(void) goto error; } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_dspace = generate_random_dataspace(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_DSET_SPACE_RANK, NULL, - NULL, FALSE)) < 0) + NULL, false)) < 0) TEST_ERROR; for (i = 0; i < LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS; i++) { @@ -21852,9 +21777,9 @@ test_link_visit_hard_links_no_cycles(void) char grp_name[LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE]; /* Create the groups with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(grp_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); + snprintf(grp_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); if ((subgroup_id = H5Gcreate2(group_id, grp_name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -21866,9 +21791,9 @@ test_link_visit_hard_links_no_cycles(void) char dset_name[LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE]; /* Create the datasets with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(dset_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); + snprintf(dset_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); if ((dset_id = H5Dcreate2(subgroup_id, dset_name, dset_dtype, dset_dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -22153,7 +22078,7 @@ test_link_visit_hard_links_no_cycles(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -22169,7 +22094,7 @@ test_link_visit_hard_links_no_cycles(void) } H5E_END_TRY - return 1; + return; } /* @@ -22180,7 +22105,7 @@ test_link_visit_hard_links_no_cycles(void) * decreasing order of both link name and link * creation order. */ -static int +static void test_link_visit_soft_links_no_cycles(void) { size_t i; @@ -22199,7 +22124,7 @@ test_link_visit_soft_links_no_cycles(void) SKIPPED(); printf(" API functions for basic file, group, link, soft link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -22243,9 +22168,9 @@ test_link_visit_soft_links_no_cycles(void) char grp_name[LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE]; /* Create the groups with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(grp_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); + snprintf(grp_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); if ((subgroup_id = H5Gcreate2(group_id, grp_name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -22258,12 +22183,12 @@ test_link_visit_soft_links_no_cycles(void) char link_target[LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE]; /* Create the links with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); + snprintf(link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); - HDsnprintf(link_target, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, "target%d", - (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); + snprintf(link_target, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, "target%d", + (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); if (H5Lcreate_soft(link_target, subgroup_id, link_name, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); @@ -22536,7 +22461,7 @@ test_link_visit_soft_links_no_cycles(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -22549,7 +22474,7 @@ test_link_visit_soft_links_no_cycles(void) } H5E_END_TRY - return 1; + return; } /* @@ -22560,16 +22485,16 @@ test_link_visit_soft_links_no_cycles(void) * decreasing order of both link name and link * creation order. */ -static int +static void test_link_visit_external_links_no_cycles(void) { size_t i; htri_t link_exists; hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t subgroup_id = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t subgroup_id = H5I_INVALID_HID; + hid_t gcpl_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING_MULTIPART("link visiting without cycles (only external links)"); @@ -22580,7 +22505,7 @@ test_link_visit_external_links_no_cycles(void) SKIPPED(); printf(" API functions for basic file, group, link, external link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -22639,9 +22564,9 @@ test_link_visit_external_links_no_cycles(void) char grp_name[LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE]; /* Create the groups with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(grp_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); + snprintf(grp_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); if ((subgroup_id = H5Gcreate2(group_id, grp_name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -22653,9 +22578,9 @@ test_link_visit_external_links_no_cycles(void) char link_name[LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE]; /* Create the links with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); + snprintf(link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); if (H5Lcreate_external(ext_link_filename, "/", subgroup_id, link_name, H5P_DEFAULT, H5P_DEFAULT) < 0) { @@ -22931,10 +22856,12 @@ test_link_visit_external_links_no_cycles(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -22944,11 +22871,12 @@ test_link_visit_external_links_no_cycles(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* @@ -22962,14 +22890,14 @@ test_link_visit_external_links_no_cycles(void) * TODO refactor test so that creation order tests * actually test the order that objects were created in. */ -static int +static void test_link_visit_ud_links_no_cycles(void) { TESTING("link visiting without cycles (only user-defined links)"); SKIPPED(); - return 1; + return; } /* @@ -22987,7 +22915,7 @@ test_link_visit_ud_links_no_cycles(void) * * TODO refactor test to create a macroed number of subgroups */ -static int +static void test_link_visit_mixed_links_no_cycles(void) { size_t i; @@ -22995,11 +22923,11 @@ test_link_visit_mixed_links_no_cycles(void) hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t subgroup1 = H5I_INVALID_HID, subgroup2 = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t dset_dtype = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t gcpl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dset_dtype = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING_MULTIPART("link visiting without cycles (mixed link types)"); @@ -23013,7 +22941,7 @@ test_link_visit_mixed_links_no_cycles(void) printf( " API functions for basic file, group, link, hard link, soft link, external link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -23083,11 +23011,11 @@ test_link_visit_mixed_links_no_cycles(void) goto error; } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((fspace_id = generate_random_dataspace(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_SPACE_RANK, NULL, - NULL, FALSE)) < 0) + NULL, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(subgroup1, LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_NAME, dset_dtype, @@ -23445,10 +23373,12 @@ test_link_visit_mixed_links_no_cycles(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -23462,11 +23392,12 @@ test_link_visit_mixed_links_no_cycles(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* @@ -23476,7 +23407,7 @@ test_link_visit_mixed_links_no_cycles(void) * Iteration is done in increasing and decreasing * order of both link name and link creation order. */ -static int +static void test_link_visit_hard_links_cycles(void) { size_t i; @@ -23495,7 +23426,7 @@ test_link_visit_hard_links_cycles(void) SKIPPED(); printf(" API functions for basic file, group, link, hard link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -23539,9 +23470,9 @@ test_link_visit_hard_links_cycles(void) char grp_name[LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE]; /* Create the groups with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(grp_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); + snprintf(grp_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); if ((subgroup_id = H5Gcreate2(group_id, grp_name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -23553,9 +23484,9 @@ test_link_visit_hard_links_cycles(void) char link_name[LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE]; /* Create the links with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); + snprintf(link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); if (H5Lcreate_hard(subgroup_id, ".", subgroup_id, link_name, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); @@ -23826,7 +23757,7 @@ test_link_visit_hard_links_cycles(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -23839,7 +23770,7 @@ test_link_visit_hard_links_cycles(void) } H5E_END_TRY - return 1; + return; } /* @@ -23849,7 +23780,7 @@ test_link_visit_hard_links_cycles(void) * Iteration is done in increasing and decreasing * order of both link name and link creation order. */ -static int +static void test_link_visit_soft_links_cycles(void) { size_t i; @@ -23868,7 +23799,7 @@ test_link_visit_soft_links_cycles(void) SKIPPED(); printf(" API functions for basic file, group, link, soft link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -23912,9 +23843,9 @@ test_link_visit_soft_links_cycles(void) char grp_name[LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE]; /* Create the groups with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(grp_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); + snprintf(grp_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); if ((subgroup_id = H5Gcreate2(group_id, grp_name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -23927,13 +23858,13 @@ test_link_visit_soft_links_cycles(void) char link_target[2 * LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE]; /* Create the links with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); + snprintf(link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); - HDsnprintf(link_target, 2 * LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, - "/" LINK_TEST_GROUP_NAME "/" LINK_VISIT_SOFT_LINKS_CYCLE_TEST_SUBGROUP_NAME "/%s", - grp_name); + snprintf(link_target, 2 * LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, + "/" LINK_TEST_GROUP_NAME "/" LINK_VISIT_SOFT_LINKS_CYCLE_TEST_SUBGROUP_NAME "/%s", + grp_name); if (H5Lcreate_soft(link_target, subgroup_id, link_name, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); @@ -24205,7 +24136,7 @@ test_link_visit_soft_links_cycles(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -24218,7 +24149,7 @@ test_link_visit_soft_links_cycles(void) } H5E_END_TRY - return 1; + return; } /* @@ -24229,7 +24160,7 @@ test_link_visit_soft_links_cycles(void) * decreasing order of both link name and link * creation order. */ -static int +static void test_link_visit_external_links_cycles(void) { size_t i; @@ -24248,7 +24179,7 @@ test_link_visit_external_links_cycles(void) SKIPPED(); printf(" API functions for basic file, group, link, external link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -24292,9 +24223,9 @@ test_link_visit_external_links_cycles(void) char grp_name[LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE]; /* Create the groups with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(grp_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); + snprintf(grp_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - i - 1)); if ((subgroup_id = H5Gcreate2(group_id, grp_name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -24307,13 +24238,13 @@ test_link_visit_external_links_cycles(void) char link_target_obj[2 * LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE]; /* Create the links with a reverse-ordering naming scheme to test creation order later */ - HDsnprintf(link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); + snprintf(link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - j - 1)); - HDsnprintf(link_target_obj, 2 * LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, - "/" LINK_TEST_GROUP_NAME "/" LINK_VISIT_EXT_LINKS_CYCLE_TEST_SUBGROUP_NAME "/%s", - grp_name); + snprintf(link_target_obj, 2 * LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, + "/" LINK_TEST_GROUP_NAME "/" LINK_VISIT_EXT_LINKS_CYCLE_TEST_SUBGROUP_NAME "/%s", + grp_name); if (H5Lcreate_external(H5_API_TEST_FILENAME, link_target_obj, subgroup_id, link_name, H5P_DEFAULT, H5P_DEFAULT) < 0) { @@ -24590,7 +24521,7 @@ test_link_visit_external_links_cycles(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -24603,7 +24534,7 @@ test_link_visit_external_links_cycles(void) } H5E_END_TRY - return 1; + return; } /* @@ -24617,14 +24548,14 @@ test_link_visit_external_links_cycles(void) * TODO refactor test so that creation order tests * actually test the order that objects were created in. */ -static int +static void test_link_visit_ud_links_cycles(void) { TESTING("link visiting with cycles (only user-defined links)"); SKIPPED(); - return 1; + return; } /* @@ -24637,7 +24568,7 @@ test_link_visit_ud_links_cycles(void) * TODO refactor test so that creation order tests * actually test the order that objects were created in. */ -static int +static void test_link_visit_mixed_links_cycles(void) { htri_t link_exists; @@ -24645,8 +24576,9 @@ test_link_visit_mixed_links_cycles(void) hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t subgroup1 = H5I_INVALID_HID, subgroup2 = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t gcpl_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; + TESTING_MULTIPART("link visiting with cycles (mixed link types)"); /* Make sure the connector supports the API functions being tested */ @@ -24657,14 +24589,14 @@ test_link_visit_mixed_links_cycles(void) SKIPPED(); printf(" API functions for basic file, group, link, hard link, soft link, external link, iterate, " "or user defined link aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); - printf(" couldn't create external link test file name\n"); + printf(" couldn't create external link filename\n"); goto error; } @@ -25052,10 +24984,12 @@ test_link_visit_mixed_links_cycles(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -25066,18 +25000,19 @@ test_link_visit_mixed_links_cycles(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Lvisit(_by_name)2 fails when * it is given invalid parameters. */ -static int +static void test_link_visit_invalid_params(void) { herr_t err_ret = -1; @@ -25085,10 +25020,10 @@ test_link_visit_invalid_params(void) hid_t file_id = H5I_INVALID_HID; hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t subgroup1 = H5I_INVALID_HID, subgroup2 = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t dset_dtype = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; - char *ext_link_filename = NULL; + hid_t dset_id = H5I_INVALID_HID; + hid_t dset_dtype = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + char *ext_link_filename = NULL; TESTING_MULTIPART("link visiting with invalid parameters"); @@ -25099,14 +25034,14 @@ test_link_visit_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, dataset, link, external link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); - printf(" couldn't create external link test file name\n"); + printf(" couldn't create external link filename\n"); goto error; } @@ -25152,11 +25087,11 @@ test_link_visit_invalid_params(void) goto error; } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((fspace_id = generate_random_dataspace(LINK_VISIT_INVALID_PARAMS_TEST_DSET_SPACE_RANK, NULL, NULL, - FALSE)) < 0) + false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(subgroup1, LINK_VISIT_INVALID_PARAMS_TEST_DSET_NAME, dset_dtype, fspace_id, @@ -25516,10 +25451,12 @@ test_link_visit_invalid_params(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + if (remove_test_file(NULL, ext_link_filename) < 0) + TEST_ERROR; free(ext_link_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -25532,11 +25469,12 @@ test_link_visit_invalid_params(void) H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + remove_test_file(NULL, ext_link_filename); free(ext_link_filename); } H5E_END_TRY - return 1; + return; } /* @@ -25544,7 +25482,7 @@ test_link_visit_invalid_params(void) * performed on a group with no links in it is * not problematic. */ -static int +static void test_link_visit_0_links(void) { hid_t file_id = H5I_INVALID_HID; @@ -25559,7 +25497,7 @@ test_link_visit_0_links(void) SKIPPED(); printf(" API functions for basic file, group, or link iterate aren't supported " "with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -25758,7 +25696,7 @@ test_link_visit_0_links(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -25770,7 +25708,7 @@ test_link_visit_0_links(void) } H5E_END_TRY - return 1; + return; } /* @@ -25810,18 +25748,18 @@ link_iter_hard_links_cb(hid_t group_id, const char *name, const H5L_info2_t *inf */ test_iteration = (counter_val / LINK_ITER_HARD_LINKS_TEST_NUM_LINKS); if (test_iteration == 0 || test_iteration == 3) { - HDsnprintf(expected_link_name, LINK_ITER_HARD_LINKS_TEST_BUF_SIZE, - LINK_ITER_HARD_LINKS_TEST_LINK_NAME "%d", - (int)(counter_val % LINK_ITER_HARD_LINKS_TEST_NUM_LINKS)); + snprintf(expected_link_name, LINK_ITER_HARD_LINKS_TEST_BUF_SIZE, + LINK_ITER_HARD_LINKS_TEST_LINK_NAME "%d", + (int)(counter_val % LINK_ITER_HARD_LINKS_TEST_NUM_LINKS)); } else { - HDsnprintf(expected_link_name, LINK_ITER_HARD_LINKS_TEST_BUF_SIZE, - LINK_ITER_HARD_LINKS_TEST_LINK_NAME "%d", - (int)(LINK_ITER_HARD_LINKS_TEST_NUM_LINKS - - (counter_val % LINK_ITER_HARD_LINKS_TEST_NUM_LINKS) - 1)); + snprintf(expected_link_name, LINK_ITER_HARD_LINKS_TEST_BUF_SIZE, + LINK_ITER_HARD_LINKS_TEST_LINK_NAME "%d", + (int)(LINK_ITER_HARD_LINKS_TEST_NUM_LINKS - + (counter_val % LINK_ITER_HARD_LINKS_TEST_NUM_LINKS) - 1)); } - if (HDstrncmp(name, expected_link_name, LINK_ITER_HARD_LINKS_TEST_BUF_SIZE)) { + if (strncmp(name, expected_link_name, LINK_ITER_HARD_LINKS_TEST_BUF_SIZE)) { printf(" link name '%s' didn't match expected name '%s'\n", name, expected_link_name); ret_val = H5_ITER_ERROR; goto done; @@ -25870,18 +25808,18 @@ link_iter_soft_links_cb(hid_t group_id, const char *name, const H5L_info2_t *inf */ test_iteration = (counter_val / LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS); if (test_iteration == 0 || test_iteration == 3) { - HDsnprintf(expected_link_name, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE, - LINK_ITER_SOFT_LINKS_TEST_LINK_NAME "%d", - (int)(counter_val % LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS)); + snprintf(expected_link_name, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE, + LINK_ITER_SOFT_LINKS_TEST_LINK_NAME "%d", + (int)(counter_val % LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS)); } else { - HDsnprintf(expected_link_name, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE, - LINK_ITER_SOFT_LINKS_TEST_LINK_NAME "%d", - (int)(LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS - - (counter_val % LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS) - 1)); + snprintf(expected_link_name, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE, + LINK_ITER_SOFT_LINKS_TEST_LINK_NAME "%d", + (int)(LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS - + (counter_val % LINK_ITER_SOFT_LINKS_TEST_NUM_LINKS) - 1)); } - if (HDstrncmp(name, expected_link_name, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE)) { + if (strncmp(name, expected_link_name, LINK_ITER_SOFT_LINKS_TEST_BUF_SIZE)) { printf(" link name '%s' didn't match expected name '%s'\n", name, expected_link_name); ret_val = H5_ITER_ERROR; goto done; @@ -25908,7 +25846,6 @@ link_iter_external_links_cb(hid_t group_id, const char *name, const H5L_info2_t herr_t ret_val = H5_ITER_CONT; if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS)) { - SKIPPED(); printf(" API functions for external links aren't supported with this " "connector\n"); return 1; @@ -25937,18 +25874,18 @@ link_iter_external_links_cb(hid_t group_id, const char *name, const H5L_info2_t */ test_iteration = (counter_val / LINK_ITER_EXT_LINKS_TEST_NUM_LINKS); if (test_iteration == 0 || test_iteration == 3) { - HDsnprintf(expected_link_name, LINK_ITER_EXT_LINKS_TEST_BUF_SIZE, - LINK_ITER_EXT_LINKS_TEST_LINK_NAME "%d", - (int)(counter_val % LINK_ITER_EXT_LINKS_TEST_NUM_LINKS)); + snprintf(expected_link_name, LINK_ITER_EXT_LINKS_TEST_BUF_SIZE, + LINK_ITER_EXT_LINKS_TEST_LINK_NAME "%d", + (int)(counter_val % LINK_ITER_EXT_LINKS_TEST_NUM_LINKS)); } else { - HDsnprintf(expected_link_name, LINK_ITER_EXT_LINKS_TEST_BUF_SIZE, - LINK_ITER_EXT_LINKS_TEST_LINK_NAME "%d", - (int)(LINK_ITER_EXT_LINKS_TEST_NUM_LINKS - - (counter_val % LINK_ITER_EXT_LINKS_TEST_NUM_LINKS) - 1)); + snprintf(expected_link_name, LINK_ITER_EXT_LINKS_TEST_BUF_SIZE, + LINK_ITER_EXT_LINKS_TEST_LINK_NAME "%d", + (int)(LINK_ITER_EXT_LINKS_TEST_NUM_LINKS - + (counter_val % LINK_ITER_EXT_LINKS_TEST_NUM_LINKS) - 1)); } - if (HDstrncmp(name, expected_link_name, LINK_ITER_EXT_LINKS_TEST_BUF_SIZE)) { + if (strncmp(name, expected_link_name, LINK_ITER_EXT_LINKS_TEST_BUF_SIZE)) { printf(" link name '%s' didn't match expected name '%s'\n", name, expected_link_name); ret_val = H5_ITER_ERROR; goto done; @@ -25973,7 +25910,6 @@ link_iter_mixed_links_cb(hid_t group_id, const char *name, const H5L_info2_t *in herr_t ret_val = 0; if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { - SKIPPED(); printf(" API functions for external or user-defined link aren't supported with this " "connector\n"); return 1; @@ -25981,8 +25917,8 @@ link_iter_mixed_links_cb(hid_t group_id, const char *name, const H5L_info2_t *in UNUSED(group_id); - if (!HDstrncmp(name, LINK_ITER_MIXED_LINKS_TEST_HARD_LINK_NAME, - strlen(LINK_ITER_MIXED_LINKS_TEST_HARD_LINK_NAME) + 1) && + if (!strncmp(name, LINK_ITER_MIXED_LINKS_TEST_HARD_LINK_NAME, + strlen(LINK_ITER_MIXED_LINKS_TEST_HARD_LINK_NAME) + 1) && (counter_val == 1 || counter_val == 4 || counter_val == 6 || counter_val == 11)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -25991,8 +25927,8 @@ link_iter_mixed_links_cb(hid_t group_id, const char *name, const H5L_info2_t *in goto done; } - else if (!HDstrncmp(name, LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME, - strlen(LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME) + 1) && + else if (!strncmp(name, LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME, + strlen(LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME) + 1) && (counter_val == 2 || counter_val == 3 || counter_val == 7 || counter_val == 10)) { if (H5L_TYPE_SOFT != info->type) { ret_val = -1; @@ -26001,8 +25937,8 @@ link_iter_mixed_links_cb(hid_t group_id, const char *name, const H5L_info2_t *in goto done; } - else if (!HDstrncmp(name, LINK_ITER_MIXED_LINKS_TEST_EXT_LINK_NAME, - strlen(LINK_ITER_MIXED_LINKS_TEST_EXT_LINK_NAME) + 1) && + else if (!strncmp(name, LINK_ITER_MIXED_LINKS_TEST_EXT_LINK_NAME, + strlen(LINK_ITER_MIXED_LINKS_TEST_EXT_LINK_NAME) + 1) && (counter_val == 0 || counter_val == 5 || counter_val == 8 || counter_val == 9)) { if (H5L_TYPE_EXTERNAL != info->type) { ret_val = -1; @@ -26062,7 +25998,6 @@ link_iter_idx_saving_cb(hid_t group_id, const char *name, const H5L_info2_t *inf int *broken = (int *)op_data; if (!(vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) || !(vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS)) { - SKIPPED(); printf(" API functions for external or user-defined link aren't supported with this " "connector\n"); return 1; @@ -26071,29 +26006,29 @@ link_iter_idx_saving_cb(hid_t group_id, const char *name, const H5L_info2_t *inf UNUSED(group_id); if (broken && !*broken && - !HDstrncmp(name, LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME, - strlen(LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME) + 1)) { + !strncmp(name, LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME, + strlen(LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME) + 1)) { return (*broken = 1); } - if (!HDstrncmp(name, LINK_ITER_MIXED_LINKS_TEST_HARD_LINK_NAME, - strlen(LINK_ITER_MIXED_LINKS_TEST_HARD_LINK_NAME) + 1)) { + if (!strncmp(name, LINK_ITER_MIXED_LINKS_TEST_HARD_LINK_NAME, + strlen(LINK_ITER_MIXED_LINKS_TEST_HARD_LINK_NAME) + 1)) { if (H5L_TYPE_HARD != info->type) { H5_FAILED(); printf(" link type did not match\n"); goto error; } } - else if (!HDstrncmp(name, LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME, - strlen(LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME) + 1)) { + else if (!strncmp(name, LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME, + strlen(LINK_ITER_MIXED_LINKS_TEST_SOFT_LINK_NAME) + 1)) { if (H5L_TYPE_SOFT != info->type) { H5_FAILED(); printf(" link type did not match\n"); goto error; } } - else if (!HDstrncmp(name, LINK_ITER_MIXED_LINKS_TEST_EXT_LINK_NAME, - strlen(LINK_ITER_MIXED_LINKS_TEST_EXT_LINK_NAME) + 1)) { + else if (!strncmp(name, LINK_ITER_MIXED_LINKS_TEST_EXT_LINK_NAME, + strlen(LINK_ITER_MIXED_LINKS_TEST_EXT_LINK_NAME) + 1)) { if (H5L_TYPE_EXTERNAL != info->type) { H5_FAILED(); printf(" link type did not match\n"); @@ -26120,7 +26055,7 @@ link_iter_idx_saving_cb(hid_t group_id, const char *name, const H5L_info2_t *inf static herr_t link_visit_hard_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void *op_data) { - hbool_t is_subgroup_link; + bool is_subgroup_link; size_t *i = (size_t *)op_data; size_t counter_val = *((size_t *)op_data); size_t test_iteration; @@ -26176,34 +26111,34 @@ link_visit_hard_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_i if (test_iteration == 0 || test_iteration == 3) { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); + snprintf(expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); } else { - HDsnprintf(expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", - (int)subgroup_number, (int)link_idx_val); + snprintf(expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", + (int)subgroup_number, (int)link_idx_val); } } else { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); + snprintf(expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); } else { - HDsnprintf(expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), - (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); + snprintf(expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), + (int)(LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); } } - if (HDstrncmp(name, expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE)) { + if (strncmp(name, expected_link_name, LINK_VISIT_HARD_LINKS_NO_CYCLE_TEST_BUF_SIZE)) { printf(" link name '%s' didn't match expected name '%s'\n", name, expected_link_name); ret_val = H5_ITER_ERROR; goto done; @@ -26223,7 +26158,7 @@ link_visit_hard_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_i static herr_t link_visit_soft_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void *op_data) { - hbool_t is_subgroup_link; + bool is_subgroup_link; size_t *i = (size_t *)op_data; size_t counter_val = *((size_t *)op_data); size_t test_iteration; @@ -26289,34 +26224,34 @@ link_visit_soft_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_i if (test_iteration == 0 || test_iteration == 3) { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); + snprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); } else { - HDsnprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", - (int)subgroup_number, (int)link_idx_val); + snprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", + (int)subgroup_number, (int)link_idx_val); } } else { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); + snprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); } else { - HDsnprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), - (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); + snprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), + (int)(LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); } } - if (HDstrncmp(name, expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE)) { + if (strncmp(name, expected_link_name, LINK_VISIT_SOFT_LINKS_NO_CYCLE_TEST_BUF_SIZE)) { printf(" link name '%s' didn't match expected name '%s'\n", name, expected_link_name); ret_val = H5_ITER_ERROR; goto done; @@ -26337,7 +26272,7 @@ static herr_t link_visit_external_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void *op_data) { - hbool_t is_subgroup_link; + bool is_subgroup_link; size_t *i = (size_t *)op_data; size_t counter_val = *((size_t *)op_data); size_t test_iteration; @@ -26410,34 +26345,34 @@ link_visit_external_links_no_cycles_cb(hid_t group_id, const char *name, const H if (test_iteration == 0 || test_iteration == 3) { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); + snprintf(expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); } else { - HDsnprintf(expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", - (int)subgroup_number, (int)link_idx_val); + snprintf(expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", + (int)subgroup_number, (int)link_idx_val); } } else { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); + snprintf(expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); } else { - HDsnprintf(expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), - (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); + snprintf(expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), + (int)(LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); } } - if (HDstrncmp(name, expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE)) { + if (strncmp(name, expected_link_name, LINK_VISIT_EXT_LINKS_NO_CYCLE_TEST_BUF_SIZE)) { printf(" link name '%s' didn't match expected name '%s'\n", name, expected_link_name); ret_val = H5_ITER_ERROR; goto done; @@ -26471,12 +26406,12 @@ link_visit_mixed_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_ UNUSED(group_id); UNUSED(op_data); - if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME1, - strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME1) + - 1) && + if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME1, + strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME1) + + 1) && (counter_val == 2 || counter_val == 14 || counter_val == 18 || counter_val == 30)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -26487,12 +26422,12 @@ link_visit_mixed_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_ goto done; } - else if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME2, - strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME2) + - 1) && + else if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME2, + strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME2) + + 1) && (counter_val == 3 || counter_val == 13 || counter_val == 19 || counter_val == 29)) { if (H5L_TYPE_SOFT != info->type) { ret_val = -1; @@ -26503,12 +26438,12 @@ link_visit_mixed_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_ goto done; } - else if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME3, - strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME3) + - 1) && + else if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME3, + strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME3) + + 1) && (counter_val == 6 || counter_val == 10 || counter_val == 22 || counter_val == 26)) { if (H5L_TYPE_EXTERNAL != info->type) { ret_val = -1; @@ -26519,12 +26454,12 @@ link_visit_mixed_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_ goto done; } - else if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME4, - strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME4) + - 1) && + else if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME4, + strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_LINK_NAME4) + + 1) && (counter_val == 7 || counter_val == 9 || counter_val == 23 || counter_val == 25)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -26535,12 +26470,12 @@ link_visit_mixed_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_ goto done; } - else if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_NAME, - strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_NAME) + - 1) && + else if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_NAME, + strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_NAME) + + 1) && (counter_val == 1 || counter_val == 15 || counter_val == 17 || counter_val == 31)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -26551,12 +26486,12 @@ link_visit_mixed_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_ goto done; } - else if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_NAME2, - strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_NAME2) + - 1) && + else if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_NAME2, + strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_DSET_NAME2) + + 1) && (counter_val == 5 || counter_val == 11 || counter_val == 21 || counter_val == 27)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -26567,8 +26502,8 @@ link_visit_mixed_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_ goto done; } - else if (!HDstrncmp(name, LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2, - strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2) + 1) && + else if (!strncmp(name, LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2, + strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME2) + 1) && (counter_val == 0 || counter_val == 12 || counter_val == 16 || counter_val == 28)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -26578,8 +26513,8 @@ link_visit_mixed_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_ goto done; } - else if (!HDstrncmp(name, LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3, - strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3) + 1) && + else if (!strncmp(name, LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3, + strlen(LINK_VISIT_MIXED_LINKS_NO_CYCLE_TEST_SUBGROUP_NAME3) + 1) && (counter_val == 4 || counter_val == 8 || counter_val == 20 || counter_val == 24)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -26608,7 +26543,7 @@ link_visit_mixed_links_no_cycles_cb(hid_t group_id, const char *name, const H5L_ static herr_t link_visit_hard_links_cycles_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void *op_data) { - hbool_t is_subgroup_link; + bool is_subgroup_link; size_t *i = (size_t *)op_data; size_t counter_val = *((size_t *)op_data); size_t test_iteration; @@ -26664,34 +26599,34 @@ link_visit_hard_links_cycles_cb(hid_t group_id, const char *name, const H5L_info if (test_iteration == 0 || test_iteration == 3) { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); + snprintf(expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); } else { - HDsnprintf(expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_HARD_LINKS_CYCLE_TEST_LINK_NAME "%d", - (int)subgroup_number, (int)link_idx_val); + snprintf(expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_HARD_LINKS_CYCLE_TEST_LINK_NAME "%d", + (int)subgroup_number, (int)link_idx_val); } } else { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); + snprintf(expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); } else { - HDsnprintf(expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_HARD_LINKS_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), - (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); + snprintf(expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_HARD_LINKS_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_HARD_LINKS_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), + (int)(LINK_VISIT_HARD_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); } } - if (HDstrncmp(name, expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE)) { + if (strncmp(name, expected_link_name, LINK_VISIT_HARD_LINKS_CYCLE_TEST_BUF_SIZE)) { printf(" link name '%s' didn't match expected name '%s'\n", name, expected_link_name); ret_val = H5_ITER_ERROR; goto done; @@ -26711,7 +26646,7 @@ link_visit_hard_links_cycles_cb(hid_t group_id, const char *name, const H5L_info static herr_t link_visit_soft_links_cycles_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void *op_data) { - hbool_t is_subgroup_link; + bool is_subgroup_link; size_t *i = (size_t *)op_data; size_t counter_val = *((size_t *)op_data); size_t test_iteration; @@ -26777,34 +26712,34 @@ link_visit_soft_links_cycles_cb(hid_t group_id, const char *name, const H5L_info if (test_iteration == 0 || test_iteration == 3) { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); + snprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); } else { - HDsnprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_SOFT_LINKS_CYCLE_TEST_LINK_NAME "%d", - (int)subgroup_number, (int)link_idx_val); + snprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_SOFT_LINKS_CYCLE_TEST_LINK_NAME "%d", + (int)subgroup_number, (int)link_idx_val); } } else { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); + snprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); } else { - HDsnprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_SOFT_LINKS_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), - (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); + snprintf(expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_SOFT_LINKS_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), + (int)(LINK_VISIT_SOFT_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); } } - if (HDstrncmp(name, expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE)) { + if (strncmp(name, expected_link_name, LINK_VISIT_SOFT_LINKS_CYCLE_TEST_BUF_SIZE)) { printf(" link name '%s' didn't match expected name '%s'\n", name, expected_link_name); ret_val = H5_ITER_ERROR; goto done; @@ -26824,7 +26759,7 @@ link_visit_soft_links_cycles_cb(hid_t group_id, const char *name, const H5L_info static herr_t link_visit_external_links_cycles_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void *op_data) { - hbool_t is_subgroup_link; + bool is_subgroup_link; size_t *i = (size_t *)op_data; size_t counter_val = *((size_t *)op_data); size_t test_iteration; @@ -26897,34 +26832,34 @@ link_visit_external_links_cycles_cb(hid_t group_id, const char *name, const H5L_ if (test_iteration == 0 || test_iteration == 3) { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); + snprintf(expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", (int)subgroup_number); } else { - HDsnprintf(expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_EXT_LINKS_CYCLE_TEST_LINK_NAME "%d", - (int)subgroup_number, (int)link_idx_val); + snprintf(expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_EXT_LINKS_CYCLE_TEST_LINK_NAME "%d", + (int)subgroup_number, (int)link_idx_val); } } else { if (is_subgroup_link) { - HDsnprintf(expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", - (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); + snprintf(expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME "%d", + (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1)); } else { - HDsnprintf(expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, - LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME - "%d" - "/" LINK_VISIT_EXT_LINKS_CYCLE_TEST_LINK_NAME "%d", - (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), - (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); + snprintf(expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE, + LINK_VISIT_EXT_LINKS_CYCLE_TEST_NESTED_GRP_NAME + "%d" + "/" LINK_VISIT_EXT_LINKS_CYCLE_TEST_LINK_NAME "%d", + (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_SUBGROUPS - subgroup_number - 1), + (int)(LINK_VISIT_EXT_LINKS_CYCLE_TEST_NUM_LINKS_PER_GROUP - link_idx_val - 1)); } } - if (HDstrncmp(name, expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE)) { + if (strncmp(name, expected_link_name, LINK_VISIT_EXT_LINKS_CYCLE_TEST_BUF_SIZE)) { printf(" link name '%s' didn't match expected name '%s'\n", name, expected_link_name); ret_val = H5_ITER_ERROR; goto done; @@ -26958,12 +26893,12 @@ link_visit_mixed_links_cycles_cb(hid_t group_id, const char *name, const H5L_inf UNUSED(group_id); UNUSED(op_data); - if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME1, - strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME1) + - 1) && + if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME1, + strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME1) + + 1) && (counter_val == 1 || counter_val == 11 || counter_val == 13 || counter_val == 23)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -26974,12 +26909,12 @@ link_visit_mixed_links_cycles_cb(hid_t group_id, const char *name, const H5L_inf goto done; } - else if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME2, - strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2 - "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME2) + - 1) && + else if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME2, + strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2 + "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME2) + + 1) && (counter_val == 2 || counter_val == 10 || counter_val == 14 || counter_val == 22)) { if (H5L_TYPE_SOFT != info->type) { ret_val = -1; @@ -26990,12 +26925,12 @@ link_visit_mixed_links_cycles_cb(hid_t group_id, const char *name, const H5L_inf goto done; } - else if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME3, - strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME3) + - 1) && + else if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME3, + strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME3) + + 1) && (counter_val == 4 || counter_val == 8 || counter_val == 16 || counter_val == 20)) { if (H5L_TYPE_EXTERNAL != info->type) { ret_val = -1; @@ -27006,12 +26941,12 @@ link_visit_mixed_links_cycles_cb(hid_t group_id, const char *name, const H5L_inf goto done; } - else if (!HDstrncmp(name, - LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME4, - strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3 - "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME4) + - 1) && + else if (!strncmp(name, + LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME4, + strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3 + "/" LINK_VISIT_MIXED_LINKS_CYCLE_TEST_LINK_NAME4) + + 1) && (counter_val == 5 || counter_val == 7 || counter_val == 17 || counter_val == 19)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -27022,8 +26957,8 @@ link_visit_mixed_links_cycles_cb(hid_t group_id, const char *name, const H5L_inf goto done; } - else if (!HDstrncmp(name, LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2, - strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2) + 1) && + else if (!strncmp(name, LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2, + strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME2) + 1) && (counter_val == 0 || counter_val == 9 || counter_val == 12 || counter_val == 21)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -27033,8 +26968,8 @@ link_visit_mixed_links_cycles_cb(hid_t group_id, const char *name, const H5L_inf goto done; } - else if (!HDstrncmp(name, LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3, - strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3) + 1) && + else if (!strncmp(name, LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3, + strlen(LINK_VISIT_MIXED_LINKS_CYCLE_TEST_SUBGROUP_NAME3) + 1) && (counter_val == 3 || counter_val == 6 || counter_val == 15 || counter_val == 18)) { if (H5L_TYPE_HARD != info->type) { ret_val = -1; @@ -27085,46 +27020,114 @@ link_visit_0_links_cb(hid_t group_id, const char *name, const H5L_info2_t *info, return 0; } -/* - * Cleanup temporary test files - */ -static void -cleanup_files(void) -{ - char *ext_link_filename = NULL; - - prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename); - H5Fdelete(ext_link_filename, H5P_DEFAULT); - - free(ext_link_filename); - ext_link_filename = NULL; - - prefix_filename(test_path_prefix, EXTERNAL_LINK_INVALID_PARAMS_TEST_FILE_NAME, &ext_link_filename); - H5Fdelete(ext_link_filename, H5P_DEFAULT); - - free(ext_link_filename); -} - -int -H5_api_link_test(void) +void +H5_api_link_test_add(void) { - size_t i; - int nerrors; - - printf("**********************************************\n"); - printf("* *\n"); - printf("* API Link Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); - - for (i = 0, nerrors = 0; i < ARRAY_LENGTH(link_tests); i++) { - nerrors += (*link_tests[i])() ? 1 : 0; - } - - printf("\n"); - - printf("Cleaning up testing files\n"); - cleanup_files(); - - return nerrors; + /* Add a fake test to print out a header to distinguish different test interfaces */ + AddTest("print_link_test_header", print_link_test_header, NULL, "Prints header for link tests", NULL); + AddTest("test_create_hard_link", MT_API_TEST_FUNC_OUTER(test_create_hard_link), NULL, "hard link creation", NULL); + AddTest("test_create_hard_link_long_name", MT_API_TEST_FUNC_OUTER(test_create_hard_link_long_name), NULL, + "hard link creation with a long name", NULL); + AddTest("test_create_hard_link_many", MT_API_TEST_FUNC_OUTER(test_create_hard_link_many), NULL, + "hard link creation of many links", NULL); + AddTest("test_create_hard_link_same_loc", MT_API_TEST_FUNC_OUTER(test_create_hard_link_same_loc), NULL, + "hard link creation with H5L_SAME_LOC", NULL); + AddTest("test_create_hard_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_hard_link_invalid_params), NULL, + "hard link creation with invalid parameters", NULL); + AddTest("test_create_soft_link_existing_relative", MT_API_TEST_FUNC_OUTER(test_create_soft_link_existing_relative), NULL, + "soft link creation to existing object by relative path", NULL); + AddTest("test_create_soft_link_existing_absolute", MT_API_TEST_FUNC_OUTER(test_create_soft_link_existing_absolute), NULL, + "soft link creation to existing object by absolute path", NULL); + AddTest("test_create_soft_link_dangling_relative", MT_API_TEST_FUNC_OUTER(test_create_soft_link_dangling_relative), NULL, + "dangling soft link creation to object by relative path", NULL); + AddTest("test_create_soft_link_dangling_absolute", MT_API_TEST_FUNC_OUTER(test_create_soft_link_dangling_absolute), NULL, + "dangling soft link creation to object by absolute path", NULL); + AddTest("test_create_soft_link_long_name", MT_API_TEST_FUNC_OUTER(test_create_soft_link_long_name), NULL, + "soft link creation with a long name", NULL); + AddTest("test_create_soft_link_many", MT_API_TEST_FUNC_OUTER(test_create_soft_link_many), NULL, + "soft link creation of many links", NULL); + AddTest("test_create_soft_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_soft_link_invalid_params), NULL, + "soft link creation with invalid parameters", NULL); + AddTest("test_create_external_link", MT_API_TEST_FUNC_OUTER(test_create_external_link), NULL, + "external link creation to existing object", NULL); + AddTest("test_create_external_link_dangling", MT_API_TEST_FUNC_OUTER(test_create_external_link_dangling), NULL, + "dangling external link creation", NULL); + AddTest("test_create_external_link_multi", MT_API_TEST_FUNC_OUTER(test_create_external_link_multi), NULL, + "external link creation to an object across several files", NULL); + AddTest("test_create_external_link_ping_pong", MT_API_TEST_FUNC_OUTER(test_create_external_link_ping_pong), NULL, + "external link creation to an object in ping pong style", NULL); + AddTest("test_create_external_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_external_link_invalid_params), NULL, + "H5Lcreate_external with invalid parameters", NULL); + AddTest("test_create_user_defined_link", MT_API_TEST_FUNC_OUTER(test_create_user_defined_link), NULL, + "user-defined link creation", NULL); + AddTest("test_create_user_defined_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_user_defined_link_invalid_params), + NULL, "H5Lcreate_ud with invalid parameters", NULL); + AddTest("test_delete_link", MT_API_TEST_FUNC_OUTER(test_delete_link), NULL, "link deletion", NULL); + AddTest("test_delete_link_reset_grp_max_crt_order", MT_API_TEST_FUNC_OUTER(test_delete_link_reset_grp_max_crt_order), NULL, + "H5Ldelete of all links in group resets group's maximum link creation order value", NULL); + AddTest("test_delete_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_delete_link_invalid_params), NULL, + "H5Ldelete with invalid parameters", NULL); + AddTest("test_copy_link", MT_API_TEST_FUNC_OUTER(test_copy_link), NULL, "link copying", NULL); + AddTest("test_copy_links_into_group_with_links", MT_API_TEST_FUNC_OUTER(test_copy_links_into_group_with_links), NULL, + "H5Lcopy adjusting creation order values for copied links", NULL); + AddTest("test_copy_link_across_files", MT_API_TEST_FUNC_OUTER(test_copy_link_across_files), NULL, "link copying across files", + NULL); + AddTest("test_copy_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_copy_link_invalid_params), NULL, + "H5Lcopy with invalid parameters", NULL); + AddTest("test_move_link", MT_API_TEST_FUNC_OUTER(test_move_link), NULL, "link moving", NULL); + AddTest("test_move_links_into_group_with_links", MT_API_TEST_FUNC_OUTER(test_move_links_into_group_with_links), NULL, + "H5Lmove adjusting creation order values for moved links", NULL); + AddTest("test_move_link_across_files", MT_API_TEST_FUNC_OUTER(test_move_link_across_files), NULL, "link moving across files", + NULL); + AddTest("test_move_link_reset_grp_max_crt_order", MT_API_TEST_FUNC_OUTER(test_move_link_reset_grp_max_crt_order), NULL, + "H5Lmove of all links out of group resets group's maximum link creation order value", NULL); + AddTest("test_move_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_move_link_invalid_params), NULL, + "H5Lmove with invalid parameters", NULL); + AddTest("test_get_link_val", MT_API_TEST_FUNC_OUTER(test_get_link_val), NULL, "link value retrieval", NULL); + AddTest("test_get_link_val_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_link_val_invalid_params), NULL, + "link value retrieval with invalid parameters", NULL); + AddTest("test_get_link_info", MT_API_TEST_FUNC_OUTER(test_get_link_info), NULL, "link info retrieval", NULL); + AddTest("test_get_link_info_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_link_info_invalid_params), NULL, + "link info retrieval with invalid parameters", NULL); + AddTest("test_get_link_name", MT_API_TEST_FUNC_OUTER(test_get_link_name), NULL, "link name retrieval", NULL); + AddTest("test_get_link_name_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_link_name_invalid_params), NULL, + "link name retrieval with invalid parameters", NULL); + AddTest("test_link_iterate_hard_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_hard_links), NULL, + "link iteration (only hard links)", NULL); + AddTest("test_link_iterate_soft_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_soft_links), NULL, + "link iteration (only soft links)", NULL); + AddTest("test_link_iterate_external_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_external_links), NULL, + "link iteration (only external links)", NULL); + AddTest("test_link_iterate_ud_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_ud_links), NULL, + "link iteration (only user-defined links)", NULL); + AddTest("test_link_iterate_mixed_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_mixed_links), NULL, + "link iteration (mixed link types)", NULL); + AddTest("test_link_iterate_invalid_params", MT_API_TEST_FUNC_OUTER(test_link_iterate_invalid_params), NULL, + "link iteration with invalid parameters", NULL); + AddTest("test_link_iterate_0_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_0_links), NULL, + "link iteration on group with 0 links", NULL); + AddTest("test_link_visit_hard_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_hard_links_no_cycles), NULL, + "link visiting without cycles (only hard links)", NULL); + AddTest("test_link_visit_soft_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_soft_links_no_cycles), NULL, + "link visiting without cycles (only soft links)", NULL); + AddTest("test_link_visit_external_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_external_links_no_cycles), NULL, + "link visiting without cycles (only external links)", NULL); + AddTest("test_link_visit_ud_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_ud_links_no_cycles), NULL, + "link visiting without cycles (only user-defined links)", NULL); + AddTest("test_link_visit_mixed_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_mixed_links_no_cycles), NULL, + "link visiting without cycles (mixed link types)", NULL); + AddTest("test_link_visit_hard_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_hard_links_cycles), NULL, + "link visiting with cycles (only hard links)", NULL); + AddTest("test_link_visit_soft_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_soft_links_cycles), NULL, + "link visiting with cycles (only soft links)", NULL); + AddTest("test_link_visit_external_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_external_links_cycles), NULL, + "link visiting with cycles (only external links)", NULL); + AddTest("test_link_visit_ud_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_ud_links_cycles), NULL, + "link visiting with cycles (only user-defined links)", NULL); + AddTest("test_link_visit_mixed_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_mixed_links_cycles), NULL, + "link visiting with cycles (mixed link types)", NULL); + AddTest("test_link_visit_invalid_params", MT_API_TEST_FUNC_OUTER(test_link_visit_invalid_params), NULL, + "link visiting with invalid parameters", NULL); + AddTest("test_link_visit_0_links", MT_API_TEST_FUNC_OUTER(test_link_visit_0_links), NULL, + "link visiting on group with subgroups containing 0 links", NULL); } diff --git a/test/API/H5_api_link_test.h b/test/API/H5_api_link_test.h index c068f4ff59d..15815b191bc 100644 --- a/test/API/H5_api_link_test.h +++ b/test/API/H5_api_link_test.h @@ -15,7 +15,7 @@ #include "H5_api_test.h" -int H5_api_link_test(void); +void H5_api_link_test_add(void); /********************************************* * * @@ -29,9 +29,10 @@ int H5_api_link_test(void); #define HARD_LINK_TEST_GROUP_LONG_NAME "hard_link_long_name" #define MAX_NAME_LEN ((64 * 1024) + 1024) -#define HARD_LINK_TEST_GROUP_MANY_NAME "hard_link_many_name" -#define HARD_LINK_TEST_GROUP_MANY_FINAL_NAME "hard_link_final" -#define HARD_LINK_TEST_GROUP_MANY_NAME_BUF_SIZE 1024 +#define HARD_LINK_TEST_GROUP_MANY_NAME "hard_link_many_name" +#define HARD_LINK_TEST_GROUP_MANY_FINAL_NAME "hard_link_final" +#define HARD_LINK_TEST_GROUP_MANY_NAME_BUF_SIZE 1024 +#define HARD_LINK_TEST_GROUP_MANY_NUM_HARD_LINKS 21 #define H5L_SAME_LOC_TEST_GROUP_NAME "h5l_same_loc_test_group" #define H5L_SAME_LOC_TEST_LINK_NAME1 "h5l_same_loc_test_link1" @@ -58,9 +59,10 @@ int H5_api_link_test(void); #define SOFT_LINK_TEST_GROUP_LONG_NAME "soft_link_long_name" #define SOFT_LINK_TEST_LONG_OBJECT_NAME "soft_link_object_name" -#define SOFT_LINK_TEST_GROUP_MANY_NAME "soft_link_many_name" -#define SOFT_LINK_TEST_GROUP_MANY_FINAL_NAME "soft_link_final" -#define SOFT_LINK_TEST_GROUP_MANY_NAME_BUF_SIZE 1024 +#define SOFT_LINK_TEST_GROUP_MANY_NAME "soft_link_many_name" +#define SOFT_LINK_TEST_GROUP_MANY_FINAL_NAME "soft_link_final" +#define SOFT_LINK_TEST_GROUP_MANY_NAME_BUF_SIZE 1024 +#define SOFT_LINK_TEST_GROUP_MANY_NAME_SOFT_LINK_COUNT 16 #define SOFT_LINK_INVALID_PARAMS_TEST_GROUP_NAME "soft_link_creation_invalid_params_test" #define SOFT_LINK_INVALID_PARAMS_TEST_LINK_NAME "soft_link_to_root" @@ -77,11 +79,11 @@ int H5_api_link_test(void); #define EXTERNAL_LINK_TEST_MULTI_NAME_BUF_SIZE 1024 #define EXTERNAL_LINK_TEST_FILE_NAME2 "ext_link_file_2.h5" #define EXTERNAL_LINK_TEST_FILE_NAME3 "ext_link_file_3.h5" -#define EXTERNAL_LINK_TEST_FILE_NAME4 "ext_link_file_4.h5" #define EXTERNAL_LINK_TEST_PING_PONG_NAME1 "ext_link_file_ping_pong_1.h5" #define EXTERNAL_LINK_TEST_PING_PONG_NAME2 "ext_link_file_ping_pong_2.h5" #define EXTERNAL_LINK_TEST_PING_PONG_NAME_BUF_SIZE 1024 +#define EXTERNAL_LINK_TEST_PING_PONG_NUM_LINKS 6 #define EXTERNAL_LINK_INVALID_PARAMS_TEST_GROUP_NAME "external_link_creation_invalid_params_test" #define EXTERNAL_LINK_INVALID_PARAMS_TEST_FILE_NAME "ext_link_invalid_params_file.h5" diff --git a/test/API/H5_api_misc_test.c b/test/API/H5_api_misc_test.c index d5a7ab08aef..f8db8c630a4 100644 --- a/test/API/H5_api_misc_test.c +++ b/test/API/H5_api_misc_test.c @@ -12,23 +12,33 @@ #include "H5_api_misc_test.h" -static int test_open_link_without_leading_slash(void); -static int test_object_creation_by_absolute_path(void); -static int test_absolute_vs_relative_path(void); -static int test_dot_for_object_name(void); -static int test_symbols_in_compound_field_name(void); -static int test_double_init_term(void); - -/* - * The array of miscellaneous tests to be performed. - */ -static int (*misc_tests[])(void) = { - test_open_link_without_leading_slash, test_object_creation_by_absolute_path, - test_absolute_vs_relative_path, test_dot_for_object_name, - test_symbols_in_compound_field_name, test_double_init_term, -}; +static void print_misc_test_header(void); +static void test_open_link_without_leading_slash(void); +static void test_object_creation_by_absolute_path(void); +static void test_absolute_vs_relative_path(void); +static void test_dot_for_object_name(void); +static void test_symbols_in_compound_field_name(void); +static void test_double_init_term(void); + +MULTI_DECLARE(test_open_link_without_leading_slash) +MULTI_DECLARE(test_object_creation_by_absolute_path) +MULTI_DECLARE(test_absolute_vs_relative_path) +MULTI_DECLARE(test_dot_for_object_name) +MULTI_DECLARE(test_symbols_in_compound_field_name) +MULTI_DECLARE(test_double_init_term) + +static void +print_misc_test_header(void) +{ + printf("\n"); + printf("**********************************************\n"); + printf("* *\n"); + printf("* API Miscellaneous Tests *\n"); + printf("* *\n"); + printf("**********************************************\n\n"); +} -static int +static void test_open_link_without_leading_slash(void) { hid_t file_id = H5I_INVALID_HID; @@ -45,7 +55,7 @@ test_open_link_without_leading_slash(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -60,11 +70,11 @@ test_open_link_without_leading_slash(void) goto error; } - if ((space_id = generate_random_dataspace(OPEN_LINK_WITHOUT_SLASH_DSET_SPACE_RANK, NULL, NULL, FALSE)) < + if ((space_id = generate_random_dataspace(OPEN_LINK_WITHOUT_SLASH_DSET_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(container_group, OPEN_LINK_WITHOUT_SLASH_DSET_NAME, dset_dtype, space_id, @@ -113,7 +123,7 @@ test_open_link_without_leading_slash(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -127,10 +137,10 @@ test_open_link_without_leading_slash(void) } H5E_END_TRY - return 1; + return; } -static int +static void test_object_creation_by_absolute_path(void) { htri_t link_exists; @@ -150,7 +160,7 @@ test_object_creation_by_absolute_path(void) SKIPPED(); printf(" API functions for basic file, group, dataset, link, or stored datatype aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -235,13 +245,13 @@ test_object_creation_by_absolute_path(void) /* Try to create a dataset nested at the end of this group chain by using an absolute pathname */ if ((fspace_id = generate_random_dataspace(OBJECT_CREATE_BY_ABSOLUTE_PATH_TEST_DSET_SPACE_RANK, - NULL, NULL, FALSE)) < 0) { + NULL, NULL, false)) < 0) { H5_FAILED(); printf(" failed to generate dataspace\n"); PART_ERROR(H5Dcreate_using_absolute_path); } - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" failed to generate datatype\n"); PART_ERROR(H5Dcreate_using_absolute_path); @@ -284,7 +294,7 @@ test_object_creation_by_absolute_path(void) TESTING_2("creation of committed datatype using absolute pathname"); /* Try to create a committed datatype in the same fashion as the preceding dataset */ - if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); PART_ERROR(H5Tcommit_using_absolute_path); @@ -345,7 +355,7 @@ test_object_creation_by_absolute_path(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -361,11 +371,11 @@ test_object_creation_by_absolute_path(void) } H5E_END_TRY - return 1; + return; } /* XXX: Add testing for groups */ -static int +static void test_absolute_vs_relative_path(void) { htri_t link_exists; @@ -385,7 +395,7 @@ test_absolute_vs_relative_path(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or link aren't supported with this " "connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -411,20 +421,20 @@ test_absolute_vs_relative_path(void) } if ((fspace_id = generate_random_dataspace(ABSOLUTE_VS_RELATIVE_PATH_TEST_DSET_SPACE_RANK, NULL, NULL, - FALSE)) < 0) + false)) < 0) TEST_ERROR; - if ((dset_dtype1 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype1 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((dset_dtype2 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype2 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((dset_dtype3 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype3 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((dset_dtype4 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype4 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((dset_dtype5 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype5 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; - if ((dset_dtype6 = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype6 = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; PASSED(); @@ -680,7 +690,7 @@ test_absolute_vs_relative_path(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -704,13 +714,13 @@ test_absolute_vs_relative_path(void) } H5E_END_TRY - return 1; + return; } /* * A test to check creating/opening objects with the "." as the name */ -static int +static void test_dot_for_object_name(void) { hid_t file_id = H5I_INVALID_HID; @@ -730,7 +740,7 @@ test_dot_for_object_name(void) SKIPPED(); printf(" API functions for basic file, group, dataset, or stored datatype aren't supported with " "this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -855,7 +865,7 @@ test_dot_for_object_name(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -871,7 +881,7 @@ test_dot_for_object_name(void) } H5E_END_TRY - return 1; + return; } /* @@ -882,22 +892,22 @@ test_dot_for_object_name(void) * TODO: Not sure if this test can be done from public APIs * at the moment. */ -static int +static void test_double_init_term(void) { TESTING("double init/term correctness"); SKIPPED(); - return 0; + return; #if 0 error: - return 1; + return; #endif } -static int +static void test_symbols_in_compound_field_name(void) { size_t i; @@ -918,7 +928,7 @@ test_symbols_in_compound_field_name(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or dataset aren't supported with this connector\n"); - return 0; + return; } for (i = 0; i < COMPOUND_WITH_SYMBOLS_IN_MEMBER_NAMES_TEST_NUM_SUBTYPES; i++) @@ -944,19 +954,19 @@ test_symbols_in_compound_field_name(void) } for (i = 0, total_type_size = 0; i < COMPOUND_WITH_SYMBOLS_IN_MEMBER_NAMES_TEST_NUM_SUBTYPES; i++) { - type_pool[i] = generate_random_datatype(H5T_NO_CLASS, FALSE); + type_pool[i] = generate_random_datatype(H5T_NO_CLASS, false); total_type_size += H5Tget_size(type_pool[i]); } - HDsnprintf(member_names[0], 256, "{{{ member0"); - HDsnprintf(member_names[1], 256, "member1 }}}"); - HDsnprintf(member_names[2], 256, "{{{ member2 }}"); - HDsnprintf(member_names[3], 256, "{{ member3 }}}"); - HDsnprintf(member_names[4], 256, "\\\"member4"); - HDsnprintf(member_names[5], 256, "member5\\\""); - HDsnprintf(member_names[6], 256, "mem\\\"ber6"); - HDsnprintf(member_names[7], 256, "{{ member7\\\" }"); - HDsnprintf(member_names[8], 256, "{{ member8\\\\"); + snprintf(member_names[0], 256, "{{{ member0"); + snprintf(member_names[1], 256, "member1 }}}"); + snprintf(member_names[2], 256, "{{{ member2 }}"); + snprintf(member_names[3], 256, "{{ member3 }}}"); + snprintf(member_names[4], 256, "\\\"member4"); + snprintf(member_names[5], 256, "member5\\\""); + snprintf(member_names[6], 256, "mem\\\"ber6"); + snprintf(member_names[7], 256, "{{ member7\\\" }"); + snprintf(member_names[8], 256, "{{ member8\\\\"); if ((compound_type = H5Tcreate(H5T_COMPOUND, total_type_size)) < 0) { H5_FAILED(); @@ -978,7 +988,7 @@ test_symbols_in_compound_field_name(void) TEST_ERROR; if ((fspace_id = generate_random_dataspace(COMPOUND_WITH_SYMBOLS_IN_MEMBER_NAMES_TEST_DSET_RANK, NULL, - NULL, FALSE)) < 0) + NULL, false)) < 0) TEST_ERROR; if ((dset_id = H5Dcreate2(group_id, COMPOUND_WITH_SYMBOLS_IN_MEMBER_NAMES_TEST_DSET_NAME, compound_type, @@ -1017,7 +1027,7 @@ test_symbols_in_compound_field_name(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1033,26 +1043,25 @@ test_symbols_in_compound_field_name(void) } H5E_END_TRY - return 1; + return; } -int -H5_api_misc_test(void) +void +H5_api_misc_test_add(void) { - size_t i; - int nerrors; - - printf("**********************************************\n"); - printf("* *\n"); - printf("* API Miscellaneous Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); - - for (i = 0, nerrors = 0; i < ARRAY_LENGTH(misc_tests); i++) { - nerrors += (*misc_tests[i])() ? 1 : 0; - } - - printf("\n"); - - return nerrors; + /* Add a fake test to print out a header to distinguish different test interfaces */ + AddTest("print_misc_test_header", print_misc_test_header, NULL, "Prints header for miscellaneous tests", + NULL); + + AddTest("test_open_link_without_leading_slash", MT_API_TEST_FUNC_OUTER(test_open_link_without_leading_slash), NULL, + "opening a link without a leading slash", NULL); + AddTest("test_object_creation_by_absolute_path", MT_API_TEST_FUNC_OUTER(test_object_creation_by_absolute_path), NULL, + "object creation by absolute path", NULL); + AddTest("test_absolute_vs_relative_path", MT_API_TEST_FUNC_OUTER(test_absolute_vs_relative_path), NULL, + "absolute vs. relative pathnames", NULL); + AddTest("test_dot_for_object_name", MT_API_TEST_FUNC_OUTER(test_dot_for_object_name), NULL, + "creating objects with \".\" as the name", NULL); + AddTest("test_symbols_in_compound_field_name", MT_API_TEST_FUNC_OUTER(test_symbols_in_compound_field_name), NULL, + "usage of '{', '}' and '\\\"' symbols in compound field name", NULL); + AddTest("test_double_init_term", MT_API_TEST_FUNC_OUTER(test_double_init_term), NULL, "double init/term correctness", NULL); } diff --git a/test/API/H5_api_misc_test.h b/test/API/H5_api_misc_test.h index 99fe4b54b2e..3d5515976d5 100644 --- a/test/API/H5_api_misc_test.h +++ b/test/API/H5_api_misc_test.h @@ -15,7 +15,7 @@ #include "H5_api_test.h" -int H5_api_misc_test(void); +void H5_api_misc_test_add(void); /****************************************************** * * diff --git a/test/API/H5_api_object_test.c b/test/API/H5_api_object_test.c index 4f81c8e0751..facaa9992a0 100644 --- a/test/API/H5_api_object_test.c +++ b/test/API/H5_api_object_test.c @@ -12,36 +12,68 @@ #include "H5_api_object_test.h" -static int test_open_object(void); -static int test_open_object_invalid_params(void); -static int test_object_exists(void); -static int test_object_exists_invalid_params(void); -static int test_get_object_info(void); -static int test_get_object_info_invalid_params(void); -static int test_link_object(void); -static int test_link_object_invalid_params(void); -static int test_incr_decr_object_refcount(void); -static int test_incr_decr_object_refcount_invalid_params(void); -static int test_object_copy_basic(void); -static int test_object_copy_already_existing(void); -static int test_object_copy_shallow_group_copy(void); -static int test_object_copy_no_attributes(void); -static int test_object_copy_by_soft_link(void); -static int test_object_copy_group_with_soft_links(void); -static int test_object_copy_between_files(void); -static int test_object_copy_invalid_params(void); -static int test_object_comments(void); -static int test_object_comments_invalid_params(void); -static int test_object_visit(void); -static int test_object_visit_soft_link(void); -static int test_object_visit_invalid_params(void); -static int test_close_object(void); -static int test_close_object_invalid_params(void); -static int test_close_invalid_objects(void); -static int test_flush_object(void); -static int test_flush_object_invalid_params(void); -static int test_refresh_object(void); -static int test_refresh_object_invalid_params(void); +static void print_object_test_header(void); +static void test_open_object(void); +static void test_open_object_invalid_params(void); +static void test_object_exists(void); +static void test_object_exists_invalid_params(void); +static void test_get_object_info(void); +static void test_get_object_info_invalid_params(void); +static void test_link_object(void); +static void test_link_object_invalid_params(void); +static void test_incr_decr_object_refcount(void); +static void test_incr_decr_object_refcount_invalid_params(void); +static void test_object_copy_basic(void); +static void test_object_copy_already_existing(void); +static void test_object_copy_shallow_group_copy(void); +static void test_object_copy_no_attributes(void); +static void test_object_copy_by_soft_link(void); +static void test_object_copy_group_with_soft_links(void); +static void test_object_copy_between_files(void); +static void test_object_copy_invalid_params(void); +static void test_object_comments(void); +static void test_object_comments_invalid_params(void); +static void test_object_visit(void); +static void test_object_visit_soft_link(void); +static void test_object_visit_invalid_params(void); +static void test_close_object(void); +static void test_close_object_invalid_params(void); +static void test_close_invalid_objects(void); +static void test_flush_object(void); +static void test_flush_object_invalid_params(void); +static void test_refresh_object(void); +static void test_refresh_object_invalid_params(void); + +MULTI_DECLARE(test_open_object) +MULTI_DECLARE(test_open_object_invalid_params) +MULTI_DECLARE(test_object_exists) +MULTI_DECLARE(test_object_exists_invalid_params) +MULTI_DECLARE(test_get_object_info) +MULTI_DECLARE(test_get_object_info_invalid_params) +MULTI_DECLARE(test_link_object) +MULTI_DECLARE(test_link_object_invalid_params) +MULTI_DECLARE(test_incr_decr_object_refcount) +MULTI_DECLARE(test_incr_decr_object_refcount_invalid_params) +MULTI_DECLARE(test_object_copy_basic) +MULTI_DECLARE(test_object_copy_already_existing) +MULTI_DECLARE(test_object_copy_shallow_group_copy) +MULTI_DECLARE(test_object_copy_no_attributes) +MULTI_DECLARE(test_object_copy_by_soft_link) +MULTI_DECLARE(test_object_copy_group_with_soft_links) +MULTI_DECLARE(test_object_copy_between_files) +MULTI_DECLARE(test_object_copy_invalid_params) +MULTI_DECLARE(test_object_comments) +MULTI_DECLARE(test_object_comments_invalid_params) +MULTI_DECLARE(test_object_visit) +MULTI_DECLARE(test_object_visit_soft_link) +MULTI_DECLARE(test_object_visit_invalid_params) +MULTI_DECLARE(test_close_object) +MULTI_DECLARE(test_close_object_invalid_params) +MULTI_DECLARE(test_close_invalid_objects) +MULTI_DECLARE(test_flush_object) +MULTI_DECLARE(test_flush_object_invalid_params) +MULTI_DECLARE(test_refresh_object) +MULTI_DECLARE(test_refresh_object_invalid_params) static herr_t object_copy_attribute_iter_callback(hid_t location_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data); @@ -51,6 +83,8 @@ static herr_t object_copy_soft_link_expand_callback(hid_t group, const char *nam void *op_data); static herr_t object_visit_callback(hid_t o_id, const char *name, const H5O_info2_t *object_info, void *op_data); +static herr_t object_visit_simple_callback(hid_t o_id, const char *name, const H5O_info2_t *object_info, + void *op_data); static herr_t object_visit_dset_callback(hid_t o_id, const char *name, const H5O_info2_t *object_info, void *op_data); static herr_t object_visit_dtype_callback(hid_t o_id, const char *name, const H5O_info2_t *object_info, @@ -60,41 +94,16 @@ static herr_t object_visit_soft_link_callback(hid_t o_id, const char *name, cons static herr_t object_visit_noop_callback(hid_t o_id, const char *name, const H5O_info2_t *object_info, void *op_data); -/* - * The array of object tests to be performed. - */ -static int (*object_tests[])(void) = { - test_open_object, - test_open_object_invalid_params, - test_object_exists, - test_object_exists_invalid_params, - test_get_object_info, - test_get_object_info_invalid_params, - test_link_object, - test_link_object_invalid_params, - test_incr_decr_object_refcount, - test_incr_decr_object_refcount_invalid_params, - test_object_copy_basic, - test_object_copy_already_existing, - test_object_copy_shallow_group_copy, - test_object_copy_no_attributes, - test_object_copy_by_soft_link, - test_object_copy_group_with_soft_links, - test_object_copy_between_files, - test_object_copy_invalid_params, - test_object_comments, - test_object_comments_invalid_params, - test_object_visit, - test_object_visit_soft_link, - test_object_visit_invalid_params, - test_close_object, - test_close_object_invalid_params, - test_close_invalid_objects, - test_flush_object, - test_flush_object_invalid_params, - test_refresh_object, - test_refresh_object_invalid_params, -}; +static void +print_object_test_header(void) +{ + printf("\n"); + printf("**********************************************\n"); + printf("* *\n"); + printf("* API Object Tests *\n"); + printf("* *\n"); + printf("**********************************************\n\n"); +} /* * A test to check that various objects (group, dataset, datatype) @@ -106,7 +115,7 @@ static int (*object_tests[])(void) = { * * XXX: test opening through dangling and resolving soft links. */ -static int +static void test_open_object(void) { hid_t file_id = H5I_INVALID_HID; @@ -128,7 +137,7 @@ test_open_object(void) SKIPPED(); printf(" API functions for basic file, group, object, dataset, or stored datatype aren't " "supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -150,10 +159,10 @@ test_open_object(void) goto error; } - if ((fspace_id = generate_random_dataspace(OBJECT_OPEN_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(OBJECT_OPEN_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; PASSED(); @@ -242,7 +251,7 @@ test_open_object(void) { TESTING_2("H5Oopen on a committed datatype"); - if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype '%s'\n", OBJECT_OPEN_TEST_TYPE_NAME); PART_ERROR(H5Oopen_dtype); @@ -396,7 +405,7 @@ test_open_object(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -412,7 +421,7 @@ test_open_object(void) } H5E_END_TRY - return 1; + return; } /* @@ -420,7 +429,7 @@ test_open_object(void) * can't be opened when H5Oopen, H5Oopen_by_idx and H5Oopen_by_addr * are passed invalid parameters. */ -static int +static void test_open_object_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -436,7 +445,7 @@ test_open_object_invalid_params(void) SKIPPED(); printf(" API functions for basic file, group, or object aren't supported with " "this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -771,7 +780,7 @@ test_open_object_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -784,13 +793,13 @@ test_open_object_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Oexists_by_name. */ -static int +static void test_object_exists(void) { htri_t object_exists; @@ -812,7 +821,7 @@ test_object_exists(void) SKIPPED(); printf(" API functions for basic file, group, object, dataset, stored datatype or soft link " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -836,10 +845,10 @@ test_object_exists(void) goto error; } - if ((fspace_id = generate_random_dataspace(OBJECT_EXISTS_TEST_DSET_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(OBJECT_EXISTS_TEST_DSET_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; PASSED(); @@ -921,7 +930,7 @@ test_object_exists(void) { TESTING_2("H5Oexists_by_name on a committed datatype"); - if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype '%s'\n", OBJECT_EXISTS_TEST_TYPE_NAME); PART_ERROR(H5Oexists_by_name_dtype); @@ -1033,7 +1042,7 @@ test_object_exists(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1049,14 +1058,14 @@ test_object_exists(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Oexists_by_name fails * when it is passed invalid parameters. */ -static int +static void test_object_exists_invalid_params(void) { htri_t object_exists; @@ -1071,7 +1080,7 @@ test_object_exists_invalid_params(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_OBJECT_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or object aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1197,7 +1206,7 @@ test_object_exists_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1209,20 +1218,20 @@ test_object_exists_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Oget_info(_by_name/_by_idx). */ -static int +static void test_get_object_info(void) { TESTING("object info retrieval"); SKIPPED(); - return 0; + return; } /* @@ -1230,20 +1239,20 @@ test_get_object_info(void) * when H5Oget_info(_by_name/_by_idx) are passed invalid * parameters. */ -static int +static void test_get_object_info_invalid_params(void) { TESTING("object info retrieval with invalid parameters"); SKIPPED(); - return 0; + return; } /* * A test for H5Olink. */ -static int +static void test_link_object(void) { hid_t file_id = H5I_INVALID_HID; @@ -1263,7 +1272,7 @@ test_link_object(void) SKIPPED(); printf(" API functions for basic file, group, object, dataset, or stored datatype aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1287,10 +1296,10 @@ test_link_object(void) goto error; } - if ((fspace_id = generate_random_dataspace(OBJECT_LINK_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(OBJECT_LINK_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; PASSED(); @@ -1378,7 +1387,7 @@ test_link_object(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1394,7 +1403,7 @@ test_link_object(void) } H5E_END_TRY - return 1; + return; } /* @@ -1402,7 +1411,7 @@ test_link_object(void) * the file structure when H5Olink is passed invalid * parameters. */ -static int +static void test_link_object_invalid_params(void) { hid_t file_id = H5I_INVALID_HID; @@ -1417,7 +1426,7 @@ test_link_object_invalid_params(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_OBJECT_BASIC)) { SKIPPED(); printf(" API functions for basic file, group, or object aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1582,7 +1591,7 @@ test_link_object_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1594,13 +1603,13 @@ test_link_object_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Oincr_refcount/H5Odecr_refcount. */ -static int +static void test_incr_decr_object_refcount(void) { H5O_info2_t oinfo; /* Object info struct */ @@ -1621,7 +1630,7 @@ test_incr_decr_object_refcount(void) SKIPPED(); printf(" API functions for basic file, group, dataset, stored datatype, or object " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -1645,10 +1654,10 @@ test_incr_decr_object_refcount(void) goto error; } - if ((fspace_id = generate_random_dataspace(OBJECT_REF_COUNT_TEST_DSET_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(OBJECT_REF_COUNT_TEST_DSET_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; PASSED(); @@ -1877,7 +1886,7 @@ test_incr_decr_object_refcount(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -1892,14 +1901,14 @@ test_incr_decr_object_refcount(void) } H5E_END_TRY - return 1; + return; } /* test_incr_decr_object_refcount */ /* * A test to check that H5Oincr_refcount/H5Odecr_refcount * fail when passed invalid parameters. */ -static int +static void test_incr_decr_object_refcount_invalid_params(void) { herr_t status; @@ -1910,7 +1919,7 @@ test_incr_decr_object_refcount_invalid_params(void) if (!(vol_cap_flags_g & H5VL_CAP_FLAG_OBJECT_MORE)) { SKIPPED(); printf(" API functions for more object aren't supported with this connector\n"); - return 0; + return; } BEGIN_MULTIPART @@ -1957,16 +1966,16 @@ test_incr_decr_object_refcount_invalid_params(void) } END_MULTIPART; - return 0; + return; error: - return 1; + return; } /* * Basic tests for H5Ocopy. */ -static int +static void test_object_copy_basic(void) { H5O_info2_t object_info; @@ -1998,7 +2007,7 @@ test_object_copy_basic(void) SKIPPED(); printf(" API functions for basic file, group, object, link, dataset, attribute, iterate, or " "stored datatype aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -2022,12 +2031,12 @@ test_object_copy_basic(void) goto error; } - if ((space_id = generate_random_dataspace(OBJECT_COPY_BASIC_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((space_id = generate_random_dataspace(OBJECT_COPY_BASIC_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((attr_space_id = generate_random_dataspace(OBJECT_COPY_BASIC_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + if ((attr_space_id = generate_random_dataspace(OBJECT_COPY_BASIC_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; /* Create the test group object, along with its nested members and the attributes attached to it. */ @@ -2117,7 +2126,7 @@ test_object_copy_basic(void) } /* Create the test committed datatype object, along with the attributes attached to it. */ - if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -2515,7 +2524,7 @@ test_object_copy_basic(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2536,14 +2545,14 @@ test_object_copy_basic(void) } H5E_END_TRY - return 1; + return; } /* * Tests to ensure that H5Ocopy fails when attempting to copy * an object to a destination where the object already exists. */ -static int +static void test_object_copy_already_existing(void) { herr_t err_ret; @@ -2566,7 +2575,7 @@ test_object_copy_already_existing(void) SKIPPED(); printf(" API functions for basic file, group, object, dataset, or stored datatype aren't " "supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -2592,9 +2601,9 @@ test_object_copy_already_existing(void) } if ((space_id = - generate_random_dataspace(OBJECT_COPY_ALREADY_EXISTING_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + generate_random_dataspace(OBJECT_COPY_ALREADY_EXISTING_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; /* Create the test group object */ @@ -2614,7 +2623,7 @@ test_object_copy_already_existing(void) } /* Create the test committed datatype object */ - if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -2718,7 +2727,7 @@ test_object_copy_already_existing(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2734,14 +2743,14 @@ test_object_copy_already_existing(void) } H5E_END_TRY - return 1; + return; } /* * A test to exercise the H5O_COPY_SHALLOW_HIERARCHY_FLAG flag * for H5Ocopy. */ -static int +static void test_object_copy_shallow_group_copy(void) { H5G_info_t group_info; @@ -2763,7 +2772,7 @@ test_object_copy_shallow_group_copy(void) SKIPPED(); printf(" API functions for basic file, group, object, or link aren't supported with this " "connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -2947,7 +2956,7 @@ test_object_copy_shallow_group_copy(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -2961,14 +2970,14 @@ test_object_copy_shallow_group_copy(void) } H5E_END_TRY - return 1; + return; } /* * Tests to exercise the H5O_COPY_WITHOUT_ATTR_FLAG flag * of H5Ocopy. */ -static int +static void test_object_copy_no_attributes(void) { H5O_info2_t object_info; @@ -3000,7 +3009,7 @@ test_object_copy_no_attributes(void) SKIPPED(); printf(" API functions for basic file, group, object, link, dataset, attribute, or stored " "datatype aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3024,13 +3033,13 @@ test_object_copy_no_attributes(void) goto error; } - if ((space_id = generate_random_dataspace(OBJECT_COPY_NO_ATTRS_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((space_id = generate_random_dataspace(OBJECT_COPY_NO_ATTRS_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((attr_space_id = generate_random_dataspace(OBJECT_COPY_NO_ATTRS_TEST_SPACE_RANK, NULL, NULL, TRUE)) < + if ((attr_space_id = generate_random_dataspace(OBJECT_COPY_NO_ATTRS_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; /* Create the test group object, along with the attributes attached to it. */ @@ -3090,7 +3099,7 @@ test_object_copy_no_attributes(void) } /* Create the test committed datatype object, along with the attributes attached to it. */ - if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -3452,7 +3461,7 @@ test_object_copy_no_attributes(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3474,14 +3483,14 @@ test_object_copy_no_attributes(void) } H5E_END_TRY - return 1; + return; } /* * Tests to exercise the behavior of H5Ocopy when the source * object specified is a soft link or dangling soft link. */ -static int +static void test_object_copy_by_soft_link(void) { H5O_info2_t object_info; @@ -3508,7 +3517,7 @@ test_object_copy_by_soft_link(void) SKIPPED(); printf(" API functions for basic file, group, object, link, dataset, attribute, iterate, or " "soft link aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -3532,7 +3541,7 @@ test_object_copy_by_soft_link(void) goto error; } - if ((attr_space_id = generate_random_dataspace(OBJECT_COPY_SOFT_LINK_TEST_SPACE_RANK, NULL, NULL, TRUE)) < + if ((attr_space_id = generate_random_dataspace(OBJECT_COPY_SOFT_LINK_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; @@ -3791,7 +3800,7 @@ test_object_copy_by_soft_link(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -3806,7 +3815,7 @@ test_object_copy_by_soft_link(void) } H5E_END_TRY - return 1; + return; } /* @@ -3814,7 +3823,7 @@ test_object_copy_by_soft_link(void) * H5Ocopy. Also tested is the H5O_COPY_EXPAND_SOFT_LINK_FLAG * flag. */ -static int +static void test_object_copy_group_with_soft_links(void) { H5G_info_t group_info; @@ -3838,7 +3847,7 @@ test_object_copy_group_with_soft_links(void) printf(" API functions for basic file, group, object, link, iterate, or soft link aren't " "supported with " "this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -4151,7 +4160,7 @@ test_object_copy_group_with_soft_links(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -4165,14 +4174,14 @@ test_object_copy_group_with_soft_links(void) } H5E_END_TRY - return 1; + return; } /* * Tests for copying objects between two different files using * H5Ocopy. */ -static int +static void test_object_copy_between_files(void) { H5O_info2_t object_info; @@ -4208,7 +4217,7 @@ test_object_copy_between_files(void) SKIPPED(); printf(" API functions for basic file, group, object, link, dataset, attribute, stored " "datatype, or iterate aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -4247,14 +4256,14 @@ test_object_copy_between_files(void) goto error; } - if ((space_id = generate_random_dataspace(OBJECT_COPY_BETWEEN_FILES_TEST_SPACE_RANK, NULL, NULL, FALSE)) < + if ((space_id = generate_random_dataspace(OBJECT_COPY_BETWEEN_FILES_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; if ((attr_space_id = - generate_random_dataspace(OBJECT_COPY_BETWEEN_FILES_TEST_SPACE_RANK, NULL, NULL, TRUE)) < 0) + generate_random_dataspace(OBJECT_COPY_BETWEEN_FILES_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; /* Create the test group object, along with its nested members and the attributes attached to it. */ @@ -4344,7 +4353,7 @@ test_object_copy_between_files(void) } /* Create the test committed datatype object, along with the attributes attached to it. */ - if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype\n"); goto error; @@ -4750,10 +4759,13 @@ test_object_copy_between_files(void) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; + + if (remove_test_file(NULL, obj_copy_filename) < 0) + TEST_ERROR; free(obj_copy_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -4773,18 +4785,19 @@ test_object_copy_between_files(void) H5Gclose(container_group); H5Fclose(file_id2); H5Fclose(file_id); + remove_test_file(NULL, obj_copy_filename); free(obj_copy_filename); } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Ocopy fails when it * is passed invalid parameters. */ -static int +static void test_object_copy_invalid_params(void) { herr_t err_ret = -1; @@ -4799,7 +4812,7 @@ test_object_copy_invalid_params(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_OBJECT_MORE)) { SKIPPED(); printf(" API functions for basic file, group, or object aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -5002,7 +5015,7 @@ test_object_copy_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -5014,34 +5027,34 @@ test_object_copy_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Oset_comment(_by_name)/H5Oget_comment(_by_name). */ -static int +static void test_object_comments(void) { TESTING("object comments"); SKIPPED(); - return 0; + return; } /* * A test to check that H5Oset_comment(_by_name)/H5Oget_comment(_by_name) * fail when passed invalid parameters. */ -static int +static void test_object_comments_invalid_params(void) { - TESTING("object comment "); + TESTING("object comments with invalid parameters"); SKIPPED(); - return 0; + return; } /* @@ -5049,18 +5062,26 @@ test_object_comments_invalid_params(void) * * XXX: Should have test for checking nested object's names/paths. */ -static int +static void test_object_visit(void) { - size_t i; - hid_t file_id = H5I_INVALID_HID; - hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; - hid_t group_id2 = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t dset_dtype = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; + size_t i; + hid_t file_id = H5I_INVALID_HID; + hid_t file_id2 = H5I_INVALID_HID; + hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; + hid_t group_id2 = H5I_INVALID_HID; + hid_t gcpl_id = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dset_dtype = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; + hid_t group_id3 = H5I_INVALID_HID; + hid_t group_id4 = H5I_INVALID_HID; + hid_t group_id5 = H5I_INVALID_HID; + hssize_t num_elems = 0; + size_t elem_size = 0; + char *visit_filename = NULL; TESTING_MULTIPART("object visiting"); @@ -5072,7 +5093,7 @@ test_object_visit(void) SKIPPED(); printf(" API functions for basic file, group, object, dataset, attribute, stored datatype, or " "iterate aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -5083,6 +5104,18 @@ test_object_visit(void) goto error; } + if (prefix_filename(test_path_prefix, OBJECT_VISIT_TEST_FILE_NAME, &visit_filename) < 0) { + H5_FAILED(); + printf(" couldn't generate filename\n"); + goto error; + } + + if ((file_id2 = H5Fcreate(visit_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't open file '%s'\n", OBJECT_VISIT_TEST_FILE_NAME); + goto error; + } + if ((container_group = H5Gopen2(file_id, OBJECT_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't open container group '%s'\n", OBJECT_TEST_GROUP_NAME); @@ -5110,11 +5143,29 @@ test_object_visit(void) goto error; } - if ((fspace_id = generate_random_dataspace(OBJECT_VISIT_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) - TEST_ERROR; + /* Make sure not to generate too much data for an attribute to hold */ + do { + if (fspace_id != H5I_INVALID_HID) + H5Sclose(fspace_id); - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) - TEST_ERROR; + if (dset_dtype != H5I_INVALID_HID) + H5Tclose(dset_dtype); + + if ((fspace_id = generate_random_dataspace(OBJECT_VISIT_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) { + TEST_ERROR; + } + + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + TEST_ERROR; + } + + if ((num_elems = H5Sget_simple_extent_npoints(fspace_id)) < 0) + TEST_ERROR; + + if ((elem_size = H5Tget_size(dset_dtype)) == 0) + TEST_ERROR; + + } while (((long unsigned int)num_elems * elem_size) > OBJECT_VISIT_TEST_TOTAL_DATA_SIZE_LIMIT); if ((type_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { H5_FAILED(); @@ -5122,6 +5173,14 @@ test_object_visit(void) goto error; } + if ((attr_id = H5Acreate2(group_id, OBJECT_VISIT_TEST_ATTR_NAME, dset_dtype, fspace_id, H5P_DEFAULT, + H5P_DEFAULT)) == H5I_INVALID_HID) { + H5_FAILED(); + printf(" couldn't create attribute '%s' on group '%s'\n", OBJECT_VISIT_TEST_ATTR_NAME, + OBJECT_VISIT_TEST_SUBGROUP_NAME); + goto error; + } + if ((group_id2 = H5Gcreate2(group_id, OBJECT_VISIT_TEST_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -5129,6 +5188,27 @@ test_object_visit(void) goto error; } + if ((group_id3 = H5Gcreate2(file_id2, OBJECT_VISIT_TEST_GROUP_NAME_PARENT, H5P_DEFAULT, gcpl_id, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create group '%s'\n", OBJECT_VISIT_TEST_GROUP_NAME_PARENT); + goto error; + } + + if ((group_id4 = H5Gcreate2(group_id3, OBJECT_VISIT_TEST_GROUP_NAME_CHILD, H5P_DEFAULT, gcpl_id, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create group '%s'\n", OBJECT_VISIT_TEST_GROUP_NAME_CHILD); + goto error; + } + + if ((group_id5 = H5Gcreate2(group_id4, OBJECT_VISIT_TEST_GROUP_NAME_GRANDCHILD, H5P_DEFAULT, gcpl_id, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + printf(" couldn't create group '%s'\n", OBJECT_VISIT_TEST_GROUP_NAME_GRANDCHILD); + goto error; + } + if ((dset_id = H5Dcreate2(group_id, OBJECT_VISIT_TEST_DSET_NAME, dset_dtype, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -5261,16 +5341,49 @@ test_object_visit(void) } PART_END(H5Ovisit_create_order_decreasing); + PART_BEGIN(H5Ovisit_group) + { + TESTING_2("H5Ovisit on a group"); + + i = 0; + + if (H5Ovisit3(group_id3, H5_INDEX_CRT_ORDER, H5_ITER_INC, object_visit_simple_callback, &i, + H5O_INFO_ALL) < 0) { + H5_FAILED(); + printf(" H5Ovisit on a group failed!\n"); + PART_ERROR(H5Ovisit_group); + } + + if (i != OBJECT_VISIT_TEST_SUBGROUP_LAYERS) { + H5_FAILED(); + printf(" some objects were not visited!\n"); + PART_ERROR(H5Ovisit_group); + } + + PASSED(); + } + PART_END(H5Ovisit_group); + PART_BEGIN(H5Ovisit_file) { TESTING_2("H5Ovisit on a file ID"); - /* - * XXX: - */ + i = 0; + + if (H5Ovisit3(file_id2, H5_INDEX_CRT_ORDER, H5_ITER_INC, object_visit_simple_callback, &i, + H5O_INFO_ALL) < 0) { + H5_FAILED(); + printf(" H5Ovisit on a file ID failed!\n"); + PART_ERROR(H5Ovisit_file); + } + + if (i != OBJECT_VISIT_TEST_NUM_OBJS_VISITED) { + H5_FAILED(); + printf(" some objects were not visited!\n"); + PART_ERROR(H5Ovisit_file); + } - SKIPPED(); - PART_EMPTY(H5Ovisit_file); + PASSED(); } PART_END(H5Ovisit_file); @@ -5304,6 +5417,30 @@ test_object_visit(void) } PART_END(H5Ovisit_dtype); + PART_BEGIN(H5Ovisit_attr) + { + TESTING_2("H5Ovisit on an attribute"); + + i = 0; + + if (H5Ovisit3(attr_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, object_visit_simple_callback, &i, + H5O_INFO_ALL) < 0) { + H5_FAILED(); + printf(" H5Ovisit on an attribute failed!\n"); + PART_ERROR(H5Ovisit_attr); + } + + /* Should have same effect as calling H5Ovisit on group_id */ + if (i != OBJECT_VISIT_TEST_NUM_OBJS_VISITED) { + H5_FAILED(); + printf(" some objects were not visited!\n"); + PART_ERROR(H5Ovisit_attr); + } + + PASSED(); + } + PART_END(H5Ovisit_attr); + PART_BEGIN(H5Ovisit_by_name_obj_name_increasing) { TESTING_2("H5Ovisit_by_name by object name in increasing order"); @@ -5484,12 +5621,22 @@ test_object_visit(void) { TESTING_2("H5Ovisit_by_name on a file ID"); - /* - * XXX: - */ + i = 0; + + if (H5Ovisit_by_name3(file_id2, "/", H5_INDEX_CRT_ORDER, H5_ITER_INC, + object_visit_simple_callback, &i, H5O_INFO_ALL, H5P_DEFAULT) < 0) { + H5_FAILED(); + printf(" H5Ovisit on a file ID failed!\n"); + PART_ERROR(H5Ovisit_by_name_file); + } + + if (i != OBJECT_VISIT_TEST_NUM_OBJS_VISITED) { + H5_FAILED(); + printf(" some objects were not visited!\n"); + PART_ERROR(H5Ovisit_by_name_file); + } - SKIPPED(); - PART_EMPTY(H5Ovisit_by_name_file); + PASSED(); } PART_END(H5Ovisit_by_name_file); @@ -5522,6 +5669,30 @@ test_object_visit(void) PASSED(); } PART_END(H5Ovisit_by_name_dtype); + + PART_BEGIN(H5Ovisit_by_name_attr) + { + TESTING_2("H5Ovisit_by_name on an attribute"); + + i = 0; + + if (H5Ovisit_by_name(attr_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, object_visit_simple_callback, + &i, H5O_INFO_ALL, H5P_DEFAULT) < 0) { + H5_FAILED(); + printf(" H5Ovisit_by_name on an attribute failed!\n"); + PART_ERROR(H5Ovisit_by_name_attr); + } + + /* Should have same effect as calling H5Ovisit on group_id */ + if (i != OBJECT_VISIT_TEST_NUM_OBJS_VISITED) { + H5_FAILED(); + printf(" some objects were not visited!\n"); + PART_ERROR(H5Ovisit_by_name_attr); + } + + PASSED(); + } + PART_END(H5Ovisit_by_name_attr); } END_MULTIPART; @@ -5539,16 +5710,28 @@ test_object_visit(void) TEST_ERROR; if (H5Gclose(group_id2) < 0) TEST_ERROR; + if (H5Gclose(group_id3) < 0) + TEST_ERROR; + if (H5Gclose(group_id4) < 0) + TEST_ERROR; + if (H5Gclose(group_id5) < 0) + TEST_ERROR; + if (H5Aclose(attr_id) < 0) + TEST_ERROR; if (H5Gclose(group_id) < 0) TEST_ERROR; if (H5Gclose(container_group) < 0) TEST_ERROR; if (H5Fclose(file_id) < 0) TEST_ERROR; - + if (H5Fclose(file_id2) < 0) + TEST_ERROR; + if (remove_test_file(NULL, visit_filename) < 0) + TEST_ERROR; + free(visit_filename); PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -5559,13 +5742,20 @@ test_object_visit(void) H5Dclose(dset_id); H5Pclose(gcpl_id); H5Gclose(group_id2); + H5Gclose(group_id3); + H5Gclose(group_id4); + H5Gclose(group_id5); + H5Aclose(attr_id); H5Gclose(group_id); H5Gclose(container_group); H5Fclose(file_id); + H5Fclose(file_id2); + remove_test_file(NULL, visit_filename); + free(visit_filename); } - H5E_END_TRY + H5E_END_TRY; - return 1; + return; } /* @@ -5577,7 +5767,7 @@ test_object_visit(void) * the links to ensure that the objects in the other group * do not get visited. */ -static int +static void test_object_visit_soft_link(void) { size_t i; @@ -5596,7 +5786,7 @@ test_object_visit_soft_link(void) SKIPPED(); printf(" API functions for basic file, group, object, soft link, or iterate " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -6040,7 +6230,7 @@ test_object_visit_soft_link(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6055,14 +6245,14 @@ test_object_visit_soft_link(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Ovisit(_by_name) fails when * it is passed invalid parameters. */ -static int +static void test_object_visit_invalid_params(void) { herr_t err_ret = -1; @@ -6077,7 +6267,7 @@ test_object_visit_invalid_params(void) !(vol_cap_flags_g & H5VL_CAP_FLAG_ITERATE)) { SKIPPED(); printf(" API functions for basic file, group, or iterate aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -6361,7 +6551,7 @@ test_object_visit_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6373,13 +6563,13 @@ test_object_visit_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test for H5Oclose. */ -static int +static void test_close_object(void) { hid_t file_id = H5I_INVALID_HID; @@ -6400,7 +6590,7 @@ test_close_object(void) SKIPPED(); printf(" API functions for basic file, group, object, dataset, attribute, or stored datatype " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -6424,10 +6614,10 @@ test_close_object(void) goto error; } - if ((fspace_id = generate_random_dataspace(OBJECT_CLOSE_TEST_SPACE_RANK, NULL, NULL, FALSE)) < 0) + if ((fspace_id = generate_random_dataspace(OBJECT_CLOSE_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) + if ((dset_dtype = generate_random_datatype(H5T_NO_CLASS, false)) < 0) TEST_ERROR; PASSED(); @@ -6504,7 +6694,7 @@ test_close_object(void) { TESTING_2("H5Oclose on a committed datatype"); - if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, FALSE)) < 0) { + if ((dtype_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) { H5_FAILED(); printf(" couldn't create datatype '%s'\n", OBJECT_CLOSE_TEST_TYPE_NAME); PART_ERROR(H5Oclose_dtype); @@ -6556,7 +6746,7 @@ test_close_object(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6572,14 +6762,14 @@ test_close_object(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that H5Oclose fails when it * is passed invalid parameters. */ -static int +static void test_close_object_invalid_params(void) { herr_t err_ret = -1; @@ -6591,7 +6781,7 @@ test_close_object_invalid_params(void) if (!(vol_cap_flags_g & (H5VL_CAP_FLAG_FILE_BASIC)) || !(vol_cap_flags_g & H5VL_CAP_FLAG_OBJECT_BASIC)) { SKIPPED(); printf(" API functions for basic file or object aren't supported with this connector\n"); - return 0; + return; } if ((file_id = H5Fopen(H5_API_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -6617,7 +6807,7 @@ test_close_object_invalid_params(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6626,14 +6816,14 @@ test_close_object_invalid_params(void) } H5E_END_TRY - return 1; + return; } /* * A test to check that various objects (file, dataspace, property list, * and attribute) can't be closed with H5Oclose. */ -static int +static void test_close_invalid_objects(void) { hid_t file_id = H5I_INVALID_HID; @@ -6652,7 +6842,7 @@ test_close_invalid_objects(void) SKIPPED(); printf(" API functions for basic file, group, or object " "aren't supported with this connector\n"); - return 0; + return; } TESTING_2("test setup"); @@ -6679,11 +6869,11 @@ test_close_invalid_objects(void) goto error; } - if ((attr_space_id = generate_random_dataspace(OBJECT_CLOSE_INVALID_TEST_SPACE_RANK, NULL, NULL, TRUE)) < + if ((attr_space_id = generate_random_dataspace(OBJECT_CLOSE_INVALID_TEST_SPACE_RANK, NULL, NULL, true)) < 0) TEST_ERROR; - if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, TRUE)) < 0) + if ((attr_dtype = generate_random_datatype(H5T_NO_CLASS, true)) < 0) TEST_ERROR; if ((attr_id = H5Acreate2(group_id, OBJECT_CLOSE_INVALID_TEST_ATTRIBUTE_NAME, attr_dtype, attr_space_id, @@ -6795,7 +6985,7 @@ test_close_invalid_objects(void) PASSED(); - return 0; + return; error: H5E_BEGIN_TRY @@ -6810,61 +7000,61 @@ test_close_invalid_objects(void) } H5E_END_TRY - return 1; + return; } /* test_close_invalid_objects */ /* * A test for H5Oflush. */ -static int +static void test_flush_object(void) { TESTING("H5Oflush"); SKIPPED(); - return 0; + return; } /* * A test to check that H5Oflush fails when * it is passed invalid parameters. */ -static int +static void test_flush_object_invalid_params(void) { TESTING("H5Oflush with invalid parameters"); SKIPPED(); - return 0; + return; } /* * A test for H5Orefresh. */ -static int +static void test_refresh_object(void) { TESTING("H5Orefresh"); SKIPPED(); - return 0; + return; } /* * A test to check that H5Orefresh fails when * it is passed invalid parameters. */ -static int +static void test_refresh_object_invalid_params(void) { TESTING("H5Orefresh with invalid parameters"); SKIPPED(); - return 0; + return; } /* @@ -6887,7 +7077,7 @@ object_copy_attribute_iter_callback(hid_t location_id, const char *attr_name, co snprintf(expected_name, 256, "attr%d", (int)(*counter)); - if (HDstrncmp(attr_name, expected_name, 256)) { + if (strncmp(attr_name, expected_name, 256)) { printf(" attribute name '%s' did not match expected name '%s'\n", attr_name, expected_name); ret_value = H5_ITER_ERROR; goto done; @@ -7032,28 +7222,28 @@ object_visit_callback(hid_t o_id, const char *name, const H5O_info2_t *object_in UNUSED(o_id); - if (!HDstrncmp(name, ".", strlen(".") + 1) && + if (!strncmp(name, ".", strlen(".") + 1) && (counter_val == 0 || counter_val == 4 || counter_val == 8 || counter_val == 12)) { if (H5O_TYPE_GROUP == object_info->type) goto done; else printf(" type for object '%s' was not H5O_TYPE_GROUP\n", name); } - else if (!HDstrncmp(name, OBJECT_VISIT_TEST_GROUP_NAME, strlen(OBJECT_VISIT_TEST_GROUP_NAME) + 1) && + else if (!strncmp(name, OBJECT_VISIT_TEST_GROUP_NAME, strlen(OBJECT_VISIT_TEST_GROUP_NAME) + 1) && (counter_val == 2 || counter_val == 6 || counter_val == 9 || counter_val == 15)) { if (H5O_TYPE_GROUP == object_info->type) goto done; else printf(" type for object '%s' was not H5O_TYPE_GROUP\n", name); } - else if (!HDstrncmp(name, OBJECT_VISIT_TEST_DSET_NAME, strlen(OBJECT_VISIT_TEST_DSET_NAME) + 1) && + else if (!strncmp(name, OBJECT_VISIT_TEST_DSET_NAME, strlen(OBJECT_VISIT_TEST_DSET_NAME) + 1) && (counter_val == 1 || counter_val == 7 || counter_val == 10 || counter_val == 14)) { if (H5O_TYPE_DATASET == object_info->type) goto done; else printf(" type for object '%s' was not H5O_TYPE_DATASET\n", name); } - else if (!HDstrncmp(name, OBJECT_VISIT_TEST_TYPE_NAME, strlen(OBJECT_VISIT_TEST_TYPE_NAME) + 1) && + else if (!strncmp(name, OBJECT_VISIT_TEST_TYPE_NAME, strlen(OBJECT_VISIT_TEST_TYPE_NAME) + 1) && (counter_val == 3 || counter_val == 5 || counter_val == 11 || counter_val == 13)) { if (H5O_TYPE_NAMED_DATATYPE == object_info->type) goto done; @@ -7071,6 +7261,29 @@ object_visit_callback(hid_t o_id, const char *name, const H5O_info2_t *object_in return ret_val; } +/* + * H5Ovisit callback to count the number of visited objects + */ +static herr_t +object_visit_simple_callback(hid_t o_id, const char *name, const H5O_info2_t *object_info, void *op_data) +{ + size_t *i = (size_t *)op_data; + herr_t ret_val = 0; + + UNUSED(o_id); + UNUSED(object_info); + + if (name) + goto done; + + ret_val = -1; + +done: + (*i)++; + + return ret_val; +} + /* * H5Ovisit callback for visiting a singular dataset. */ @@ -7082,7 +7295,7 @@ object_visit_dset_callback(hid_t o_id, const char *name, const H5O_info2_t *obje UNUSED(o_id); UNUSED(op_data); - if (HDstrncmp(name, ".", strlen(".") + 1)) { + if (strncmp(name, ".", strlen(".") + 1)) { printf(" object '%s' didn't match known names\n", name); return -1; } @@ -7106,7 +7319,7 @@ object_visit_dtype_callback(hid_t o_id, const char *name, const H5O_info2_t *obj UNUSED(o_id); UNUSED(op_data); - if (HDstrncmp(name, ".", strlen(".") + 1)) { + if (strncmp(name, ".", strlen(".") + 1)) { printf(" object '%s' didn't match known names\n", name); return -1; } @@ -7132,7 +7345,15 @@ object_visit_soft_link_callback(hid_t o_id, const char *name, const H5O_info2_t UNUSED(o_id); - if (!HDstrncmp(name, ".", strlen(".") + 1) && (counter_val <= 5)) { + if (!strcmp(name, OBJECT_VISIT_TEST_GROUP_NAME_PARENT) || + !strcmp(name, OBJECT_VISIT_TEST_GROUP_NAME_PARENT "/" OBJECT_VISIT_TEST_GROUP_NAME_CHILD) || + !strcmp(name, OBJECT_VISIT_TEST_GROUP_NAME_PARENT "/" OBJECT_VISIT_TEST_GROUP_NAME_CHILD + "/" OBJECT_VISIT_TEST_GROUP_NAME_GRANDCHILD)) { + (*i)--; + goto done; + } + + if (!strncmp(name, ".", strlen(".") + 1) && (counter_val <= 5)) { if (H5O_TYPE_GROUP == object_info->type) goto done; else @@ -7164,40 +7385,60 @@ 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 *obj_copy_filename = NULL; - - prefix_filename(test_path_prefix, OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME, &obj_copy_filename); - - H5Fdelete(obj_copy_filename, H5P_DEFAULT); - free(obj_copy_filename); -} - -int -H5_api_object_test(void) +void +H5_api_object_test_add(void) { - size_t i; - int nerrors; - - printf("**********************************************\n"); - printf("* *\n"); - printf("* API Object Tests *\n"); - printf("* *\n"); - printf("**********************************************\n\n"); - - for (i = 0, nerrors = 0; i < ARRAY_LENGTH(object_tests); i++) { - nerrors += (*object_tests[i])() ? 1 : 0; - } - - printf("\n"); - - printf("Cleaning up testing files\n"); - cleanup_files(); - - return nerrors; + /* Add a fake test to print out a header to distinguish different test interfaces */ + AddTest("print_object_test_header", print_object_test_header, NULL, "Prints header for object tests", + NULL); + + AddTest("test_open_object", MT_API_TEST_FUNC_OUTER(test_open_object), NULL, "object opening", NULL); + AddTest("test_open_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_object_invalid_params), NULL, + "object opening with invalid parameters", NULL); + AddTest("test_object_exists", MT_API_TEST_FUNC_OUTER(test_object_exists), NULL, "object existence", NULL); + AddTest("test_object_exists_invalid_params", MT_API_TEST_FUNC_OUTER(test_object_exists_invalid_params), NULL, + "object existence with invalid parameters", NULL); + AddTest("test_get_object_info", MT_API_TEST_FUNC_OUTER(test_get_object_info), NULL, "object info retrieval", NULL); + AddTest("test_get_object_info_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_object_info_invalid_params), NULL, + "object info retrieval with invalid parameters", NULL); + AddTest("test_link_object", MT_API_TEST_FUNC_OUTER(test_link_object), NULL, "object linking", NULL); + AddTest("test_link_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_link_object_invalid_params), NULL, + "object linking with invalid parameters", NULL); + AddTest("test_incr_decr_object_refcount", MT_API_TEST_FUNC_OUTER(test_incr_decr_object_refcount), NULL, + "increment/decrement the reference count of object", NULL); + AddTest("test_incr_decr_object_refcount_invalid_params", MT_API_TEST_FUNC_OUTER(test_incr_decr_object_refcount_invalid_params), + NULL, "object reference count incr./decr. with an invalid parameter", NULL); + AddTest("test_object_copy_basic", MT_API_TEST_FUNC_OUTER(test_object_copy_basic), NULL, "basic object copying", NULL); + AddTest("test_object_copy_already_existing", MT_API_TEST_FUNC_OUTER(test_object_copy_already_existing), NULL, + "object copying to location where objects already exist", NULL); + AddTest("test_object_copy_shallow_group_copy", MT_API_TEST_FUNC_OUTER(test_object_copy_shallow_group_copy), NULL, + "object copying with H5O_COPY_SHALLOW_HIERARCHY_FLAG flag", NULL); + AddTest("test_object_copy_no_attributes", MT_API_TEST_FUNC_OUTER(test_object_copy_no_attributes), NULL, + "object copying with H5O_COPY_WITHOUT_ATTR_FLAG flag", NULL); + AddTest("test_object_copy_by_soft_link", MT_API_TEST_FUNC_OUTER(test_object_copy_by_soft_link), NULL, + "object copying through use of soft links", NULL); + AddTest("test_object_copy_group_with_soft_links", MT_API_TEST_FUNC_OUTER(test_object_copy_group_with_soft_links), NULL, + "group copying when group contains soft links", NULL); + AddTest("test_object_copy_between_files", MT_API_TEST_FUNC_OUTER(test_object_copy_between_files), NULL, + "object copying between files", NULL); + AddTest("test_object_copy_invalid_params", MT_API_TEST_FUNC_OUTER(test_object_copy_invalid_params), NULL, + "object copying with invalid parameters", NULL); + AddTest("test_object_comments", MT_API_TEST_FUNC_OUTER(test_object_comments), NULL, "object comments", NULL); + AddTest("test_object_comments_invalid_params", MT_API_TEST_FUNC_OUTER(test_object_comments_invalid_params), NULL, + "object comments with invalid parameters", NULL); + AddTest("test_object_visit", MT_API_TEST_FUNC_OUTER(test_object_visit), NULL, "object visiting", NULL); + AddTest("test_object_visit_soft_link", MT_API_TEST_FUNC_OUTER(test_object_visit_soft_link), NULL, + "object visiting with soft links", NULL); + AddTest("test_object_visit_invalid_params", MT_API_TEST_FUNC_OUTER(test_object_visit_invalid_params), NULL, + "object visiting with invalid parameters", NULL); + AddTest("test_close_object", MT_API_TEST_FUNC_OUTER(test_close_object), NULL, "H5Oclose", NULL); + AddTest("test_close_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_close_object_invalid_params), NULL, + "H5Oclose with an invalid object ID", NULL); + AddTest("test_close_invalid_objects", MT_API_TEST_FUNC_OUTER(test_close_invalid_objects), NULL, "H5Oclose invalid objects", NULL); + AddTest("test_flush_object", MT_API_TEST_FUNC_OUTER(test_flush_object), NULL, "H5Oflush", NULL); + AddTest("test_flush_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_flush_object_invalid_params), NULL, + "H5Oflush with invalid parameters", NULL); + AddTest("test_refresh_object", MT_API_TEST_FUNC_OUTER(test_refresh_object), NULL, "H5Orefresh", NULL); + AddTest("test_refresh_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_refresh_object_invalid_params), NULL, + "H5Orefresh with invalid parameters", NULL); } diff --git a/test/API/H5_api_object_test.h b/test/API/H5_api_object_test.h index 75c39613100..60832db7537 100644 --- a/test/API/H5_api_object_test.h +++ b/test/API/H5_api_object_test.h @@ -15,7 +15,7 @@ #include "H5_api_test.h" -int H5_api_object_test(void); +void H5_api_object_test_add(void); /*********************************************** * * @@ -121,12 +121,19 @@ int H5_api_object_test(void); #define OBJECT_COPY_INVALID_PARAMS_TEST_GROUP_NAME "object_copy_invalid_params_group" #define OBJECT_COPY_INVALID_PARAMS_TEST_GROUP_NAME2 "object_copy_invalid_params_group_copy" -#define OBJECT_VISIT_TEST_NUM_OBJS_VISITED 4 -#define OBJECT_VISIT_TEST_SUBGROUP_NAME "object_visit_test" -#define OBJECT_VISIT_TEST_SPACE_RANK 2 -#define OBJECT_VISIT_TEST_GROUP_NAME "object_visit_test_group" -#define OBJECT_VISIT_TEST_DSET_NAME "object_visit_test_dset" -#define OBJECT_VISIT_TEST_TYPE_NAME "object_visit_test_type" +#define OBJECT_VISIT_TEST_NUM_OBJS_VISITED 4 +#define OBJECT_VISIT_TEST_SUBGROUP_NAME "object_visit_test" +#define OBJECT_VISIT_TEST_SPACE_RANK 2 +#define OBJECT_VISIT_TEST_GROUP_NAME "object_visit_test_group" +#define OBJECT_VISIT_TEST_DSET_NAME "object_visit_test_dset" +#define OBJECT_VISIT_TEST_TYPE_NAME "object_visit_test_type" +#define OBJECT_VISIT_TEST_ATTR_NAME "object_visit_test_attr" +#define OBJECT_VISIT_TEST_FILE_NAME "object_visit_test_file" +#define OBJECT_VISIT_TEST_SUBGROUP_LAYERS 3 +#define OBJECT_VISIT_TEST_GROUP_NAME_PARENT "object_visit_test_group_parent" +#define OBJECT_VISIT_TEST_GROUP_NAME_CHILD "object_visit_test_group_child" +#define OBJECT_VISIT_TEST_GROUP_NAME_GRANDCHILD "object_visit_test_group_grandchild" +#define OBJECT_VISIT_TEST_TOTAL_DATA_SIZE_LIMIT 32000 #define OBJECT_VISIT_SOFT_LINK_TEST_NUM_OBJS_VISITED 1 #define OBJECT_VISIT_SOFT_LINK_TEST_SUBGROUP_NAME "object_visit_soft_link" diff --git a/test/API/H5_api_test.c b/test/API/H5_api_test.c index f8062912eee..da16149cf41 100644 --- a/test/API/H5_api_test.c +++ b/test/API/H5_api_test.c @@ -46,15 +46,13 @@ char H5_api_test_filename[H5_API_TEST_FILENAME_MAX_LENGTH]; #endif -/* Run the API tests within a single thread */ -static void *run_h5_API_tests_thread(void *thread_info); - - - -const char *test_path_prefix; +const char *test_path_prefix = NULL; size_t active_thread_ct = 0; +/* Margin of runtime for each subtest allocated to cleanup */ +#define API_TEST_MARGIN 1 + /* X-macro to define the following for each test: * - enum type * - name @@ -64,27 +62,27 @@ size_t active_thread_ct = 0; #ifdef H5_API_TEST_HAVE_ASYNC #define H5_API_TESTS \ X(H5_API_TEST_NULL, "", NULL, 0) \ - X(H5_API_TEST_FILE, "file", H5_api_file_test, 1) \ - X(H5_API_TEST_GROUP, "group", H5_api_group_test, 1) \ - X(H5_API_TEST_DATASET, "dataset", H5_api_dataset_test, 1) \ - X(H5_API_TEST_DATATYPE, "datatype", H5_api_datatype_test, 1) \ - X(H5_API_TEST_ATTRIBUTE, "attribute", H5_api_attribute_test, 1) \ - X(H5_API_TEST_LINK, "link", H5_api_link_test, 1) \ - X(H5_API_TEST_OBJECT, "object", H5_api_object_test, 1) \ - X(H5_API_TEST_MISC, "misc", H5_api_misc_test, 1) \ - X(H5_API_TEST_ASYNC, "async", H5_api_async_test, 1) \ + X(H5_API_TEST_FILE, "file", H5_api_file_test_add, 1) \ + X(H5_API_TEST_GROUP, "group", H5_api_group_test_add, 1) \ + X(H5_API_TEST_DATASET, "dataset", H5_api_dataset_test_add, 1) \ + X(H5_API_TEST_DATATYPE, "datatype", H5_api_datatype_test_add, 1) \ + X(H5_API_TEST_ATTRIBUTE, "attribute", H5_api_attribute_test_add, 1) \ + X(H5_API_TEST_LINK, "link", H5_api_link_test_add, 1) \ + X(H5_API_TEST_OBJECT, "object", H5_api_object_test_add, 1) \ + X(H5_API_TEST_MISC, "misc", H5_api_misc_test_add, 1) \ + X(H5_API_TEST_ASYNC, "async", H5_api_async_test_add, 1) \ X(H5_API_TEST_MAX, "", NULL, 0) #else #define H5_API_TESTS \ X(H5_API_TEST_NULL, "", NULL, 0) \ - X(H5_API_TEST_FILE, "file", H5_api_file_test, 1) \ - X(H5_API_TEST_GROUP, "group", H5_api_group_test, 1) \ - X(H5_API_TEST_DATASET, "dataset", H5_api_dataset_test, 1) \ - X(H5_API_TEST_DATATYPE, "datatype", H5_api_datatype_test, 1) \ - X(H5_API_TEST_ATTRIBUTE, "attribute", H5_api_attribute_test, 1) \ - X(H5_API_TEST_LINK, "link", H5_api_link_test, 1) \ - X(H5_API_TEST_OBJECT, "object", H5_api_object_test, 1) \ - X(H5_API_TEST_MISC, "misc", H5_api_misc_test, 1) \ + X(H5_API_TEST_FILE, "file", H5_api_file_test_add, 1) \ + X(H5_API_TEST_GROUP, "group", H5_api_group_test_add, 1) \ + X(H5_API_TEST_DATASET, "dataset", H5_api_dataset_test_add, 1) \ + X(H5_API_TEST_DATATYPE, "datatype", H5_api_datatype_test_add, 1) \ + X(H5_API_TEST_ATTRIBUTE, "attribute", H5_api_attribute_test_add, 1) \ + X(H5_API_TEST_LINK, "link", H5_api_link_test_add, 1) \ + X(H5_API_TEST_OBJECT, "object", H5_api_object_test_add, 1) \ + X(H5_API_TEST_MISC, "misc", H5_api_misc_test_add, 1) \ X(H5_API_TEST_MAX, "", NULL, 0) #endif @@ -95,14 +93,12 @@ enum H5_api_test_type { H5_API_TESTS }; static const char *const H5_api_test_name[] = {H5_API_TESTS}; #undef X #define X(a, b, c, d) c, -static int (*H5_api_test_func[])(void) = {H5_API_TESTS}; +static void (*H5_api_test_add_func[])(void) = {H5_API_TESTS}; #undef X #define X(a, b, c, d) d, static int H5_api_test_enabled[] = {H5_API_TESTS}; #undef X -#define MAX_THREAD_ID_LEN 16 - static enum H5_api_test_type H5_api_test_name_to_type(const char *test_name) { @@ -114,113 +110,123 @@ H5_api_test_name_to_type(const char *test_name) return ((i == H5_API_TEST_MAX) ? H5_API_TEST_NULL : i); } -/******************************************************************************/ static void -H5_api_test_run(void) +H5_api_test_add(void) { enum H5_api_test_type i; for (i = H5_API_TEST_FILE; i < H5_API_TEST_MAX; i++) if (H5_api_test_enabled[i]) - (void)H5_api_test_func[i](); + H5_api_test_add_func[i](); } - -/* Run the API tests from a single thread. - * Returns: Pointer to the input thread_info_t structure. - * A result summary of the tests run can be found in threat_info_t->result - */ -void * -run_h5_API_tests_thread(void *thread_info) +static int +parse_command_line(int argc, char **argv) { - unsigned seed; - hid_t fapl_id = H5I_INVALID_HID; - hid_t default_con_id = H5I_INVALID_HID; - hid_t registered_con_id = H5I_INVALID_HID; - thread_info_t *tinfo = NULL; - int chars_written; - size_t tests_failed = 0; - - if (!thread_info) { - fprintf(stderr, "Thread info is NULL\n"); - tinfo->result = API_TEST_ERROR; - goto done; - } - - tinfo = (thread_info_t *)thread_info; - -#ifdef H5_HAVE_MULTITHREAD - if (pthread_setspecific(thread_info_key_g, (void *)tinfo) != 0) { - fprintf(stderr, "Error setting thread-specific data\n"); - tinfo->result = API_TEST_ERROR; - goto done; + /* Simple argument checking, TODO can improve that later */ + if (argc > 1) { + enum H5_api_test_type i = H5_api_test_name_to_type(argv[argc - 1]); + if (i != H5_API_TEST_NULL) { + /* Run only specific API test */ + memset(H5_api_test_enabled, 0, sizeof(H5_api_test_enabled)); + H5_api_test_enabled[i] = 1; + } } -#endif - - printf("%zu: Running API tests\n", tinfo->thread_idx); + return 0; +} - seed = (unsigned)HDtime(NULL); - srand(seed); +static void +usage(void) +{ + print_func("file run only the file interface tests\n"); + print_func("group run only the group interface tests\n"); + print_func("dataset run only the dataset interface tests\n"); + print_func("attribute run only the attribute interface tests\n"); + print_func("datatype run only the datatype interface tests\n"); + print_func("link run only the link interface tests\n"); + print_func("object run only the object interface tests\n"); + print_func("misc run only the miscellaneous tests\n"); + print_func("async run only the async interface tests\n"); +} - if ((test_path_prefix = HDgetenv(HDF5_API_TEST_PATH_PREFIX)) == NULL) - test_path_prefix = (const char *)""; -#ifdef H5_HAVE_MULTITHREAD - if (MAX_THREAD_ID_LEN + strlen(test_path_prefix) + strlen(TEST_FILE_NAME) >= H5_API_TEST_FILENAME_MAX_LENGTH) { - fprintf(stderr, "Test file name exceeded expected size\n"); - tinfo->result = API_TEST_ERROR; - goto done; +int +main(int argc, char **argv) +{ + H5E_auto2_t default_err_func; + void *default_err_data = NULL; + bool err_occurred = false; + + unsigned runtime = 0; /* Maximum run-time for test (in seconds) */ + unsigned num_subtests = 8; + unsigned subtest_timeout = 0; + + int testExpress = 0; + int num_errs_occurred = 0; + + H5open(); + + /* Store current error stack printing function since TestInit unsets it */ + H5Eget_auto2(H5E_DEFAULT, &default_err_func, &default_err_data); + /* Initialize testing framework */ + TestInit(argv[0], usage, NULL); + /* Reset error stack printing function */ + H5Eset_auto2(H5E_DEFAULT, default_err_func, default_err_data); + + /* Hide all output from testing framework and replace with our own */ + SetTestVerbosity(VERBO_NONE); + + /* Parse command line separately from the test framework since + * tests need to be added before TestParseCmdLine in order for + * the -help option to show them, but we need to know ahead of + * time which tests to add if only a specific interface's tests + * are going to be run. + */ + parse_command_line(argc, argv); + + testExpress = GetTestExpress(); + + if (testExpress == 0) { + runtime = 0; /* Run with no timeout */ + } else if (testExpress == 1) { + runtime = 1800; /* 30 minute timeout */ + } else if (testExpress == 2) { + runtime = 600; /* 10 minute timeout */ + } else { + runtime = 60; /* 1 minute timeout */ } - if (NULL == (tinfo->H5_api_test_filename = (char *)calloc(1, H5_API_TEST_FILENAME_MAX_LENGTH))) { - fprintf(stderr, "Unable to allocate memory for test file name\n"); - tinfo->result = API_TEST_ERROR; - goto done; + if (testExpress > 0) { + subtest_timeout = (runtime - API_TEST_MARGIN) / num_subtests; + } else { + subtest_timeout = 0; } - if ((chars_written = HDsnprintf(tinfo->H5_api_test_filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%zu%s%s", tinfo->thread_idx, test_path_prefix, - TEST_FILE_NAME)) < 0) { - fprintf(stderr, "Error while creating test file name\n"); - tinfo->result = API_TEST_ERROR; - goto done; - } -#else - if ((chars_written = HDsnprintf(H5_api_test_filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%zu%s%s", tinfo->thread_idx, test_path_prefix, - TEST_FILE_NAME)) < 0) { - fprintf(stderr, "Error while creating test file name\n"); - tinfo->result = API_TEST_ERROR; - goto done; + /* Parse command line arguments */ + TestParseCmdLine(argc, argv); + +#ifndef H5_HAVE_MULTITHREAD + if (GetTestMaxNumThreads() > 1) { + fprintf(stderr, "HDF5 must be built with multi-thread support to run multi-threaded API tests\n"); + exit(EXIT_FAILURE); } #endif - if (chars_written >= H5_API_TEST_FILENAME_MAX_LENGTH) { - fprintf(stderr, "Test file name exceeded expected size\n"); - tinfo->result = API_TEST_ERROR; - goto done; + if (GetTestMaxNumThreads() <= 0) + SetTestMaxNumThreads(API_TESTS_DEFAULT_NUM_THREADS); + + /* API Test Specific Setup */ + if (H5_api_test_global_setup() < 0) { + fprintf(stderr, "Error setting up global API test info\n"); + return EXIT_FAILURE; } + /* Display testing information */ + TestInfo(argv[0]); -#ifndef H5_HAVE_MULTITHREAD - n_tests_run_g = 0; - n_tests_passed_g = 0; - n_tests_failed_g = 0; - n_tests_skipped_g = 0; -#endif - - printf("Running API tests with VOL connector '%s' and info string '%s'\n\n", tinfo->vol_connector_name, - tinfo->vol_connector_info ? tinfo->vol_connector_info : ""); - printf("Test parameters:\n"); - printf(" - Test file name: '%s'\n", H5_API_TEST_FILENAME); - printf(" - Test seed: %u\n", seed); - printf(" - Test path prefix: '%s'\n", test_path_prefix); - printf("\n\n"); - - if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { - fprintf(stderr, "Unable to create FAPL\n"); - tinfo->result = API_TEST_ERROR; - goto done; - } + /* TODO: Refactor TestAlarmOn to accept specific timeout */ + TestAlarmOn(); /* * If using a VOL connector other than the native @@ -229,328 +235,41 @@ run_h5_API_tests_thread(void *thread_info) * Otherwise, HDF5 will default to running the tests * with the native connector, which could be misleading. */ - if (0 != HDstrcmp(tinfo->vol_connector_name, "native")) { - htri_t is_registered; - - if ((is_registered = H5VLis_connector_registered_by_name(tinfo->vol_connector_name)) < 0) { - fprintf(stderr, "Unable to determine if VOL connector is registered\n"); - tinfo->result = API_TEST_ERROR; - goto done; - } - - if (!is_registered) { - fprintf(stderr, "Specified VOL connector '%s' wasn't correctly registered!\n", - tinfo->vol_connector_name); - tinfo->result = API_TEST_ERROR; - goto done; - } - else { - /* - * If the connector was successfully registered, check that - * the connector ID set on the default FAPL matches the ID - * for the registered connector before running the tests. - */ - if (H5Pget_vol_id(fapl_id, &default_con_id) < 0) { - fprintf(stderr, "Couldn't retrieve ID of VOL connector set on default FAPL\n"); - tinfo->result = API_TEST_ERROR; - goto done; - } - - if ((registered_con_id = H5VLget_connector_id_by_name(tinfo->vol_connector_name)) < 0) { - fprintf(stderr, "Couldn't retrieve ID of registered VOL connector\n"); - tinfo->result = API_TEST_ERROR; - goto done; - } - - if (default_con_id != registered_con_id) { - fprintf(stderr, "VOL connector set on default FAPL didn't match specified VOL connector\n"); - tinfo->result = API_TEST_ERROR; - goto done; - } - } - } - - /* - * Create the file that will be used for all of the tests, - * except for those which test file creation. - */ - if (create_test_container(H5_API_TEST_FILENAME, vol_cap_flags_g) < 0) { - fprintf(stderr, "Unable to create testing container file '%s'\n", H5_API_TEST_FILENAME); - tinfo->result = API_TEST_ERROR; - goto done; + if (H5_api_check_vol_registration() < 0) { + fprintf(stderr, "Active VOL connector not properly registered\n"); + return EXIT_FAILURE; } - /* Run all the tests that are enabled */ - H5_api_test_run(); - - printf("Cleaning up testing files\n"); - - H5Fdelete(H5_API_TEST_FILENAME, fapl_id); - -/* -#ifndef H5_HAVE_MULTITHREAD - tinfo->n_tests_run_g = n_tests_run_g; - tinfo->n_tests_passed_g = n_tests_passed_g; - tinfo->n_tests_failed_g = n_tests_failed_g; - tinfo->n_tests_skipped_g = n_tests_skipped_g; -#endif -*/ - -#ifdef H5_HAVE_MULTITHREAD - tests_failed = atomic_load(&n_tests_failed_g); -#else - tests_failed = n_tests_failed_g; -#endif - if (tests_failed > 0) { - tinfo->result = API_TEST_FAIL; - } -done: - if (tinfo && tinfo->H5_api_test_filename) - free(tinfo->H5_api_test_filename); - - if (default_con_id >= 0 && H5VLclose(default_con_id) < 0) { - fprintf(stderr, "Unable to close VOL connector ID\n"); - tinfo->result = API_TEST_ERROR; - } - - if (registered_con_id >= 0 && H5VLclose(registered_con_id) < 0) { - fprintf(stderr, "Unable to close VOL connector ID\n"); - tinfo->result = API_TEST_ERROR; - } - - if (fapl_id >= 0 && H5Pclose(fapl_id) < 0) { - fprintf(stderr, "Unable to close FAPL\n"); - tinfo->result = API_TEST_ERROR; - } - -#ifdef H5_HAVE_MULTITHREAD - pthread_exit((void *)tinfo); -#else - return (void *)tinfo; -#endif -} + H5_api_test_add(); -int -main(int argc, char **argv) -{ - void* retval = NULL; - int ret_value = EXIT_SUCCESS; - const char *vol_connector_name = NULL; - char *vol_connector_name_copy = NULL; - char *vol_connector_info = NULL; - hid_t fapl_id = H5I_INVALID_HID; + /* Perform requested testing */ + PerformTests(); -#ifdef H5_HAVE_MULTITHREAD -#define MAX_THREADS 10 - pthread_t threads[MAX_THREADS]; - size_t n_tests_run = 0; - size_t n_tests_passed = 0; - size_t n_tests_failed = 0; - size_t n_tests_skipped = 0; + /* Display test summary, if requested */ + if (GetTestSummary()) + TestSummary(); - memset(threads, 0, sizeof(threads)); -#else -#define MAX_THREADS 1 - active_thread_ct = 1; - n_tests_run_g = 0; - n_tests_passed_g = 0; - n_tests_failed_g = 0; - n_tests_skipped_g = 0; - -#endif - thread_info_t tinfo[MAX_THREADS]; - htri_t results[MAX_THREADS]; - - memset(tinfo, 0, sizeof(tinfo)); - memset(results, 0, sizeof(results)); - - /* Simple argument checking, TODO can improve that later */ - if (argc > 1) { - enum H5_api_test_type i = H5_api_test_name_to_type(argv[1]); - if (i != H5_API_TEST_NULL) { - /* Run only specific API test */ - memset(H5_api_test_enabled, 0, sizeof(H5_api_test_enabled)); - H5_api_test_enabled[i] = 1; - } - } - - if (NULL == (vol_connector_name = HDgetenv(HDF5_VOL_CONNECTOR))) { - printf("No VOL connector selected; using native VOL connector\n"); - vol_connector_name = "native"; - vol_connector_info = NULL; - } - else { - char *token; - - if (NULL == (vol_connector_name_copy = HDstrdup(vol_connector_name))) { - fprintf(stderr, "Unable to copy VOL connector string\n"); - ret_value = FAIL; - goto done; - } - - if (NULL == (token = HDstrtok(vol_connector_name_copy, " "))) { - fprintf(stderr, "Error while parsing VOL connector string\n"); - ret_value = FAIL; - goto done; - } - - vol_connector_name = token; - - if (NULL != (token = HDstrtok(NULL, " "))) { - vol_connector_info = token; - } - } - -#ifdef H5_HAVE_PARALLEL - /* If HDF5 was built with parallel enabled, go ahead and call MPI_Init before - * running these tests. Even though these are meant to be serial tests, they will - * likely be run using mpirun (or similar) and we cannot necessarily expect HDF5 or - * an HDF5 VOL connector to call MPI_Init. - */ - MPI_Init(&argc, &argv); -#endif - - - - /* Retrieve the VOL cap flags - work around an HDF5 - * library issue by creating a FAPL - */ - - if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { - fprintf(stderr, "Unable to create FAPL\n"); - ret_value = FAIL; - goto done; - } - - if (H5Pget_vol_cap_flags(fapl_id, &vol_cap_flags_g) < 0) { - fprintf(stderr, "Unable to retrieve VOL connector capability flags\n"); - ret_value = FAIL; - goto done; - } - - if (H5Pclose(fapl_id) < 0) { - fprintf(stderr, "Unable to close FAPL\n"); - ret_value = FAIL; - goto done; - } - - fapl_id = H5I_INVALID_HID; - -#ifdef H5_HAVE_MULTITHREAD - - if (pthread_key_create(&thread_info_key_g, NULL) != 0) { - fprintf(stderr, "Error creating thread-specific data key\n"); - ret_value = FAIL; - goto done; - } - - for (size_t nthreads = 1; nthreads <= MAX_THREADS; nthreads++) { - H5open(); - - /* Execute API tests in each thread */ - active_thread_ct = nthreads; - printf("== Running API tests with %zu thread(s) ==\n", nthreads); - for (size_t thread_idx = 0; thread_idx < nthreads; thread_idx++) { - - tinfo[thread_idx].thread_idx = thread_idx; - tinfo[thread_idx].result = API_TEST_PASS; - tinfo[thread_idx].vol_connector_name = vol_connector_name; - tinfo[thread_idx].vol_connector_info = vol_connector_info; - - if (pthread_create(&threads[thread_idx], NULL, run_h5_API_tests_thread, - (void *)&tinfo[thread_idx]) != 0) { - fprintf(stderr, "Error creating thread %zu\n", thread_idx); - ret_value = FAIL; - goto done; - } - } - - /* Wait for threads to finish */ - for (size_t i = 0; i < nthreads; i++) { - size_t thread_idx = 0; - - if (pthread_join(threads[i], (void *)&retval) != 0) { - fprintf(stderr, "Error joining an API test thread\n"); - ret_value = FAIL; - goto done; - } - - if (!retval) { - fprintf(stderr, "No return from an API tests thread\n"); - exit(EXIT_FAILURE); - } - - thread_idx = ((thread_info_t *)(retval))->thread_idx; - - results[thread_idx] = ((thread_info_t *)(retval))->result; - - if (results[thread_idx] == API_TEST_ERROR) { - fprintf(stderr, "An internal error occurred during API tests in thread %zu\n", thread_idx); - ret_value = 1; - goto done; - } - } + /* Clean up test files, if allowed */ + if (GetTestCleanup() && !HDgetenv(HDF5_NOCLEANUP)) + TestCleanup(); - H5close(); - - /* Display results */ - for (size_t i = 0; i < nthreads; i++) { - if (results[i] == API_TEST_FAIL) { - fprintf(stderr, "A failure occurred during API tests in thread %zu\n", i); - ret_value = FAIL; - } - - if (results[i] == API_TEST_PASS) { - printf("API tests in thread %zu passed\n", i); - } - } + TestAlarmOff(); - printf("Results from API tests run with %zu thread(s):\n", nthreads); - printf("%zu/%zu (%.2f%%) API tests passed with VOL connector '%s'\n", n_tests_passed_g, n_tests_run_g, - ((double) n_tests_passed_g/ (double)n_tests_run_g * 100.0), vol_connector_name); - printf("%zu/%zu (%.2f%%) API tests did not pass with VOL connector '%s'\n", n_tests_failed_g, - n_tests_run_g, ((double)n_tests_failed_g / (double)n_tests_run_g * 100.0), vol_connector_name); - printf("%zu/%zu (%.2f%%) API tests were skipped with VOL connector '%s'\n\n", n_tests_skipped_g, - n_tests_run_g, ((double)n_tests_skipped_g / (double)n_tests_run_g * 100.0), - vol_connector_name); + num_errs_occurred = GetTestNumErrs(); - } + /* Release test infrastructure */ + TestShutdown(); -#else - tinfo[0].thread_idx = 0; - tinfo[0].result = API_TEST_PASS; - tinfo[0].vol_connector_name = vol_connector_name; - tinfo[0].vol_connector_info = vol_connector_info; - - if ((retval = run_h5_API_tests_thread((void*) &tinfo[0])) == NULL) { - fprintf(stderr, "Error running API tests\n"); - ret_value = FAIL; - goto done; + H5close(); + + if (H5_api_test_global_cleanup() < 0) { + fprintf(stderr, "Error cleaning up global API test info\n"); + return EXIT_FAILURE; } - 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, - ((double)n_tests_passed_g / (double)n_tests_run_g * 100.0), tinfo[0].vol_connector_name); - printf("%zu/%zu (%.2f%%) API tests did not pass with VOL connector '%s'\n", n_tests_failed_g, - n_tests_run_g, ((double)n_tests_failed_g / (double)n_tests_run_g * 100.0), tinfo[0].vol_connector_name); - printf("%zu/%zu (%.2f%%) API tests were skipped with VOL connector '%s'\n", n_tests_skipped_g, - n_tests_run_g, ((double)n_tests_skipped_g / (double)n_tests_run_g * 100.0), tinfo[0].vol_connector_name); + if (num_errs_occurred > 0) { + exit(EXIT_FAILURE); } else { - printf("No API tests were run\n"); + exit(EXIT_SUCCESS); } - -#endif - - - -done: - free(vol_connector_name_copy); - - H5close(); - -#ifdef H5_HAVE_PARALLEL - MPI_Finalize(); -#endif - - exit(ret_value); -} +} \ No newline at end of file diff --git a/test/API/H5_api_test.h b/test/API/H5_api_test.h index fdc3a1a9680..d4d05a06f36 100644 --- a/test/API/H5_api_test.h +++ b/test/API/H5_api_test.h @@ -38,11 +38,11 @@ /* The name of the file that all of the tests will operate on */ #define TEST_FILE_NAME "H5_api_test.h5" -extern char H5_api_test_filename[]; - +/* Final name of the API test container file (for this thread) */ #ifdef H5_HAVE_MULTITHREAD -#define H5_API_TEST_FILENAME ((char*) ((thread_info_t*) pthread_getspecific(thread_info_key_g))->H5_api_test_filename) +#define H5_API_TEST_FILENAME (pthread_getspecific(thread_info_key_g) ? ((thread_info_t*) pthread_getspecific(thread_info_key_g))->H5_api_test_filename : NULL) #else +extern char H5_api_test_filename[]; #define H5_API_TEST_FILENAME H5_api_test_filename #endif @@ -75,4 +75,57 @@ extern size_t active_thread_ct; * of a dataspace/datatype. */ #define MAX_DIM_SIZE 16 -#endif +/* Individual API tests may be run serially or in multiple threads. + * If being run in multiple threads, this macro will define a handler + * named _thread which creates and tears down the threads. + * + * TBD: Note that it invokes another macro-defined routine...which sets up threadlocal info... + * */ +#define DECLARE_MT_API_TEST_FUNC_OUTER(func) \ + void func##_thread_outer(void);\ + void func##_thread_outer(void) {\ + pthread_t *threads = NULL;\ + int max_threads = GetTestMaxNumThreads();\ + if ((threads = calloc((size_t) max_threads, sizeof(pthread_t))) == NULL) {\ + TestErrPrintf("Couldn't allocate threads");\ + return ;\ + }\ + for (int64_t i = 0; i < (int64_t) max_threads; i++) { \ + if (pthread_create(&threads[i], NULL, func##_thread_inner, (void*)i) != 0) { \ + TestErrPrintf("Couldn't create API test thread %ld", i); \ + return; \ + } \ + } \ + for (int i = 0; i < max_threads; i++) { \ + if (pthread_join(threads[i], NULL) != 0) { \ + TestErrPrintf("Couldn't join API test thread %d", i); \ + return; \ + } \ + } \ + free(threads); \ + return; \ + } + +#define MT_API_TEST_FUNC_OUTER(func) func##_thread_outer + +/* Invoked by MT_API_TEST_FUNC_OUTER. Sets up thread-local API test info and runs the actual test in this thread. */ +#define DECLARE_MT_API_TEST_FUNC_INNER(func) \ + void *func##_thread_inner(void *arg);\ + void *func##_thread_inner(void *arg) {\ + int64_t thread_idx = (int64_t)arg;\ + if (H5_api_test_thread_setup((int) thread_idx) < 0) {\ + TestErrPrintf("Error setting up thread-local API test info");\ + return (void*)-1;\ + }\ + func();\ + return NULL;\ + }\ + +#define MT_API_TEST_FUNC_INNER(func) func##_thread_inner + +/* Declare the multi-thread helper routines to execute an API test in multiple threads.*/ +#define MULTI_DECLARE(func)\ + DECLARE_MT_API_TEST_FUNC_INNER(func)\ + DECLARE_MT_API_TEST_FUNC_OUTER(func) + +#endif \ No newline at end of file diff --git a/test/API/H5_api_test_util.c b/test/API/H5_api_test_util.c index ee19644fe7e..cfe78f472ce 100644 --- a/test/API/H5_api_test_util.c +++ b/test/API/H5_api_test_util.c @@ -76,6 +76,12 @@ #define COMPACT_SPACE_MAX_DIM_SIZE 4 #define COMPACT_SPACE_MAX_DIMS 3 +/* Allow 3-digit thread indexes (0-999)*/ +#define API_THREAD_IDX_LEN 3 + +#define THREAD_IDX_DIGITS_OFFSET(n) (n > 99 ? 3 : (n > 9 ? 2 : 1)) + + typedef hid_t (*generate_datatype_func)(H5T_class_t parent_class, hbool_t is_compact, size_t depth); static hid_t generate_random_datatype_internal(H5T_class_t parent_class, hbool_t is_compact, size_t depth); static hid_t generate_random_datatype_integer(H5T_class_t parent_class, hbool_t is_compact, size_t depth); @@ -86,6 +92,12 @@ static hid_t generate_random_datatype_reference(H5T_class_t parent_class, hbool_ static hid_t generate_random_datatype_enum(H5T_class_t parent_class, hbool_t is_compact, size_t depth); static hid_t generate_random_datatype_array(H5T_class_t parent_class, hbool_t is_compact, size_t depth); +#ifdef H5_HAVE_MULTITHREAD +static void H5_api_test_tl_key_destructor(void *value); +#endif + +static int H5_api_test_display_information(void); +static int create_test_container_internal(const char *filename, uint64_t vol_cap_flags); /* * Helper function to generate a random HDF5 datatype in order to thoroughly * test support for datatypes. The parent_class parameter is to support @@ -644,17 +656,11 @@ generate_random_dataspace(int rank, const hsize_t *max_dims, hsize_t *dims_out, return H5I_INVALID_HID; } -int -create_test_container(char *filename, uint64_t vol_cap_flags) -{ +static int +create_test_container_internal(const char *filename, uint64_t vol_cap_flags) { hid_t file_id = H5I_INVALID_HID; hid_t group_id = H5I_INVALID_HID; - if (!(vol_cap_flags & H5VL_CAP_FLAG_FILE_BASIC)) { - printf(" VOL connector doesn't support file creation\n"); - goto error; - } - if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { printf(" couldn't create testing container file '%s'\n", filename); goto error; @@ -666,54 +672,46 @@ create_test_container(char *filename, uint64_t vol_cap_flags) */ if ((group_id = H5Gcreate2(file_id, GROUP_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - printf(" created container group for Group tests\n"); H5Gclose(group_id); } if ((group_id = H5Gcreate2(file_id, ATTRIBUTE_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - printf(" created container group for Attribute tests\n"); H5Gclose(group_id); } if ((group_id = H5Gcreate2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - printf(" created container group for Dataset tests\n"); H5Gclose(group_id); } if ((group_id = H5Gcreate2(file_id, DATATYPE_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - printf(" created container group for Datatype tests\n"); H5Gclose(group_id); } if ((group_id = H5Gcreate2(file_id, LINK_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - printf(" created container group for Link tests\n"); H5Gclose(group_id); } if ((group_id = H5Gcreate2(file_id, OBJECT_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - printf(" created container group for Object tests\n"); H5Gclose(group_id); } if ((group_id = H5Gcreate2(file_id, MISCELLANEOUS_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - printf(" created container group for Miscellaneous tests\n"); H5Gclose(group_id); } } if (H5Fclose(file_id) < 0) { - printf(" failed to close testing container\n"); + printf(" failed to close testing container %s\n", filename); goto error; } return 0; - error: H5E_BEGIN_TRY { @@ -723,8 +721,180 @@ create_test_container(char *filename, uint64_t vol_cap_flags) H5E_END_TRY return -1; + +} + + + +int +create_test_container(const char *filename, uint64_t vol_cap_flags) +{ + char *tl_filename = NULL; + + if (!(vol_cap_flags & H5VL_CAP_FLAG_FILE_BASIC)) { + printf(" VOL connector doesn't support file creation\n"); + goto error; + } + +#ifdef H5_HAVE_MULTITHREAD + size_t tl_filename_len = strlen(filename) + API_THREAD_IDX_LEN + 1; + int chars_written = 0; + int max_threads = GetTestMaxNumThreads(); + size_t num_padding = 0; + + if ((tl_filename = (char*)malloc(tl_filename_len)) == NULL) { + printf(" can't allocate space for threadlocal filename\n"); + goto error; + } + + for (int i = 0; i < max_threads; i++) { + /* Set up tl_filename as <3-digit-thread-idx>*/ + + /* First, left-pad with zeros */ + num_padding = (size_t) API_THREAD_IDX_LEN - THREAD_IDX_DIGITS_OFFSET(i); + memset(tl_filename, '0', num_padding); + + chars_written = snprintf(tl_filename + num_padding, + tl_filename_len - num_padding, + "%d%s", i, filename); + + if (chars_written < 0 || (size_t) chars_written >= tl_filename_len - num_padding) { + printf(" thread-local filename buffer overflow\n"); + goto error; + } + + if (create_test_container_internal((const char *)tl_filename, vol_cap_flags) < 0) { + printf(" failed to create thread-local API test container"); + } + + } + + free(tl_filename); + +#else + (void) tl_filename; + if (create_test_container_internal((const char *)filename, vol_cap_flags) < 0) { + printf(" failed to create test container\n"); + goto error; + } +#endif + + return 0; + +error: + free(tl_filename); + return -1; +} + +int destroy_test_container(const char *filename, uint64_t vol_cap_flags) { + char *tl_filename = NULL; + + if (!(vol_cap_flags & H5VL_CAP_FLAG_FILE_BASIC)) { + printf(" container should not have been created\n"); + goto error; + } + +#ifdef H5_HAVE_MULTITHREAD + size_t tl_filename_len = strlen(filename) + API_THREAD_IDX_LEN + 1; + int chars_written = 0; + int max_threads = GetTestMaxNumThreads(); + size_t num_padding = 0; + + if ((tl_filename = (char*)malloc(tl_filename_len)) == NULL) { + printf(" can't allocate space for threadlocal filename\n"); + goto error; + } + + for (int i = 0; i < max_threads; i++) { + /* Set up tl_filename as <3-digit-thread-idx>*/ + + /* First, left-pad with zeros */ + num_padding = (size_t) API_THREAD_IDX_LEN - THREAD_IDX_DIGITS_OFFSET(i); + memset(tl_filename, '0', num_padding); + + chars_written = snprintf(tl_filename + num_padding, + tl_filename_len - num_padding, + "%d%s", i, filename); + + if (chars_written < 0 || (size_t) chars_written >= tl_filename_len - num_padding) { + printf(" thread-local filename buffer overflow\n"); + goto error; + } + + if (H5Fdelete(tl_filename, H5P_DEFAULT) < 0) { + printf(" failed to destroy thread-local API test container"); + goto error; + } + } + + free(tl_filename); + + +#else + (void) tl_filename; + if (H5Fdelete(filename, H5P_DEFAULT) < 0) { + printf(" failed to destroy thread-local API test container"); + goto error; + } +#endif + + return 0; +error: + return -1; +} + +#ifdef H5_HAVE_MULTITHREAD +/* Set up any thread-local variables for individual API tests. + * Must be run from each individual thread in multi-thread scenarios. */ +int H5_api_test_thread_setup(int thread_idx) { + int chars_written = 0; + thread_info_t *tinfo = NULL; + size_t num_padding = 0; + num_padding = (size_t) API_THREAD_IDX_LEN - THREAD_IDX_DIGITS_OFFSET(thread_idx); + + if (API_THREAD_IDX_LEN + strlen(TEST_FILE_NAME) >= H5_API_TEST_FILENAME_MAX_LENGTH) { + TestErrPrintf(" test file name exceeded expected size\n"); + goto error; + } + + if (NULL == (tinfo = (thread_info_t *)calloc(1, sizeof(thread_info_t)))) { + TestErrPrintf(" couldn't allocate memory for thread-specific data\n"); + goto error; + } + + tinfo->thread_idx = thread_idx; + + if (NULL == (tinfo->H5_api_test_filename = (char *)calloc(1, H5_API_TEST_FILENAME_MAX_LENGTH))) { + TestErrPrintf(" couldn't allocate memory for test file name\n"); + goto error; + } + + /* First, left-pad with zeros */ + memset(tinfo->H5_api_test_filename, '0', num_padding); + + /* Set up test filename*/ + if ((chars_written = snprintf(tinfo->H5_api_test_filename + num_padding, + H5_API_TEST_FILENAME_MAX_LENGTH - num_padding, "%s%d%s", + test_path_prefix, thread_idx, TEST_FILE_NAME)) < 0) { + TestErrPrintf(" couldn't create test file name\n"); + goto error; + } + + if (pthread_setspecific(thread_info_key_g, (void *) tinfo) != 0) { + TestErrPrintf(" couldn't set thread-specific data\n"); + goto error; + } + + return 0; + +error: + free(tinfo->H5_api_test_filename); + free(tinfo); + return -1; } +#endif + /* * Add a thread-specific prefix to the given filename. The caller * is responsible for freeing the returned filename @@ -763,14 +933,21 @@ prefix_filename(const char *prefix, const char *filename, char **filename_out) } #ifdef H5_HAVE_MULTITHREAD + size_t num_padding = 0; + if ((tinfo = (thread_info_t *)pthread_getspecific(thread_info_key_g)) == NULL) { printf(" failed to retrieve thread-specific info\n"); ret_value = FAIL; goto done; } - if ((chars_written = HDsnprintf(out_buf, H5_API_TEST_FILENAME_MAX_LENGTH, "%zu%s%s", tinfo->thread_idx, - prefix, filename)) < 0) { + num_padding = (size_t) API_THREAD_IDX_LEN - THREAD_IDX_DIGITS_OFFSET(tinfo->thread_idx); + + /* First, left-pad with zeros */ + memset(out_buf, '0', num_padding); + + if ((chars_written = HDsnprintf(out_buf + num_padding, H5_API_TEST_FILENAME_MAX_LENGTH - num_padding, "%s%d%s", + prefix, tinfo->thread_idx, filename)) < 0) { printf(" couldn't prefix filename\n"); ret_value = FAIL; goto done; @@ -834,3 +1011,277 @@ remove_test_file(const char *prefix, const char *filename) return ret_value; } + +static int H5_api_test_display_information(void) { + unsigned seed = 0; + const char *vol_connector_name = NULL; + char *vol_connector_name_copy = NULL; + char *vol_connector_info = NULL; + + seed = (unsigned)HDtime(NULL); + srand(seed); + + if (NULL == (vol_connector_name = HDgetenv(HDF5_VOL_CONNECTOR))) { + vol_connector_name = "native"; + vol_connector_info = NULL; + } + else { + char *token; + + vol_connector_name_copy = HDstrdup(vol_connector_name); + + if (NULL == (token = HDstrtok(vol_connector_name_copy, " "))) { + printf(" cannot parse VOL connector name string\n"); + goto error; + } + + vol_connector_name = token; + + if (NULL != (token = HDstrtok(NULL, " "))) { + vol_connector_info = token; + } + } + + printf("Running API tests with VOL connector '%s' and info string '%s'\n\n", vol_connector_name, + vol_connector_info ? vol_connector_info : ""); + printf("Test parameters:\n"); + printf(" - Test file name: '%s'\n", TEST_FILE_NAME); + printf(" - Test seed: %u\n", seed); + printf(" - Test path prefix: '%s'\n", test_path_prefix); + printf("\n\n"); + + free(vol_connector_name_copy); + return 0; +error: + free(vol_connector_name_copy); + return -1; +} + +/* Set up global variables used for API tests */ +int H5_api_test_global_setup(void) { + int max_threads = 0; + int chars_written = 0; + hid_t fapl_id = H5I_INVALID_HID; + + /* Silence compiler warnings */ + (void)chars_written; + + /* Set up test path prefix for filenames, with default being empty */ + if (test_path_prefix == NULL) { + if ((test_path_prefix = HDgetenv(HDF5_API_TEST_PATH_PREFIX)) == NULL) + test_path_prefix = (const char *)""; + } + + /* Set up thread count, used for some file tests */ + max_threads = GetTestMaxNumThreads(); + + if (max_threads <= 0) { + printf(" invalid max thread count\n"); + goto error; + } + + active_thread_ct = (size_t) max_threads; + +#ifdef H5_HAVE_MULTITHREAD + /* Set up pthread key */ + if (pthread_key_create(&thread_info_key_g, H5_api_test_tl_key_destructor) != 0) { + fprintf(stderr, "Error creating threadlocal key\n"); + goto error; + } +#else + /* Populate global test filename */ + if ((chars_written = HDsnprintf(H5_api_test_filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s",test_path_prefix, + TEST_FILE_NAME)) < 0) { + fprintf(stderr, "Error while creating test file name\n"); + goto error; + } + + if ((size_t)chars_written >= H5_API_TEST_FILENAME_MAX_LENGTH) { + fprintf(stderr, "Test file name exceeded expected size\n"); + goto error; + } + +#endif /* H5_HAVE_MULTITHREAD */ + + if (H5_api_test_display_information() < 0) + goto error; + + /* Retrieve the VOL cap flags - work around an HDF5 + * library issue by creating a FAPL + */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + printf(" couldn't create FAPL\n"); + goto error; + } + + vol_cap_flags_g = H5VL_CAP_FLAG_NONE; + if (H5Pget_vol_cap_flags(fapl_id, &vol_cap_flags_g) < 0) { + printf(" unable to retrieve VOL connector capability flags\n"); + goto error; + } + + /* + * Create the file(s) that will be used for all of the tests, + * except for those which test file creation. + */ + if (create_test_container(TEST_FILE_NAME, vol_cap_flags_g) < 0) { + printf(" unable to create testing container file with basename '%s'\n", TEST_FILE_NAME); + goto error; + } + + if (H5Pclose(fapl_id) < 0) { + printf(" unable to close FAPL\n"); + goto error; + } + + return 0; + +error: + H5Pclose(fapl_id); + return -1; +} + +int H5_api_test_global_cleanup(void) { + hid_t fapl_id = H5I_INVALID_HID; + + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + printf(" couldn't create FAPL\n"); + goto error; + } + + if (H5Pget_vol_cap_flags(fapl_id, &vol_cap_flags_g) < 0) { + printf(" unable to retrieve VOL connector capability flags\n"); + goto error; + } + + if (destroy_test_container(TEST_FILE_NAME, vol_cap_flags_g) < 0) { + printf(" unable to destroy testing container file with basename '%s'\n", TEST_FILE_NAME); + goto error; + } + + if (H5Pclose(fapl_id) < 0) { + printf(" unable to close FAPL\n"); + goto error; + } + + return 0; + +error: + H5Pclose(fapl_id); + return -1; +} + +int H5_api_check_vol_registration(void) { + hid_t default_con_id = H5I_INVALID_HID; + hid_t registered_con_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + + const char *vol_connector_name; + char *vol_connector_string = NULL; + char *vol_connector_string_copy = NULL; + + /* Get active VOL connector name */ + if (NULL == (vol_connector_string = getenv(HDF5_VOL_CONNECTOR))) { + printf("No VOL connector selected; using native VOL connector\n"); + vol_connector_name = "native"; + } + else { + + if (NULL == (vol_connector_string_copy = strdup(vol_connector_string))) { + fprintf(stderr, "Unable to copy VOL connector string\n"); + goto error; + } + + if (NULL == (vol_connector_name = (const char*) strtok(vol_connector_string_copy, " "))) { + fprintf(stderr, "Error while parsing VOL connector string\n"); + goto error; + } + + } + + /* If VOL is not native, make sure it is registered properly */ + if (0 != strcmp(vol_connector_name, "native")) { + htri_t is_registered; + + if ((is_registered = H5VLis_connector_registered_by_name(vol_connector_name)) < 0) { + fprintf(stderr, "Unable to determine if VOL connector is registered\n"); + goto error; + } + + if (!is_registered) { + fprintf(stderr, "Specified VOL connector '%s' wasn't correctly registered!\n", + vol_connector_name); + goto error; + } + else { + /* + * If the connector was successfully registered, check that + * the connector ID set on the default FAPL matches the ID + * for the registered connector before running the tests. + */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + fprintf(stderr, "Couldn't create FAPL\n"); + goto error; + } + + if (H5Pget_vol_id(fapl_id, &default_con_id) < 0) { + fprintf(stderr, "Couldn't retrieve ID of VOL connector set on default FAPL\n"); + goto error; + } + + if ((registered_con_id = H5VLget_connector_id_by_name(vol_connector_name)) < 0) { + fprintf(stderr, "Couldn't retrieve ID of registered VOL connector\n"); + goto error; + } + + if (default_con_id != registered_con_id) { + fprintf(stderr, "VOL connector set on default FAPL didn't match specified VOL connector\n"); + goto error; + } + } + } + + if (registered_con_id > 0 && H5VLclose(registered_con_id) < 0) { + fprintf(stderr, "Unable to close registered VOL connector\n"); + goto error; + } + + if (default_con_id > 0 && H5VLclose(default_con_id) < 0) { + fprintf(stderr, "Unable to close default VOL connector\n"); + goto error; + } + + if (fapl_id > 0 && H5Pclose(fapl_id) < 0) { + fprintf(stderr, "Unable to close FAPL\n"); + goto error; + } + + free(vol_connector_string_copy); + + return 0; + +error: + H5E_BEGIN_TRY { + H5VLclose(registered_con_id); + H5VLclose(default_con_id); + H5Pclose(fapl_id); + free(vol_connector_string_copy); + } H5E_END_TRY; + + return -1; +} +#ifdef H5_HAVE_MULTITHREAD +/* Destructor for the API-test managed threadlocal value */ +static void H5_api_test_tl_key_destructor(void *value) { + thread_info_t *tinfo = (thread_info_t *)value; + + if (tinfo) { + free(tinfo->H5_api_test_filename); + } + + free(tinfo); + + return; +} + +#endif diff --git a/test/API/H5_api_test_util.h b/test/API/H5_api_test_util.h index 5d127bbf70d..ae86faac534 100644 --- a/test/API/H5_api_test_util.h +++ b/test/API/H5_api_test_util.h @@ -13,12 +13,23 @@ #ifndef H5_API_TEST_UTIL_H_ #define H5_API_TEST_UTIL_H_ +#define API_TESTS_DEFAULT_NUM_THREADS 1 + #include "hdf5.h" hid_t generate_random_datatype(H5T_class_t parent_class, hbool_t is_compact); hid_t generate_random_dataspace(int rank, const hsize_t *max_dims, hsize_t *dims_out, hbool_t is_compact); -int create_test_container(char *filename, uint64_t vol_cap_flags); +int create_test_container(const char *filename, uint64_t vol_cap_flags); +int destroy_test_container(const char *filename, uint64_t vol_cap_flags); +int H5_api_test_global_setup(void); +int H5_api_test_global_cleanup(void); +int H5_api_check_vol_registration(void); + herr_t prefix_filename(const char *prefix, const char *filename, char **filename_out); herr_t remove_test_file(const char *prefix, const char *filename); +#ifdef H5_HAVE_MULTITHREAD +int H5_api_test_thread_setup(int thread_idx); +#endif + #endif /* H5_API_TEST_UTIL_H_ */ diff --git a/test/API/testhdf5.c b/test/API/testhdf5.c index f69b1c80374..56bbe455ba5 100644 --- a/test/API/testhdf5.c +++ b/test/API/testhdf5.c @@ -55,6 +55,7 @@ print_func(const char *format, ...) va_list arglist; int ret_value; + /* Print requested information */ va_start(arglist, format); ret_value = HDvprintf(format, arglist); va_end(arglist); diff --git a/test/h5test.h b/test/h5test.h index a0960113714..123dc952b73 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -91,13 +91,11 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #define API_TEST_PASS 1 #define API_TEST_FAIL 0 #define API_TEST_ERROR -1 + /* Information for an individual thread running the API tests */ typedef struct thread_info_t { - size_t thread_idx; /* Test-assigned thread index */ - htri_t result; /* Whether the tests passed, failed, or experienced an error */ + int thread_idx; /* The test-assign index of the thread */ char* H5_api_test_filename; /* The name of the test container file */ - const char *vol_connector_name; - char *vol_connector_info; } thread_info_t; #ifdef H5_HAVE_MULTITHREAD @@ -154,7 +152,7 @@ extern pthread_key_t thread_info_key_g; } while (0) #define H5_FAILED() \ do { \ - HDputs("*FAILED*"); \ + TestErrPrintf("*FAILED*\n"); \ fflush(stdout); \ INCR_TEST_STAT(n_tests_failed_g); \ } while (0) diff --git a/test/mt_id_test.c b/test/mt_id_test.c index 9445d65ac14..a9250f2bda8 100644 --- a/test/mt_id_test.c +++ b/test/mt_id_test.c @@ -3,7 +3,7 @@ #define H5I_FRIEND /*suppress error about including H5Ipkg */ #include "H5Ipkg.h" -#ifdef H5_NOT_DEFINED +#ifdef H5_HAVE_MULTITHREAD #include /********************************************************************************* diff --git a/test/mt_test_vol_connector.c b/test/mt_test_vol_connector.c index 82dae74ce09..ed636bb5a90 100644 --- a/test/mt_test_vol_connector.c +++ b/test/mt_test_vol_connector.c @@ -270,27 +270,34 @@ static const H5VL_class_t mt_test_vol_g = { #define MT_TEST_FILENAME_PREFIX "mt_terminal_test_vol_" #define MT_TEST_FILENAME_BUF_SIZE 128 -#define THREAD_ID_LEN 15 -#define MT_TEST_PREFIX_LENGTH (THREAD_ID_LEN + strlen(MT_TEST_FILENAME_PREFIX)) +#define MAX_THREAD_ID_LEN 15 +#define MT_TEST_PREFIX_LENGTH (MAX_THREAD_ID_LEN + strlen(MT_TEST_FILENAME_PREFIX)) // out filename must already be allocated herr_t generate_filename(const char *original_filename, char *out_filename) { int chars_written = 0; pthread_t thread_id = pthread_self(); - char pthread_buf[THREAD_ID_LEN + 1]; + char pthread_buf[MAX_THREAD_ID_LEN + 1]; /* Make sure thread ID has expected length, to allow for filename recovery later */ - if ((chars_written = snprintf(pthread_buf, THREAD_ID_LEN + 1, "%ld", thread_id)) < 0) { + if ((chars_written = snprintf(pthread_buf, MAX_THREAD_ID_LEN + 1, "%ld", thread_id)) < 0) { printf("Failed to create thread ID\n"); return -1; } - if (chars_written != THREAD_ID_LEN) { + if (chars_written > MAX_THREAD_ID_LEN) { printf("Thread ID %ld has unexpected length\n", (long int) thread_id); return -1; } - if ((chars_written = snprintf(out_filename, MT_TEST_FILENAME_BUF_SIZE, "%s%ld%s", MT_TEST_FILENAME_PREFIX, thread_id, original_filename)) < 0) { + if (chars_written < MAX_THREAD_ID_LEN) { + /* Pad with right zeros */ + memset(pthread_buf + chars_written, '0', MAX_THREAD_ID_LEN - (size_t) chars_written); + } + + pthread_buf[MAX_THREAD_ID_LEN] = '\0'; + + if ((chars_written = snprintf(out_filename, MT_TEST_FILENAME_BUF_SIZE, "%s%s%s", MT_TEST_FILENAME_PREFIX,pthread_buf, original_filename)) < 0) { printf("Failed to create new file name\n"); return -1; } @@ -598,7 +605,7 @@ mt_test_file_get(void *file, H5VL_file_get_args_t *args, hid_t dxpl_id, void **r case H5VL_FILE_GET_NAME: { if (args->args.get_name.buf == NULL) { /* This is preliminary call to determine necessary buffer length */ - args->args.get_name.buf_size += (MT_TEST_PREFIX_LENGTH + THREAD_ID_LEN); + args->args.get_name.buf_size += (MT_TEST_PREFIX_LENGTH + MAX_THREAD_ID_LEN); } else { /* Populate filename buffer */ if ((filename_buf = strdup(args->args.get_name.buf)) == NULL) { @@ -786,9 +793,14 @@ mt_test_link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_par const char *original_buf = NULL; size_t original_size = 0; + memset(new_name, 0, MT_TEST_FILENAME_BUF_SIZE); switch (args->op_type) { case H5VL_LINK_CREATE_UD: { + if (args->args.ud.type != H5L_TYPE_EXTERNAL) { + break; + } + size_t name_len = 0; size_t new_buf_size = 0; uint8_t *p = NULL; @@ -796,16 +808,19 @@ mt_test_link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_par /* Skip external link flags */ original_buf = (const char *) args->args.ud.buf; + original_size = args->args.ud.buf_size; original_name = original_buf + 1; name_len = strlen(original_name); - norm_obj_buf = original_buf + 1 + name_len + 1; - if (generate_filename(original_buf + 1, new_name) < 0) { + norm_obj_buf = original_name + name_len + 1; + if (generate_filename(original_name, new_name) < 0) { printf("Failed to generate new file name\n"); ret_value = FAIL; goto error; } + assert(original_size = 1 + name_len + 1 + strlen(norm_obj_buf) + 1); + new_buf_size = 1 + strlen(new_name) + 1 + strlen(norm_obj_buf) + 1; if ((new_buf = (char *) malloc(new_buf_size)) == NULL) { @@ -824,8 +839,6 @@ mt_test_link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_par strncpy((char*) p, norm_obj_buf, strlen(norm_obj_buf) + 1); p += strlen(norm_obj_buf) + 1; - original_size = args->args.ud.buf_size; - args->args.ud.buf_size = new_buf_size; args->args.ud.buf = new_buf; @@ -842,8 +855,10 @@ mt_test_link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_par switch (args->op_type) { case H5VL_LINK_CREATE_UD: - args->args.ud.buf = original_buf; - args->args.ud.buf_size = original_size; + if (args->args.ud.type == H5L_TYPE_EXTERNAL) { + args->args.ud.buf = original_buf; + args->args.ud.buf_size = original_size; + } break; default: break; @@ -899,6 +914,7 @@ mt_test_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_a switch (args->op_type) { case H5VL_LINK_GET_INFO: { if (args->args.get_info.linfo->type == H5L_TYPE_EXTERNAL) { + /* Actual size on disk will exceed expected size; report the size the user provided */ args->args.get_info.linfo->u.val_size -= MT_TEST_PREFIX_LENGTH; } } diff --git a/test/testframe.c b/test/testframe.c index d21d8bc8117..f3c52dc2f2a 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -20,8 +20,8 @@ /* * Definitions for the testing structure. */ -#define MAXTESTNAME 16 -#define MAXTESTDESC 64 +#define MAXTESTNAME 64 +#define MAXTESTDESC 128 typedef struct TestStruct { int NumErrors; diff --git a/test/threads/testmthdf5.c b/test/threads/testmthdf5.c index e7978918a67..6f3f13922b2 100644 --- a/test/threads/testmthdf5.c +++ b/test/threads/testmthdf5.c @@ -32,10 +32,7 @@ #include "testmthdf5.h" /* Margin of runtime for each subtest allocated to cleanup */ -#define MARGIN 10 - -/* Margin of runtime for each subtest allocated to cleanup */ -#define MARGIN 1 +#define MT_VL_TEST_MARGIN 1 #define DEFAULT_NUM_THREADS 10 @@ -68,7 +65,7 @@ int main(int argc, char *argv[]) params.num_repetitions = NUM_ITERS; if (testExpress > 0) { - params.subtest_timeout = (runtime - MARGIN) / num_subtests; + params.subtest_timeout = (runtime - MT_VL_TEST_MARGIN) / num_subtests; } else { params.subtest_timeout = 0; } diff --git a/test/threads/unit/mt_vl_test.c b/test/threads/unit/mt_vl_test.c index 9b30e836ec2..a1c3eeb51a6 100644 --- a/test/threads/unit/mt_vl_test.c +++ b/test/threads/unit/mt_vl_test.c @@ -29,9 +29,6 @@ #ifdef H5_HAVE_MULTITHREAD -/* Silence compiler warning */ -extern int GetTestMaxNumThreads(void); - /* Shared VOL Connector Property for testing */ H5VL_connector_prop_t conn_prop_g; @@ -90,7 +87,7 @@ void mt_test_run_helper_in_parallel(int max_num_threads, mt_vl_test_cb mt_test_f * threads. */ void mt_test_registration(void) { int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); mt_test_run_helper_in_parallel(max_num_threads, mt_test_registration_helper, NULL); @@ -129,7 +126,7 @@ void *mt_test_registration_helper(void H5_ATTR_UNUSED *arg) { * threads. */ void mt_test_registration_by_name(void) { int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); mt_test_run_helper_in_parallel(max_num_threads, mt_test_registration_by_name_helper, NULL); @@ -172,7 +169,7 @@ void *mt_test_registration_by_name_helper(void H5_ATTR_UNUSED *arg) { * threads. */ void mt_test_registration_by_value(void) { int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); mt_test_run_helper_in_parallel(max_num_threads, mt_test_registration_by_value_helper, NULL); @@ -214,7 +211,7 @@ void *mt_test_registration_by_value_helper(void H5_ATTR_UNUSED *arg) { /* Test concurrent registration and unregistration of dynamic VOL operations */ void mt_test_dyn_op_registration(void) { int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); mt_test_run_helper_in_parallel(max_num_threads, mt_test_dyn_op_registration_helper, NULL); @@ -309,7 +306,7 @@ void mt_test_registration_operation(void) { hid_t file_id = H5I_INVALID_HID; herr_t ret = SUCCEED; int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); @@ -387,7 +384,7 @@ void mt_test_registration_operation_cleanup(void) { * H5PL works in a multi-threaded environment */ void mt_test_file_open_failure_registration(void) { int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); @@ -427,7 +424,7 @@ void mt_test_vol_property_copy(void) { herr_t ret = SUCCEED; int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); @@ -500,7 +497,7 @@ void mt_test_register_and_search(void) { int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); @@ -637,7 +634,7 @@ void *mt_test_search_search_by_value_helper(void *arg) { void mt_test_lib_state_ops(void) { int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); @@ -687,7 +684,7 @@ void mt_test_vol_wrap_ctx(void) { hid_t passthru_id = H5I_INVALID_HID; int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); @@ -773,7 +770,7 @@ void mt_test_vol_wrap_ctx_cleanup(void) { void mt_test_vol_info(void) { int max_num_threads = GetTestMaxNumThreads(); - const mt_test_params *params = GetTestParameters(); + const mt_test_params *params = (const mt_test_params *) GetTestParameters(); assert(params != NULL); alarm(params->subtest_timeout); diff --git a/testpar/API/H5_api_async_test_parallel.c b/testpar/API/H5_api_async_test_parallel.c index 23e3544cb01..cd902f3f5b1 100644 --- a/testpar/API/H5_api_async_test_parallel.c +++ b/testpar/API/H5_api_async_test_parallel.c @@ -3574,7 +3574,7 @@ test_file_reopen(void) * Cleanup temporary test files */ static void -cleanup_files(void) +file_api_test_cleanup(void) { char file_name[64]; int i; @@ -3625,7 +3625,7 @@ H5_api_async_test_parallel(void) printf("Cleaning up testing files\n"); } - cleanup_files(); + file_api_test_cleanup(); if (MAINPROCESS) { printf("\n * Re-testing with independent metadata reads *\n"); @@ -3647,7 +3647,7 @@ H5_api_async_test_parallel(void) printf("Cleaning up testing files\n"); } - cleanup_files(); + file_api_test_cleanup(); return nerrors; } diff --git a/testpar/API/H5_api_file_test_parallel.c b/testpar/API/H5_api_file_test_parallel.c index 9bbcd9c7f79..462a71b89ae 100644 --- a/testpar/API/H5_api_file_test_parallel.c +++ b/testpar/API/H5_api_file_test_parallel.c @@ -311,7 +311,7 @@ test_split_comm_file_access(void) * Cleanup temporary test files */ static void -cleanup_files(void) +file_api_test_cleanup(void) { hid_t fapl_id = H5I_INVALID_HID; @@ -361,7 +361,7 @@ H5_api_file_test_parallel(void) printf("Cleaning up testing files\n"); } - cleanup_files(); + file_api_test_cleanup(); return nerrors; } diff --git a/testpar/API/H5_api_test_parallel.c b/testpar/API/H5_api_test_parallel.c index 9b1d432b7be..da21dfed379 100644 --- a/testpar/API/H5_api_test_parallel.c +++ b/testpar/API/H5_api_test_parallel.c @@ -372,11 +372,11 @@ main(int argc, char **argv) BEGIN_INDEPENDENT_OP(create_test_container) { if (MAINPROCESS) { - if (create_test_container(H5_api_test_parallel_filename, vol_cap_flags_g) < 0) { + if (create_test_container((const char *)(H5_api_test_parallel_filename), vol_cap_flags_g) < 0) { fprintf(stderr, " failed to create testing container file '%s'\n", H5_api_test_parallel_filename); INDEPENDENT_OP_ERROR(create_test_container); - } + } } } END_INDEPENDENT_OP(create_test_container);