mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
Sync API tests with vol-tests (#3940)
This commit is contained in:
@@ -51,6 +51,7 @@ 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_attribute_string_encodings(void);
|
||||
static int test_delete_attribute(void);
|
||||
static int test_delete_attribute_invalid_params(void);
|
||||
static int test_attribute_exists(void);
|
||||
@@ -99,6 +100,7 @@ static int (*attribute_tests[])(void) = {test_create_attribute_on_root,
|
||||
test_attribute_iterate_index_saving,
|
||||
test_attribute_iterate_invalid_params,
|
||||
test_attribute_iterate_0_attributes,
|
||||
test_attribute_string_encodings,
|
||||
test_delete_attribute,
|
||||
test_delete_attribute_invalid_params,
|
||||
test_attribute_exists,
|
||||
@@ -8333,6 +8335,272 @@ error:
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* A test to check that attributes preserve data
|
||||
* correctness for strings with ASCII or UTF-8 char sets
|
||||
*/
|
||||
static int
|
||||
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 0;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
PASSED();
|
||||
}
|
||||
END_MULTIPART;
|
||||
|
||||
TESTING_2("test cleanup");
|
||||
|
||||
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 (H5Aclose(attr_id1) < 0)
|
||||
TEST_ERROR;
|
||||
if (H5Aclose(attr_id2) < 0)
|
||||
TEST_ERROR;
|
||||
if (write_buf)
|
||||
free(write_buf);
|
||||
if (read_buf)
|
||||
free(read_buf);
|
||||
PASSED();
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
H5Fclose(file_id);
|
||||
H5Gclose(container_group);
|
||||
H5Dclose(dset_id1);
|
||||
H5Dclose(dset_id2);
|
||||
H5Tclose(type_id1);
|
||||
H5Tclose(type_id2);
|
||||
H5Aclose(attr_id1);
|
||||
H5Aclose(attr_id2);
|
||||
if (write_buf)
|
||||
free(write_buf);
|
||||
if (read_buf)
|
||||
free(read_buf);
|
||||
}
|
||||
H5E_END_TRY;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* A test to check that an attribute can be deleted
|
||||
* using H5Adelete(_by_idx).
|
||||
|
||||
@@ -156,6 +156,15 @@ 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_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"
|
||||
|
||||
+1345
-121
@@ -63,7 +63,9 @@ static int test_write_multi_dataset_small_hyperslab(void);
|
||||
static int test_write_multi_dataset_small_point_selection(void);
|
||||
static int test_write_multi_dataset_data_verification(void);
|
||||
static int test_write_dataset_invalid_params(void);
|
||||
static int test_dataset_string_encodings(void);
|
||||
static int test_dataset_builtin_type_conversion(void);
|
||||
static int test_dataset_real_to_int_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);
|
||||
@@ -133,6 +135,7 @@ static int (*dataset_tests[])(void) = {
|
||||
test_read_multi_dataset_small_point_selection,
|
||||
test_dataset_io_point_selections,
|
||||
test_read_dataset_invalid_params,
|
||||
test_dataset_string_encodings,
|
||||
test_write_dataset_small_all,
|
||||
test_write_dataset_small_hyperslab,
|
||||
test_write_dataset_small_point_selection,
|
||||
@@ -143,6 +146,7 @@ static int (*dataset_tests[])(void) = {
|
||||
test_write_multi_dataset_data_verification,
|
||||
test_write_dataset_invalid_params,
|
||||
test_dataset_builtin_type_conversion,
|
||||
test_dataset_real_to_int_conversion,
|
||||
test_dataset_compound_partial_io,
|
||||
test_dataset_set_extent_chunked_unlimited,
|
||||
test_dataset_set_extent_chunked_fixed,
|
||||
@@ -166,6 +170,9 @@ static int (*dataset_tests[])(void) = {
|
||||
test_get_vlen_buf_size,
|
||||
};
|
||||
|
||||
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);
|
||||
/*
|
||||
* A test to check that a dataset can be
|
||||
* created under the root group.
|
||||
@@ -2041,6 +2048,22 @@ error:
|
||||
return 1;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
buf_size = 0;
|
||||
|
||||
if (flags & H5Z_FLAG_REVERSE) {
|
||||
/* No-op */
|
||||
}
|
||||
else {
|
||||
/* No-op */
|
||||
}
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
/*
|
||||
* A test to check the functionality of the different
|
||||
* dataset creation properties.
|
||||
@@ -2048,15 +2071,21 @@ error:
|
||||
static int
|
||||
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[strlen(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");
|
||||
|
||||
/* Make sure the connector supports the API functions being tested */
|
||||
@@ -2388,7 +2417,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)
|
||||
@@ -2490,6 +2787,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)
|
||||
{
|
||||
@@ -2689,6 +3100,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)
|
||||
@@ -2711,6 +3127,10 @@ test_create_dataset_creation_properties(void)
|
||||
error:
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
if (read_buf) {
|
||||
free(read_buf);
|
||||
}
|
||||
|
||||
H5Sclose(compact_fspace_id);
|
||||
H5Sclose(fspace_id);
|
||||
H5Tclose(compact_dtype);
|
||||
@@ -2720,10 +3140,11 @@ error:
|
||||
H5Gclose(group_id);
|
||||
H5Gclose(container_group);
|
||||
H5Fclose(file_id);
|
||||
}
|
||||
H5E_END_TRY
|
||||
|
||||
return 1;
|
||||
H5E_END_TRY
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3652,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");
|
||||
@@ -3743,8 +4164,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");
|
||||
@@ -4721,7 +5142,7 @@ test_read_multi_dataset_small_point_selection(void)
|
||||
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 *data[DATASET_MULTI_COUNT];
|
||||
void *read_buf[DATASET_MULTI_COUNT];
|
||||
|
||||
TESTING("small multi read from datasets with point selections");
|
||||
|
||||
@@ -4735,7 +5156,7 @@ test_read_multi_dataset_small_point_selection(void)
|
||||
|
||||
/* Prevent uninitialized memory usage on test failure */
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
data[i] = NULL;
|
||||
read_buf[i] = NULL;
|
||||
dset_id_arr[i] = H5I_INVALID_HID;
|
||||
}
|
||||
|
||||
@@ -4797,7 +5218,7 @@ test_read_multi_dataset_small_point_selection(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (NULL == (data[i] = malloc(data_size)))
|
||||
if (NULL == (read_buf[i] = malloc(data_size)))
|
||||
TEST_ERROR;
|
||||
|
||||
dtype_arr[i] = DATASET_SMALL_READ_TEST_POINT_SELECTION_DSET_DTYPE;
|
||||
@@ -4806,16 +5227,16 @@ test_read_multi_dataset_small_point_selection(void)
|
||||
}
|
||||
|
||||
if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_arr, mspace_id_arr, fspace_id_arr, H5P_DEFAULT,
|
||||
data) < 0) {
|
||||
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 (data[i]) {
|
||||
free(data[i]);
|
||||
data[i] = NULL;
|
||||
if (read_buf[i]) {
|
||||
free(read_buf[i]);
|
||||
read_buf[i] = NULL;
|
||||
}
|
||||
if (H5Dclose(dset_id_arr[i]) < 0)
|
||||
TEST_ERROR;
|
||||
@@ -4840,9 +5261,9 @@ error:
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
if (data[i]) {
|
||||
free(data[i]);
|
||||
data[i] = NULL;
|
||||
if (read_buf[i]) {
|
||||
free(read_buf[i]);
|
||||
read_buf[i] = NULL;
|
||||
}
|
||||
H5Dclose(dset_id_arr[i]);
|
||||
}
|
||||
@@ -5228,8 +5649,8 @@ test_dataset_io_point_selections(void)
|
||||
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");
|
||||
FAIL_PUTS_ERROR("Incorrect data found after writing from hyperslab in memory to "
|
||||
"points in dataset");
|
||||
|
||||
PASSED();
|
||||
|
||||
@@ -5302,8 +5723,8 @@ test_dataset_io_point_selections(void)
|
||||
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");
|
||||
FAIL_PUTS_ERROR("Incorrect data found after writing from points in memory to "
|
||||
"hyperslab in dataset");
|
||||
|
||||
if (!do_chunk)
|
||||
PASSED();
|
||||
@@ -6501,22 +6922,24 @@ error:
|
||||
static int
|
||||
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];
|
||||
void *data[DATASET_MULTI_COUNT];
|
||||
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];
|
||||
|
||||
TESTING("small multi write to datasets with H5S_ALL");
|
||||
|
||||
/* Prevent uninitialized memory usage on test failure */
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
dset_id_arr[i] = H5I_INVALID_HID;
|
||||
data[i] = NULL;
|
||||
write_buf[i] = NULL;
|
||||
wbuf_temp[i] = NULL;
|
||||
}
|
||||
|
||||
/* Make sure the connector supports the API functions being tested */
|
||||
@@ -6600,23 +7023,26 @@ test_write_multi_dataset_small_all(void)
|
||||
dtype_id_arr[i] = DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE;
|
||||
fspace_id_arr[i] = H5S_ALL;
|
||||
|
||||
if (NULL == (data[i] = malloc((hsize_t)space_npoints * DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPESIZE)))
|
||||
if (NULL ==
|
||||
(wbuf_temp[i] = malloc((hsize_t)space_npoints * DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPESIZE)))
|
||||
TEST_ERROR;
|
||||
|
||||
for (size_t j = 0; j < (size_t)space_npoints; j++)
|
||||
((int **)data)[i][j] = (int)i;
|
||||
((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, (const void **)data) < 0) {
|
||||
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(data[i]);
|
||||
data[i] = NULL;
|
||||
free(wbuf_temp[i]);
|
||||
wbuf_temp[i] = NULL;
|
||||
if (H5Dclose(dset_id_arr[i]) < 0)
|
||||
TEST_ERROR;
|
||||
}
|
||||
@@ -6637,8 +7063,8 @@ error:
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
if (data[i])
|
||||
free(data[i]);
|
||||
if (wbuf_temp[i])
|
||||
free(wbuf_temp[i]);
|
||||
H5Dclose(dset_id_arr[i]);
|
||||
}
|
||||
|
||||
@@ -6659,19 +7085,20 @@ error:
|
||||
static int
|
||||
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];
|
||||
void *data[DATASET_MULTI_COUNT];
|
||||
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];
|
||||
|
||||
TESTING("small multi write to datasets with hyperslab selections");
|
||||
|
||||
@@ -6685,7 +7112,8 @@ test_write_multi_dataset_small_hyperslab(void)
|
||||
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
dset_id_arr[i] = H5I_INVALID_HID;
|
||||
data[i] = NULL;
|
||||
write_buf[i] = NULL;
|
||||
wbuf_temp[i] = NULL;
|
||||
}
|
||||
|
||||
if ((file_id = H5Fopen(H5_api_test_filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) {
|
||||
@@ -6732,11 +7160,13 @@ test_write_multi_dataset_small_hyperslab(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (NULL == (data[i] = malloc(data_size)))
|
||||
if (NULL == (wbuf_temp[i] = malloc(data_size)))
|
||||
TEST_ERROR;
|
||||
|
||||
for (size_t j = 0; j < data_size / DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPESIZE; j++)
|
||||
((int **)data)[i][j] = (int)i;
|
||||
((int **)wbuf_temp)[i][j] = (int)i;
|
||||
|
||||
write_buf[i] = (const void *)wbuf_temp[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_SPACE_RANK; i++) {
|
||||
@@ -6758,16 +7188,16 @@ test_write_multi_dataset_small_hyperslab(void)
|
||||
}
|
||||
|
||||
if (H5Dwrite_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, mspace_id_arr, fspace_id_arr,
|
||||
H5P_DEFAULT, (const void **)data) < 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
if (data[i]) {
|
||||
free(data[i]);
|
||||
data[i] = NULL;
|
||||
if (wbuf_temp[i]) {
|
||||
free(wbuf_temp[i]);
|
||||
wbuf_temp[i] = NULL;
|
||||
}
|
||||
if (H5Dclose(dset_id_arr[i]) < 0)
|
||||
TEST_ERROR;
|
||||
@@ -6792,9 +7222,9 @@ error:
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
if (data[i]) {
|
||||
free(data[i]);
|
||||
data[i] = NULL;
|
||||
if (wbuf_temp[i]) {
|
||||
free(wbuf_temp[i]);
|
||||
wbuf_temp[i] = NULL;
|
||||
}
|
||||
H5Dclose(dset_id_arr[i]);
|
||||
}
|
||||
@@ -6816,18 +7246,19 @@ error:
|
||||
static int
|
||||
test_write_multi_dataset_small_point_selection(void)
|
||||
{
|
||||
hsize_t points[DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS *
|
||||
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];
|
||||
void *data[DATASET_MULTI_COUNT];
|
||||
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];
|
||||
|
||||
TESTING("small multi write to datasets with point selections");
|
||||
|
||||
@@ -6840,7 +7271,8 @@ test_write_multi_dataset_small_point_selection(void)
|
||||
}
|
||||
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
data[i] = NULL;
|
||||
write_buf[i] = NULL;
|
||||
wbuf_temp[i] = NULL;
|
||||
dset_id_arr[i] = H5I_INVALID_HID;
|
||||
}
|
||||
|
||||
@@ -6888,11 +7320,13 @@ test_write_multi_dataset_small_point_selection(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (NULL == (data[i] = malloc(data_size)))
|
||||
if (NULL == (wbuf_temp[i] = malloc(data_size)))
|
||||
TEST_ERROR;
|
||||
|
||||
for (size_t j = 0; j < data_size / DATASET_SMALL_WRITE_TEST_POINT_SELECTION_DSET_DTYPESIZE; j++)
|
||||
((int **)data)[i][j] = (int)i;
|
||||
((int **)wbuf_temp)[i][j] = (int)i;
|
||||
|
||||
write_buf[i] = (const void *)wbuf_temp[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < DATASET_SMALL_WRITE_TEST_POINT_SELECTION_NUM_POINTS; i++) {
|
||||
@@ -6916,16 +7350,16 @@ test_write_multi_dataset_small_point_selection(void)
|
||||
}
|
||||
|
||||
if (H5Dwrite_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, mspace_id_arr, fspace_id_arr,
|
||||
H5P_DEFAULT, (const void **)data) < 0) {
|
||||
H5P_DEFAULT, (const void **)write_buf) < 0) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't write to multiple datasets\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
if (data[i]) {
|
||||
free(data[i]);
|
||||
data[i] = NULL;
|
||||
if (wbuf_temp[i]) {
|
||||
free(wbuf_temp[i]);
|
||||
wbuf_temp[i] = NULL;
|
||||
}
|
||||
|
||||
if (H5Dclose(dset_id_arr[i]) < 0)
|
||||
@@ -6951,8 +7385,8 @@ error:
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
if (data[i])
|
||||
free(data[i]);
|
||||
if (wbuf_temp[i])
|
||||
free(wbuf_temp[i]);
|
||||
|
||||
H5Dclose(dset_id_arr[i]);
|
||||
}
|
||||
@@ -6992,9 +7426,10 @@ test_write_multi_dataset_data_verification(void)
|
||||
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];
|
||||
void *write_buf[DATASET_MULTI_COUNT];
|
||||
void *read_buf[DATASET_MULTI_COUNT];
|
||||
char dset_names[DATASET_MULTI_COUNT][DSET_NAME_BUF_SIZE];
|
||||
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");
|
||||
|
||||
@@ -7013,6 +7448,7 @@ test_write_multi_dataset_data_verification(void)
|
||||
select_all_arr[i] = H5S_ALL;
|
||||
read_buf[i] = NULL;
|
||||
write_buf[i] = NULL;
|
||||
wbuf_temp[i] = NULL;
|
||||
data[i] = NULL;
|
||||
}
|
||||
|
||||
@@ -7062,6 +7498,8 @@ test_write_multi_dataset_data_verification(void)
|
||||
|
||||
for (size_t j = 0; j < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; j++)
|
||||
((int **)data)[i][j] = (int)j;
|
||||
|
||||
write_buf[i] = (const void *)data[i];
|
||||
}
|
||||
|
||||
PASSED();
|
||||
@@ -7073,7 +7511,7 @@ test_write_multi_dataset_data_verification(void)
|
||||
TESTING_2("H5Dwrite_multi using H5S_ALL then H5Dread_multi");
|
||||
|
||||
if (H5Dwrite_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, select_all_arr, select_all_arr,
|
||||
H5P_DEFAULT, (const void **)data) < 0) {
|
||||
H5P_DEFAULT, (const void **)write_buf) < 0) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't write to datasets");
|
||||
PART_ERROR(H5Dwrite_multi_all_read);
|
||||
@@ -7170,14 +7608,14 @@ test_write_multi_dataset_data_verification(void)
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
data_size = dims[1] * 2 * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE;
|
||||
|
||||
if (NULL == (write_buf[i] = malloc(data_size))) {
|
||||
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);
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; j++) {
|
||||
((int *)write_buf[i])[j] = 56;
|
||||
((int *)wbuf_temp[i])[j] = 56;
|
||||
}
|
||||
|
||||
data_size = 1;
|
||||
@@ -7190,6 +7628,8 @@ test_write_multi_dataset_data_verification(void)
|
||||
printf(" couldn't allocate buffer for datasets' data verification\n");
|
||||
PART_ERROR(H5Dwrite_multi_hyperslab_read);
|
||||
}
|
||||
|
||||
write_buf[i] = (const void *)wbuf_temp[i];
|
||||
}
|
||||
|
||||
if (H5Dread_multi(DATASET_MULTI_COUNT, dset_id_arr, dtype_id_arr, select_all_arr, select_all_arr,
|
||||
@@ -7316,9 +7756,9 @@ test_write_multi_dataset_data_verification(void)
|
||||
data[i] = NULL;
|
||||
}
|
||||
|
||||
if (write_buf[i]) {
|
||||
free(write_buf[i]);
|
||||
write_buf[i] = NULL;
|
||||
if (wbuf_temp[i]) {
|
||||
free(wbuf_temp[i]);
|
||||
wbuf_temp[i] = NULL;
|
||||
}
|
||||
|
||||
if (read_buf[i]) {
|
||||
@@ -7332,14 +7772,9 @@ test_write_multi_dataset_data_verification(void)
|
||||
PART_END(H5Dwrite_multi_hyperslab_read);
|
||||
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
if (data[i]) {
|
||||
free(data[i]);
|
||||
data[i] = NULL;
|
||||
}
|
||||
|
||||
if (write_buf[i]) {
|
||||
free(write_buf[i]);
|
||||
write_buf[i] = NULL;
|
||||
if (wbuf_temp[i]) {
|
||||
free(wbuf_temp[i]);
|
||||
wbuf_temp[i] = NULL;
|
||||
}
|
||||
|
||||
if (read_buf[i]) {
|
||||
@@ -7356,14 +7791,16 @@ test_write_multi_dataset_data_verification(void)
|
||||
DATASET_DATA_VERIFY_WRITE_TEST_NUM_POINTS * DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE;
|
||||
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
if (NULL == (write_buf[i] = malloc(data_size))) {
|
||||
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);
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < data_size / DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; j++)
|
||||
((int **)write_buf)[i][j] = 13;
|
||||
((int **)wbuf_temp)[i][j] = 13;
|
||||
|
||||
write_buf[i] = (const void *)wbuf_temp[i];
|
||||
|
||||
data_size = 1;
|
||||
|
||||
@@ -7516,9 +7953,9 @@ test_write_multi_dataset_data_verification(void)
|
||||
data[i] = NULL;
|
||||
}
|
||||
|
||||
if (write_buf[i]) {
|
||||
free(write_buf[i]);
|
||||
write_buf[i] = NULL;
|
||||
if (wbuf_temp[i]) {
|
||||
free(wbuf_temp[i]);
|
||||
wbuf_temp[i] = NULL;
|
||||
}
|
||||
|
||||
if (read_buf[i]) {
|
||||
@@ -7549,8 +7986,8 @@ error:
|
||||
for (i = 0; i < DATASET_MULTI_COUNT; i++) {
|
||||
if (data[i])
|
||||
free(data[i]);
|
||||
if (write_buf[i])
|
||||
free(write_buf[i]);
|
||||
if (wbuf_temp[i])
|
||||
free(wbuf_temp[i]);
|
||||
if (read_buf[i])
|
||||
free(read_buf[i]);
|
||||
|
||||
@@ -7809,6 +8246,251 @@ error:
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* A test to ensure that strings of any encoding
|
||||
* can be written to and read from a dataset
|
||||
*/
|
||||
static int
|
||||
test_dataset_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;
|
||||
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_ATTR_BASIC)) {
|
||||
SKIPPED();
|
||||
printf(" API functions for basic file, group, basic or more dataset aren't supported with this "
|
||||
"connector\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
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(DATASET_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, 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 set character set of string to UTF-8\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
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(ASCII_cset)
|
||||
{
|
||||
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 allocate memory for write buffer\n");
|
||||
PART_ERROR(ASCII_cset);
|
||||
}
|
||||
|
||||
memcpy(write_buf, DATASET_STRING_ENCODINGS_ASCII_STRING, ascii_str_size);
|
||||
|
||||
if ((H5Dwrite(dset_id1, type_id1, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf)) < 0) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't write to dataset with ASCII string\n");
|
||||
PART_ERROR(ASCII_cset);
|
||||
}
|
||||
|
||||
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 ((H5Dread(dset_id1, type_id1, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf)) < 0) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't read from dataset with ASCII string\n");
|
||||
PART_ERROR(ASCII_cset);
|
||||
}
|
||||
|
||||
if (strncmp(write_buf, read_buf, ascii_str_size)) {
|
||||
H5_FAILED();
|
||||
printf(" incorrect data read from dataset 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");
|
||||
/* Dataset with UTF-8 string datatype */
|
||||
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, DATASET_STRING_ENCODINGS_UTF8_STRING, utf8_str_size);
|
||||
|
||||
if ((H5Dwrite(dset_id2, type_id2, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf)) < 0) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't write to dataset with ASCII string\n");
|
||||
PART_ERROR(UTF8_cset);
|
||||
}
|
||||
|
||||
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 ((H5Dread(dset_id2, type_id2, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf)) < 0) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't read from dataset with ASCII string\n");
|
||||
PART_ERROR(UTF8_cset);
|
||||
}
|
||||
|
||||
if (strncmp(write_buf, read_buf, utf8_str_size)) {
|
||||
H5_FAILED();
|
||||
printf(" incorrect data read from dataset with ASCII string\n");
|
||||
PART_ERROR(UTF8_cset);
|
||||
}
|
||||
|
||||
free(write_buf);
|
||||
write_buf = NULL;
|
||||
|
||||
free(read_buf);
|
||||
read_buf = NULL;
|
||||
|
||||
PASSED();
|
||||
}
|
||||
PART_END(UTF8_cset);
|
||||
|
||||
PASSED();
|
||||
}
|
||||
END_MULTIPART;
|
||||
|
||||
TESTING_2("test cleanup");
|
||||
|
||||
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();
|
||||
|
||||
return 0;
|
||||
|
||||
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;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* A test to ensure that data is read back correctly from a dataset after it has
|
||||
* been written, using type conversion with builtin types.
|
||||
@@ -8347,6 +9029,548 @@ error:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
test_dataset_real_to_int_conversion(void)
|
||||
{
|
||||
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 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)) {
|
||||
SKIPPED();
|
||||
printf(" API functions for basic file, group, basic or more dataset aren't supported with this "
|
||||
"connector\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_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_REAL_CONVERSION_TEST_GROUP_NAME);
|
||||
goto error;
|
||||
}
|
||||
|
||||
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_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_REAL_CONVERSION_TEST_DSET_NAME);
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (i = 0, data_size = 1; i < DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK; i++)
|
||||
data_size *= dims[i];
|
||||
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_REAL_CONVERSION_TEST_INT_DTYPESIZE; i++)
|
||||
((int *)data)[i] = (int)i;
|
||||
|
||||
PASSED();
|
||||
|
||||
BEGIN_MULTIPART
|
||||
{
|
||||
PART_BEGIN(H5Dwrite_all_read)
|
||||
{
|
||||
TESTING_2("write then read int from real dataset with H5S_ALL selection");
|
||||
|
||||
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_REAL_CONVERSION_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_REAL_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) <
|
||||
0) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't open dataset '%s'\n", DATASET_DATA_REAL_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_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_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_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_REAL_CONVERSION_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);
|
||||
|
||||
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("write then read int from real dataset with hyperslab selection");
|
||||
|
||||
data_size = dims[1] * 2 * DATASET_DATA_REAL_CONVERSION_TEST_INT_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_REAL_CONVERSION_TEST_INT_DTYPESIZE; i++)
|
||||
((int *)write_buf)[i] = 56;
|
||||
|
||||
for (i = 0, data_size = 1; i < DATASET_DATA_REAL_CONVERSION_TEST_DSET_SPACE_RANK; i++)
|
||||
data_size *= dims[i];
|
||||
data_size *= DATASET_DATA_REAL_CONVERSION_TEST_INT_DTYPESIZE;
|
||||
|
||||
if (NULL == (data = calloc(1, data_size))) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't allocate buffer for dataset data verification\n");
|
||||
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;
|
||||
|
||||
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_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_REAL_CONVERSION_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_REAL_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) <
|
||||
0) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't open dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_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_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_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_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);
|
||||
|
||||
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("write then read int from real dataset with point selection");
|
||||
|
||||
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();
|
||||
printf(" couldn't allocate buffer for dataset write\n");
|
||||
PART_ERROR(H5Dwrite_point_sel_read);
|
||||
}
|
||||
|
||||
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_REAL_CONVERSION_TEST_DSET_SPACE_RANK; i++)
|
||||
data_size *= dims[i];
|
||||
data_size *= DATASET_DATA_REAL_CONVERSION_TEST_INT_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_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_REAL_CONVERSION_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_REAL_CONVERSION_TEST_NUM_POINTS; i++) {
|
||||
size_t j;
|
||||
|
||||
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_REAL_CONVERSION_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_REAL_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);
|
||||
}
|
||||
}
|
||||
|
||||
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_REAL_CONVERSION_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_REAL_CONVERSION_TEST_DSET_NAME, H5P_DEFAULT)) <
|
||||
0) {
|
||||
H5_FAILED();
|
||||
printf(" couldn't open dataset '%s'\n", DATASET_DATA_REAL_CONVERSION_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_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_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);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
return 0;
|
||||
|
||||
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;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* A test to ensure that data is read back correctly from a dataset after it has
|
||||
* been written, using partial element I/O with compound types
|
||||
@@ -8373,8 +9597,8 @@ 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) ||
|
||||
@@ -11999,10 +13223,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -214,6 +243,15 @@ 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"
|
||||
|
||||
+237
-26
@@ -51,6 +51,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,
|
||||
@@ -5048,15 +5050,23 @@ test_object_comments_invalid_params(void)
|
||||
static int
|
||||
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[H5_API_TEST_FILENAME_MAX_LENGTH];
|
||||
|
||||
TESTING_MULTIPART("object visiting");
|
||||
|
||||
@@ -5079,6 +5089,15 @@ test_object_visit(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
snprintf(visit_filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix,
|
||||
OBJECT_VISIT_TEST_FILE_NAME);
|
||||
|
||||
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);
|
||||
@@ -5106,18 +5125,44 @@ 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 ((type_id = generate_random_datatype(H5T_NO_CLASS, false)) < 0) {
|
||||
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();
|
||||
printf(" couldn't create datatype '%s'\n", OBJECT_VISIT_TEST_TYPE_NAME);
|
||||
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();
|
||||
@@ -5125,6 +5170,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();
|
||||
@@ -5257,16 +5323,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;
|
||||
|
||||
SKIPPED();
|
||||
PART_EMPTY(H5Ovisit_file);
|
||||
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);
|
||||
}
|
||||
|
||||
PASSED();
|
||||
}
|
||||
PART_END(H5Ovisit_file);
|
||||
|
||||
@@ -5300,6 +5399,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");
|
||||
@@ -5480,12 +5603,22 @@ test_object_visit(void)
|
||||
{
|
||||
TESTING_2("H5Ovisit_by_name on a file ID");
|
||||
|
||||
/*
|
||||
* XXX:
|
||||
*/
|
||||
i = 0;
|
||||
|
||||
SKIPPED();
|
||||
PART_EMPTY(H5Ovisit_by_name_file);
|
||||
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);
|
||||
}
|
||||
|
||||
PASSED();
|
||||
}
|
||||
PART_END(H5Ovisit_by_name_file);
|
||||
|
||||
@@ -5518,6 +5651,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;
|
||||
|
||||
@@ -5535,12 +5692,22 @@ 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;
|
||||
|
||||
PASSED();
|
||||
|
||||
@@ -5555,11 +5722,16 @@ error:
|
||||
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);
|
||||
}
|
||||
H5E_END_TRY
|
||||
H5E_END_TRY;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -7067,6 +7239,29 @@ done:
|
||||
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.
|
||||
*/
|
||||
@@ -7128,6 +7323,14 @@ object_visit_soft_link_callback(hid_t o_id, const char *name, const H5O_info2_t
|
||||
|
||||
UNUSED(o_id);
|
||||
|
||||
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;
|
||||
@@ -7166,7 +7369,15 @@ object_visit_noop_callback(hid_t o_id, const char *name, const H5O_info2_t *obje
|
||||
static void
|
||||
cleanup_files(void)
|
||||
{
|
||||
H5Fdelete(OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME, H5P_DEFAULT);
|
||||
char filename[H5_API_TEST_FILENAME_MAX_LENGTH];
|
||||
|
||||
snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix,
|
||||
OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME);
|
||||
H5Fdelete(filename, H5P_DEFAULT);
|
||||
|
||||
snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix,
|
||||
OBJECT_VISIT_TEST_FILE_NAME);
|
||||
H5Fdelete(filename, H5P_DEFAULT);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user