From 24c88ddadf935c4405bada45ab23f088ee316fdc Mon Sep 17 00:00:00 2001 From: Xiaowen Wu Date: Wed, 23 Mar 2005 12:46:46 -0500 Subject: [PATCH] [svn-r10385] Purpose: New feature. Description: The scaleoffset filter is now complete for compressing integers. All previous bugs have been fixed. The filter does not compress floating-point at present. Solution: Update test cases for the scaleoffset filter. Two for integer types and one for floating-point (even though the filter does not compress). The two test cases for integer type tests situations where fill value is defined and undefined for the dataset. Platforms tested: heping, copper, shanti Misc. update: --- test/dsets.c | 332 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 304 insertions(+), 28 deletions(-) diff --git a/test/dsets.c b/test/dsets.c index 864648580d..2085175fa0 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -74,13 +74,15 @@ const char *FILENAME[] = { #define DSET_SET_LOCAL_NAME "set_local" #define DSET_SET_LOCAL_NAME_2 "set_local_2" #define DSET_ONEBYTE_SHUF_NAME "onebyte_shuffle" -#define DSET_NBIT_INT_NAME "nbit_int" -#define DSET_NBIT_FLOAT_NAME "nbit_float" -#define DSET_NBIT_DOUBLE_NAME "nbit_double" -#define DSET_NBIT_ARRAY_NAME "nbit_array" -#define DSET_NBIT_COMPOUND_NAME "nbit_compound" -#define DSET_NBIT_COMPOUND_NAME_2 "nbit_compound_2" -#define DSET_SCALEOFFSET_INT_NAME "scaleoffset_int" +#define DSET_NBIT_INT_NAME "nbit_int" +#define DSET_NBIT_FLOAT_NAME "nbit_float" +#define DSET_NBIT_DOUBLE_NAME "nbit_double" +#define DSET_NBIT_ARRAY_NAME "nbit_array" +#define DSET_NBIT_COMPOUND_NAME "nbit_compound" +#define DSET_NBIT_COMPOUND_NAME_2 "nbit_compound_2" +#define DSET_SCALEOFFSET_INT_NAME "scaleoffset_int" +#define DSET_SCALEOFFSET_INT_NAME_2 "scaleoffset_int_2" +#define DSET_SCALEOFFSET_FLOAT_NAME "scaleoffset_float" #define DSET_COMPARE_DCPL_NAME "compare_dcpl" #define DSET_COMPARE_DCPL_NAME_2 "compare_dcpl_2" @@ -3547,6 +3549,7 @@ error: * Function: test_scaleoffset_int * * Purpose: Tests the integer datatype for scaleoffset filter + * with fill value not defined * * Return: Success: 0 * @@ -3574,35 +3577,39 @@ test_scaleoffset_int(hid_t file) #endif /* H5_HAVE_FILTER_SCALEOFFSET */ puts("Testing scaleoffset filter"); - TESTING(" scaleoffset int (setup)"); + TESTING(" scaleoffset int without fill value (setup)"); #ifdef H5_HAVE_FILTER_SCALEOFFSET datatype = H5Tcopy(H5T_NATIVE_INT); -#if 0 + /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE)<0) goto error; -#endif + if(H5Tset_order(datatype, H5T_ORDER_BE)<0) goto error; + /* Create the data space */ if ((space = H5Screate_simple(2, size, NULL))<0) goto error; - /* Createa the dataset property list */ + /* Create the dataset property list */ if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error; - if (H5Pset_chunk(dc, 2, chunk_size)<0) goto error; - if (H5Pset_scaleoffset(dc, 0)<0) goto error; + + /* Fill value undefined */ if (H5Pset_fill_value(dc, datatype, NULL)<0) goto error; + /* Set up to use scaleoffset filter, let library calculate minbits */ + if (H5Pset_chunk(dc, 2, chunk_size)<0) goto error; + if (H5Pset_scaleoffset(dc, 0)<0) goto error; + /* Create the dataset */ if ((dataset = H5Dcreate(file, DSET_SCALEOFFSET_INT_NAME, datatype, space,dc))<0) goto error; - /* Initialize data, assuming size of long_long >= size of int */ + /* Initialize data */ for (i= 0;i< size[0]; i++) for (j = 0; j < size[1]; j++) { - orig_data[i][j] = (long_long)HDrandom() % - 10000; + orig_data[i][j] = HDrandom() % 10000; + /* even-numbered values are negtive */ if((i*size[1]+j+1)%2 == 0) orig_data[i][j] = -orig_data[i][j]; - } + } PASSED(); #else @@ -3615,12 +3622,11 @@ test_scaleoffset_int(hid_t file) * to it. *---------------------------------------------------------------------- */ - TESTING(" scaleoffset int (write)"); + TESTING(" scaleoffset int without fill value (write)"); #ifdef H5_HAVE_FILTER_SCALEOFFSET if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - orig_data)<0) - goto error; + orig_data)<0) goto error; PASSED(); #else SKIPPED(); @@ -3631,13 +3637,12 @@ test_scaleoffset_int(hid_t file) * STEP 2: Try to read the data we just wrote. *---------------------------------------------------------------------- */ - TESTING(" scaleoffset int (read)"); + TESTING(" scaleoffset int without fill value (read)"); #ifdef H5_HAVE_FILTER_SCALEOFFSET /* Read the dataset back */ if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - new_data)<0) - goto error; + new_data)<0) goto error; /* Check that the values read are the same as the values written */ for (i=0; i