adding to test

This commit is contained in:
Edward Hartnett 2024-08-29 01:43:29 -06:00
parent 337c4ebca0
commit 28747abae8

View File

@ -30,12 +30,10 @@ main()
hsize_t dims[1];
printf("\n*** Checking HDF5 variable functions with zstandard compression.\n");
printf("*** Checking HDF5 deflate filter setting and getting...");
#define DEFLATE_LEVEL 9
printf("*** Checking HDF5 zstd filter setting and getting...");
#define MAX_NAME 100
#define NUM_CD_ELEM 10
/* HDF5 defines this... */
#define DEFLATE_NAME "deflate"
#define ZSTD_NAME "zstd"
{
H5Z_filter_t filter;
@ -106,6 +104,72 @@ main()
ERR;
}
SUMMARIZE_ERR;
printf("*** Checking HDF5 zstd filter with int data...");
#define MAX_NAME 100
#define NUM_CD_ELEM 10
/* HDF5 defines this... */
#define ZSTD_NAME "zstd"
{
H5Z_filter_t filter;
int num_filters;
hid_t propid;
unsigned int flags, cd_values[NUM_CD_ELEM], filter_config;
size_t cd_nelems = NUM_CD_ELEM;
size_t namelen = MAX_NAME;
char name[MAX_NAME + 1];
unsigned int id = H5Z_FILTER_ZSTD;
unsigned int ulevel = 1;
herr_t code;
/* Open file and create group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate1(fileid, GRP_NAME, 0)) < 0) ERR;
/* Write an array of bools, with zstandard compression. */
dims[0] = DIM1_LEN;
if ((propid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR;
if (H5Pset_layout(propid, H5D_CHUNKED)) ERR;
if (H5Pset_chunk(propid, 1, dims)) ERR;
if ((code = H5Pset_filter(propid, id, H5Z_FLAG_OPTIONAL, 1, &ulevel)))
ERR;
if ((spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;
if ((datasetid = H5Dcreate1(grpid, VAR_BOOL_NAME, H5T_NATIVE_HBOOL,
spaceid, propid)) < 0) ERR;
if (H5Dwrite(datasetid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT,
bool_out) < 0) ERR;
if (H5Dclose(datasetid) < 0 ||
H5Pclose(propid) < 0 ||
H5Sclose(spaceid) < 0 ||
H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0)
ERR;
/* Now reopen the file and check. */
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen1(fileid, GRP_NAME)) < 0) ERR;
if ((datasetid = H5Dopen1(grpid, VAR_BOOL_NAME)) < 0) ERR;
if ((propid = H5Dget_create_plist(datasetid)) < 0) ERR;
/* The possible values of filter (which is just an int) can be
* found in H5Zpublic.h. */
if ((num_filters = H5Pget_nfilters(propid)) < 0) ERR;
printf("num_filters %d\n", num_filters);
if (num_filters != 1) ERR;
if ((filter = H5Pget_filter2(propid, 0, &flags, &cd_nelems, cd_values,
namelen, name, &filter_config)) < 0) ERR;
if (filter != H5Z_FILTER_ZSTD || cd_nelems != 1 ||
cd_values[0] != ulevel) ERR;
if (strcmp(name, ZSTD_NAME)) ERR;
if (H5Dclose(datasetid) < 0 ||
H5Pclose(propid) < 0 ||
H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0)
ERR;
}
SUMMARIZE_ERR;
FINAL_RESULTS;
}