Skip to content

Commit

Permalink
Close file in vlen test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Mar 15, 2024
1 parent a78ebac commit 5c91a30
Showing 1 changed file with 104 additions and 27 deletions.
131 changes: 104 additions & 27 deletions test/API/H5_api_dataset_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1277,10 +1277,10 @@ test_create_dataset_predefined_types(void)
hid_t fspace_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hid_t predefined_type_test_table[] = {H5T_STD_U8LE, H5T_STD_U8BE, H5T_STD_I8LE, H5T_STD_I8BE,
H5T_STD_U16LE, H5T_STD_U16BE, H5T_STD_I16LE, H5T_STD_I16BE,
H5T_STD_U32LE, H5T_STD_U32BE, H5T_STD_I32LE, H5T_STD_I32BE,
H5T_STD_U64LE, H5T_STD_U64BE, H5T_STD_I64LE, H5T_STD_I64BE,
H5T_IEEE_F32LE, H5T_IEEE_F32BE, H5T_IEEE_F64LE, H5T_IEEE_F64BE};
H5T_STD_U16LE, H5T_STD_U16BE, H5T_STD_I16LE, H5T_STD_I16BE,
H5T_STD_U32LE, H5T_STD_U32BE, H5T_STD_I32LE, H5T_STD_I32BE,
H5T_STD_U64LE, H5T_STD_U64BE, H5T_STD_I64LE, H5T_STD_I64BE,
H5T_IEEE_F32LE, H5T_IEEE_F32BE, H5T_IEEE_F64LE, H5T_IEEE_F64BE};

TESTING("dataset creation with predefined datatypes");

Expand Down Expand Up @@ -9861,8 +9861,7 @@ test_dataset_vlen_io(void)

/* Make sure the connector supports the API functions being tested */
if (!(vol_cap_flags_g & H5VL_CAP_FLAG_FILE_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_GROUP_BASIC) ||
!(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE) ||
!(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) {
!(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_BASIC) || !(vol_cap_flags_g & H5VL_CAP_FLAG_DATASET_MORE)) {
SKIPPED();
printf(" API functions for basic file, group, or dataset aren't supported with this "
"connector\n");
Expand Down Expand Up @@ -9956,6 +9955,20 @@ test_dataset_vlen_io(void)

dset_string = H5I_INVALID_HID;

if (H5Gclose(container_group) < 0) {
H5_FAILED();
printf(" couldn't close container group");
}

container_group = H5I_INVALID_HID;

if (H5Fclose(file_id) < 0) {
H5_FAILED();
printf(" couldn't close file");
}

file_id = H5I_INVALID_HID;

PASSED();

BEGIN_MULTIPART
Expand All @@ -9975,6 +9988,12 @@ test_dataset_vlen_io(void)
wbuf[i].len = i + 1;
}

if ((file_id = H5Fopen(H5_api_test_filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_int);

if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_int);

/* Open dataset */
if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_int);
Expand All @@ -9983,9 +10002,6 @@ test_dataset_vlen_io(void)
if ((H5Dwrite(dset_int, vlen_int, space_id, H5S_ALL, H5P_DEFAULT, (const void *)wbuf)) < 0)
PART_TEST_ERROR(rw_all_int);

if (H5Dflush(dset_int) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

/* Close and reopen file objects to flush cache */
if (H5Dclose(dset_int) < 0)
PART_TEST_ERROR(rw_all_int);
Expand Down Expand Up @@ -10020,6 +10036,16 @@ test_dataset_vlen_io(void)
PART_TEST_ERROR(rw_all_int);
dset_int = H5I_INVALID_HID;

if (H5Gclose(container_group) < 0)
PART_TEST_ERROR(rw_all_int);

container_group = H5I_INVALID_HID;

if (H5Fclose(file_id) < 0)
PART_TEST_ERROR(rw_all_int);

file_id = H5I_INVALID_HID;

/* Verify data */
for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) {
if (!rbuf[i].p)
Expand Down Expand Up @@ -10061,6 +10087,12 @@ test_dataset_vlen_io(void)
wbuf[i].len = i + 1;
}

if ((file_id = H5Fopen(H5_api_test_filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_float);

if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_float);

/* Open dataset */
if ((dset_float = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_float", H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_float);
Expand All @@ -10069,9 +10101,6 @@ test_dataset_vlen_io(void)
if ((H5Dwrite(dset_float, vlen_float, space_id, H5S_ALL, H5P_DEFAULT, (const void *)wbuf)) < 0)
PART_TEST_ERROR(rw_all_float);

if (H5Dflush(dset_float) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

/* Close and reopen file objects to flush cache */
if (H5Dclose(dset_float) < 0)
PART_TEST_ERROR(rw_all_float);
Expand Down Expand Up @@ -10106,6 +10135,16 @@ test_dataset_vlen_io(void)
PART_TEST_ERROR(rw_all_float);
dset_float = H5I_INVALID_HID;

if (H5Gclose(container_group) < 0)
PART_TEST_ERROR(rw_all_float);

container_group = H5I_INVALID_HID;

if (H5Fclose(file_id) < 0)
PART_TEST_ERROR(rw_all_float);

file_id = H5I_INVALID_HID;

/* Verify data */
for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) {
if (!rbuf[i].p)
Expand Down Expand Up @@ -10153,6 +10192,12 @@ test_dataset_vlen_io(void)
wbuf[i].len = i + 1;
}

if ((file_id = H5Fopen(H5_api_test_filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_string);

if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_string);

/* Open the dataset */
if ((dset_string = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_string", H5P_DEFAULT)) <
0)
Expand All @@ -10162,9 +10207,6 @@ test_dataset_vlen_io(void)
if ((H5Dwrite(dset_string, vlen_string, space_id, H5S_ALL, H5P_DEFAULT, (const void *)wbuf)) < 0)
PART_TEST_ERROR(rw_all_string);

if (H5Dflush(dset_string) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

/* Close and reopen file objects to flush cache */
if (H5Dclose(dset_string) < 0)
PART_TEST_ERROR(rw_all_string);
Expand Down Expand Up @@ -10200,6 +10242,16 @@ test_dataset_vlen_io(void)
PART_TEST_ERROR(rw_all_string);
dset_string = H5I_INVALID_HID;

if (H5Gclose(container_group) < 0)
PART_TEST_ERROR(rw_all_string);

container_group = H5I_INVALID_HID;

if (H5Fclose(file_id) < 0)
PART_TEST_ERROR(rw_all_string);

file_id = H5I_INVALID_HID;

/* Verify data */
for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) {
if (!rbuf[i].p)
Expand Down Expand Up @@ -10257,6 +10309,12 @@ test_dataset_vlen_io(void)
wbuf[i].len = i + 1;
}

if ((file_id = H5Fopen(H5_api_test_filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_point_selection);

if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_point_selection);

/* Open dataset */
if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_point_selection);
Expand All @@ -10265,9 +10323,6 @@ test_dataset_vlen_io(void)
if ((H5Dwrite(dset_int, vlen_int, space_id, space_id, H5P_DEFAULT, (const void *)wbuf)) < 0)
PART_TEST_ERROR(rw_point_selection);

if (H5Dflush(dset_int) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

/* Close and reopen file objects to flush cache */
if (H5Dclose(dset_int) < 0)
PART_TEST_ERROR(rw_point_selection);
Expand Down Expand Up @@ -10299,6 +10354,16 @@ test_dataset_vlen_io(void)
PART_TEST_ERROR(rw_point_selection);
dset_int = H5I_INVALID_HID;

if (H5Gclose(container_group) < 0)
PART_TEST_ERROR(rw_point_selection);

container_group = H5I_INVALID_HID;

if (H5Fclose(file_id) < 0)
PART_TEST_ERROR(rw_point_selection);

file_id = H5I_INVALID_HID;

/* Verify data */
for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) {
if (i % 2 == 0) {
Expand Down Expand Up @@ -10359,6 +10424,12 @@ test_dataset_vlen_io(void)
wbuf[i].len = i + 1;
}

if ((file_id = H5Fopen(H5_api_test_filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

/* Open dataset */
if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);
Expand All @@ -10367,9 +10438,6 @@ test_dataset_vlen_io(void)
if ((H5Dwrite(dset_int, vlen_int, space_id, space_id, H5P_DEFAULT, (const void *)wbuf)) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

if (H5Dflush(dset_int) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

/* Close and reopen file objects to flush cache */
if (H5Dclose(dset_int) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);
Expand Down Expand Up @@ -10401,6 +10469,16 @@ test_dataset_vlen_io(void)
PART_TEST_ERROR(rw_hyperslab_selection);
dset_int = H5I_INVALID_HID;

if (H5Gclose(container_group) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

container_group = H5I_INVALID_HID;

if (H5Fclose(file_id) < 0)
PART_TEST_ERROR(rw_hyperslab_selection);

file_id = H5I_INVALID_HID;

/* Verify data */
for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) {
if (i % stride[0] == 0) {
Expand Down Expand Up @@ -10466,10 +10544,6 @@ test_dataset_vlen_io(void)
TEST_ERROR;
if (H5Tclose(vlen_string) < 0)
TEST_ERROR;
if (H5Gclose(container_group) < 0)
TEST_ERROR;
if (H5Fclose(file_id) < 0)
TEST_ERROR;
PASSED();
return 0;
error:
Expand Down Expand Up @@ -10499,8 +10573,11 @@ test_dataset_vlen_io(void)
H5Tclose(vlen_int);
H5Tclose(vlen_float);
H5Tclose(vlen_string);
H5Gclose(container_group);
H5Fclose(file_id);

if (container_group != H5I_INVALID_HID)
H5Gclose(container_group);
if (file_id != H5I_INVALID_HID)
H5Fclose(file_id);
}
H5E_END_TRY

Expand Down

0 comments on commit 5c91a30

Please sign in to comment.