diff --git a/test/dsets.c b/test/dsets.c index 7554b01b1f..b0317d5cea 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -1,18 +1,7 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* + * Copyright (C) 1997 NCSA + * All rights reserved. + * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * @@ -38,12 +27,16 @@ const char *FILENAME[] = { #define DSET_COMPACT_IO_NAME "compact_io" #define DSET_TCONV_NAME "tconv" #define DSET_DEFLATE_NAME "deflate" +#define DSET_SZIP_NAME "szip" #define DSET_SHUFFLE_NAME "shuffle" #define DSET_FLETCHER32_NAME "fletcher32" #define DSET_FLETCHER32_NAME_2 "fletcher32_2" #define DSET_FLETCHER32_NAME_3 "fletcher32_3" #define DSET_SHUF_DEF_FLET_NAME "shuffle+deflate+fletcher32" #define DSET_SHUF_DEF_FLET_NAME_2 "shuffle+deflate+fletcher32_2" +#define DSET_SHUF_SZIP_FLET_NAME "shuffle+szip+fletcher32" +#define DSET_SHUF_SZIP_FLET_NAME_2 "shuffle+szip+fletcher32_2" + #define DSET_BOGUS_NAME "bogus" #define DSET_MISSING_NAME "missing" #define DSET_ONEBYTE_SHUF_NAME "onebyte_shuffle" @@ -775,8 +768,8 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, * might as well test all we can! */ if ((dxpl = H5Pcreate (H5P_DATASET_XFER))<0) goto error; - tconv_buf = malloc (1000); - if (H5Pset_buffer (dxpl, 1000, tconv_buf, NULL)<0) goto error; + tconv_buf = malloc (80000); + if (H5Pset_buffer (dxpl, 80000, tconv_buf, NULL)<0) goto error; if (if_fletcher32==DISABLE_FLETCHER32) { if(H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)<0) goto error; @@ -825,10 +818,13 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, } } - if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, points)<0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, points)<0){ goto error; + } - if((*dset_size=H5Dget_storage_size(dataset))==0) goto error; + if((*dset_size=H5Dget_storage_size(dataset))==0) { + goto error; + } PASSED(); @@ -914,6 +910,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, if(status>=0) goto error; } else { /* Read the dataset back and check it */ + fflush(stdout); if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) goto error; @@ -932,7 +929,6 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, } if((*dset_size=H5Dget_storage_size(dataset))==0) goto error; - PASSED(); /*---------------------------------------------------------------------- @@ -1048,7 +1044,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, PASSED(); /* Get the storage size of the dataset */ - if((*dset_size=H5Dget_storage_size(dataset))==0) goto error; + if((*dset_size=H5Dget_storage_size(dataset))==0) goto error; /* Clean up objects used for this test */ if (H5Dclose (dataset)<0) goto error; if (H5Sclose (sid)<0) goto error; @@ -1061,6 +1057,331 @@ error: return -1; } +/*------------------------------------------------------------------------- + * Function: test_filter_internal_szip + * + * Purpose: Tests dataset compression. If compression is requested when + * it hasn't been compiled into the library (such as when + * updating an existing compressed dataset) then data is sent to + * the file uncompressed but no errors are returned. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Robb Matzke + * Wednesday, April 15, 1998 + * + * Modifications: + * Moved out of main test_compression routine + * Quincey Koziol, November 14, 2002 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_filter_internal_szip(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, + int corrupted, hsize_t *dset_size) +{ + hid_t dataset; /* Dataset ID */ + hid_t dxpl; /* Dataset xfer property list ID */ + hid_t sid; /* Dataspace ID */ + const hsize_t size[2] = {100, 200}; /* Dataspace dimensions */ + const hssize_t hs_offset[2] = {7, 30}; /* Hyperslab offset */ + const hsize_t hs_size[2] = {4, 50}; /* Hyperslab size */ + void *tconv_buf = NULL; /* Temporary conversion buffer */ + hsize_t i, j, n; /* Local index variables */ + herr_t status; /* Error status */ + + /* Create the data space */ + if ((sid = H5Screate_simple(2, size, NULL))<0) goto error; + + /* + * Create a small conversion buffer to test strip mining. We + * might as well test all we can! + */ + if ((dxpl = H5Pcreate (H5P_DATASET_XFER))<0) goto error; + tconv_buf = malloc (80000); + if (H5Pset_buffer (dxpl, 80000, tconv_buf, NULL)<0) goto error; + if (if_fletcher32==DISABLE_FLETCHER32) { + if(H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)<0) + goto error; + if(H5Z_DISABLE_EDC != H5Pget_edc_check(dxpl)) + goto error; + } + TESTING(" filters (setup)"); + + /* Create the dataset */ + if ((dataset = H5Dcreate(fid, name, H5T_NATIVE_INT, sid, + dcpl))<0) goto error; + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 1: Read uninitialized data. It should be zero. + *---------------------------------------------------------------------- + */ + TESTING(" filters (uninitialized read)"); + + if (H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) + goto error; + + for (i=0; i=0) goto error; + + /* Callback decides to continue inspite data is corrupted. */ + if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error; + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) + goto error; + + /* Callback decides to fail when data is corrupted. */ + if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error; + H5E_BEGIN_TRY { + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + } H5E_END_TRY; + if(status>=0) goto error; + } else { + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) + goto error; + + /* Check that the values read are the same as the values written */ + for (i=0; i=0) goto error; + + /* Callback decides to continue inspite data is corrupted. */ + if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error; + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) + goto error; + + /* Callback decides to fail when data is corrupted. */ + if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error; + H5E_BEGIN_TRY { + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + } H5E_END_TRY; + if(status>=0) goto error; + } else { + /* Read the dataset back and check it */ + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) + goto error; + + /* Check that the values read are the same as the values written */ + for (i=0; i=0) goto error; + + /* Callback decides to continue inspite data is corrupted. */ + if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error; + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) + goto error; + + /* Callback decides to fail when data is corrupted. */ + if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error; + H5E_BEGIN_TRY { + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + } H5E_END_TRY; + if(status>=0) goto error; + } else { + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) + goto error; + + /* Check that the values read are the same as the values written */ + for (i=0; i=0) goto error; + + /* Callback decides to continue inspite data is corrupted. */ + if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error; + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) + goto error; + + /* Callback decides to fail when data is corrupted. */ + if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error; + H5E_BEGIN_TRY { + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + } H5E_END_TRY; + if(status>=0) goto error; + } else { + if (H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check)<0) + goto error; + + /* Check that the values read are the same as the values written */ + for (i=0; i