Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip part of dtypes.c _Float16 file size check for certain VFDs #4182

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions test/dtypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -6051,6 +6051,7 @@ test__Float16(void)
{
#ifdef H5_HAVE__FLOAT16
H5T_path_t *path = NULL;
const char *env_h5_driver;
hsize_t dims[1];
htri_t is_little_endian;
H5T_t *native_dtype = NULL;
Expand All @@ -6064,6 +6065,10 @@ test__Float16(void)

TESTING("_Float16 datatype");

env_h5_driver = getenv(HDF5_DRIVER);
if (env_h5_driver == NULL)
env_h5_driver = "nomatch";

/* Check that native macro maps to a valid type */
if (0 == H5Tget_size(H5T_NATIVE_FLOAT16)) {
H5_FAILED();
Expand Down Expand Up @@ -6397,24 +6402,30 @@ test__Float16(void)
if (H5Fclose(fid) < 0)
TEST_ERROR;

{
h5_stat_size_t file_size = h5_get_file_size(filename, H5P_DEFAULT);
if (!h5_driver_uses_multiple_files(env_h5_driver, H5_EXCLUDE_NON_MULTIPART_DRIVERS)) {
bool is_default_vfd_compat = false;

if (file_size < 0)
if (h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &is_default_vfd_compat) < 0)
TEST_ERROR;
if ((size_t)file_size < dims[0] * sizeof(H5__Float16)) {
H5_FAILED();
AT();
printf("File size value was too small\n");
goto error;
}
if (is_default_vfd_compat) {
h5_stat_size_t file_size = h5_get_file_size(filename, H5P_DEFAULT);

/* 4096 bytes is arbitrary, but should suffice for now */
if ((size_t)file_size > (dims[0] * sizeof(H5__Float16)) + 4096) {
H5_FAILED();
AT();
printf("File size value was too large\n");
goto error;
if (file_size < 0)
TEST_ERROR;
if ((size_t)file_size < dims[0] * sizeof(H5__Float16)) {
H5_FAILED();
AT();
printf("File size value was too small\n");
goto error;
}

/* 4096 bytes is arbitrary, but should suffice for now */
if ((size_t)file_size > (dims[0] * sizeof(H5__Float16)) + 4096) {
H5_FAILED();
AT();
printf("File size value was too large\n");
goto error;
}
}
}

Expand Down
Loading