/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * 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://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Raymond Lu * 13 February 2013 * * Purpose: Tests the plugin module (H5PL) */ #include #include #include "h5test.h" #include "H5srcdir.h" /* * This file needs to access private datatypes from the H5Z package. */ #define H5Z_PACKAGE #include "H5Zpkg.h" const char *FILENAME[] = { "plugin", NULL }; #define FILENAME_BUF_SIZE 1024 #define KB 1024 #define FILE_DEFLATE_NAME "deflate.h5" /* Dataset names for testing filters */ #define DSET_DEFAULT_NAME "default" #define DSET_CHUNKED_NAME "chunked" #define DSET_COMPACT_NAME "compact" #define DSET_SIMPLE_IO_NAME "simple_io" #define DSET_USERBLOCK_IO_NAME "userblock_io" #define DSET_COMPACT_IO_NAME "compact_io" #define DSET_COMPACT_MAX_NAME "max_compact" #define DSET_COMPACT_MAX2_NAME "max_compact_2" #define DSET_CONV_BUF_NAME "conv_buf" #define DSET_TCONV_NAME "tconv" #define DSET_DEFLATE_NAME "deflate" #define DSET_BZIP2_NAME "bzip2" #define DSET_DYNLIB1_NAME "dynlib1" #define DSET_DYNLIB2_NAME "dynlib2" #ifdef H5_HAVE_FILTER_SZIP #define DSET_SZIP_NAME "szip" #endif /* H5_HAVE_FILTER_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" #if defined H5_HAVE_FILTER_SZIP && defined H5_HAVE_FILTER_SHUFFLE && defined H5_HAVE_FILTER_FLETCHER32 #define DSET_SHUF_SZIP_FLET_NAME "shuffle+szip+fletcher32" #define DSET_SHUF_SZIP_FLET_NAME_2 "shuffle+szip+fletcher32_2" #endif /* defined H5_HAVE_FILTER_SZIP && defined H5_HAVE_FILTER_SHUFFLE && defined H5_HAVE_FILTER_FLETCHER32 */ #define DSET_MISSING_NAME "missing" #define DSET_CAN_APPLY_NAME "can_apply" #define DSET_CAN_APPLY_NAME2 "can_apply2" #ifdef H5_HAVE_FILTER_SZIP #define DSET_CAN_APPLY_SZIP_NAME "can_apply_szip" #endif /* H5_HAVE_FILTER_SZIP */ #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_NBIT_COMPOUND_NAME_3 "nbit_compound_3" #define DSET_NBIT_INT_SIZE_NAME "nbit_int_size" #define DSET_NBIT_FLT_SIZE_NAME "nbit_flt_size" #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_SCALEOFFSET_FLOAT_NAME_2 "scaleoffset_float_2" #define DSET_SCALEOFFSET_DOUBLE_NAME "scaleoffset_double" #define DSET_SCALEOFFSET_DOUBLE_NAME_2 "scaleoffset_double_2" #define DSET_COMPARE_DCPL_NAME "compare_dcpl" #define DSET_COMPARE_DCPL_NAME_2 "compare_dcpl_2" #define DSET_COPY_DCPL_NAME_1 "copy_dcpl_1" #define DSET_COPY_DCPL_NAME_2 "copy_dcpl_2" #define COPY_DCPL_EXTFILE_NAME "ext_file" #define DSET_DEPREC_NAME "deprecated" #define DSET_DEPREC_NAME_CHUNKED "deprecated_chunked" #define DSET_DEPREC_NAME_COMPACT "deprecated_compact" #define DSET_DEPREC_NAME_FILTER "deprecated_filter" #define USER_BLOCK 1024 #define SIXTY_FOUR_KB 65536 /* Temporary filter IDs used for testing */ /* Flags for testing filters */ #define DISABLE_FLETCHER32 0 #define ENABLE_FLETCHER32 1 #define DATA_CORRUPTED 1 #define DATA_NOT_CORRUPTED 0 /* Parameters for the "set local" test */ #define BOGUS2_PERM_NPARMS 2 /* Number of "permanent" parameters */ #define BOGUS2_PARAM_1 13 /* (No particular meaning, just for checking value) */ #define BOGUS2_PARAM_2 35 /* (No particular meaning, just for checking value) */ #define BOGUS2_ALL_NPARMS 4 /* Total number of parameter = permanent + "local" parameters */ /* Dimensionality for conversion buffer test */ #define DIM1 100 /* Dim. Size of data member # 1 */ #define DIM2 5000 /* Dim. Size of data member # 2 */ #define DIM3 10 /* Dim. Size of data member # 3 */ /* Parameters for internal filter test */ #define FILTER_CHUNK_DIM1 2 #define FILTER_CHUNK_DIM2 25 #define FILTER_HS_OFFSET1 7 #define FILTER_HS_OFFSET2 30 #define FILTER_HS_SIZE1 4 #define FILTER_HS_SIZE2 50 /* Names for noencoder test */ #ifdef H5_HAVE_FILTER_SZIP #define NOENCODER_FILENAME "noencoder.h5" #define NOENCODER_COPY_FILENAME "noencoder.h5.copy" #define NOENCODER_TEST_DATASET "noencoder_tdset.h5" #define NOENCODER_SZIP_DATASET "noencoder_szip_dset.h5" #define NOENCODER_SZIP_SHUFF_FLETCH_DATASET "noencoder_szip_shuffle_fletcher_dset.h5" #endif /* H5_HAVE_FILTER_SZIP */ /* Names for zero-dim test */ #define ZERODIM_DATASET "zerodim" /* Parameters for zero-dim test */ #define MISSING_CHUNK_DATASET "missing_chunk" #define MISSING_CHUNK_DIM 100 /* Names for random chunks test */ #define NPOINTS 50 /* Parameters for huge chunks test */ #define HUGE_DATASET "Dataset" #define HUGE_DIM ((hsize_t)16 * 1024 * 1024 * 1024) #define HUGE_CHUNK_DIM ((hsize_t)2 * 1024 * 1024 * 1024) #define TOO_HUGE_CHUNK_DIM ((hsize_t)4 * 1024 * 1024 * 1024) #define HUGE_DATASET2 "Dataset2" #define HUGE_DIM2_0 ((hsize_t)16 * 1024) #define HUGE_DIM2_1 ((hsize_t)16 * 1024) #define HUGE_DIM2_2 ((hsize_t)16 * 1024) #define HUGE_CHUNK_DIM2_0 ((hsize_t)2 * 1024) #define HUGE_CHUNK_DIM2_1 ((hsize_t)1024) #define HUGE_CHUNK_DIM2_2 ((hsize_t)1024) #define TOO_HUGE_CHUNK_DIM2_0 ((hsize_t)4 * 1024) #define TOO_HUGE_CHUNK_DIM2_1 ((hsize_t)1024) #define TOO_HUGE_CHUNK_DIM2_2 ((hsize_t)1024) /* Parameters for testing bypassing chunk cache */ #define BYPASS_DATASET1 "Dset1" #define BYPASS_DATASET2 "Dset2" #define BYPASS_DIM 1000 #define BYPASS_CHUNK_DIM 500 #define BYPASS_FILL_VALUE 7 /* Shared global arrays */ #define DSET_DIM1 100 #define DSET_DIM2 200 int points_deflate[DSET_DIM1][DSET_DIM2], points_dynlib1[DSET_DIM1][DSET_DIM2], points_dynlib2[DSET_DIM1][DSET_DIM2], points_bzip2[DSET_DIM1][DSET_DIM2]; /*------------------------------------------------------------------------- * Function: test_filter_internal * * Purpose: Tests writing entire data and partial data with filters * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * 27 February 2013 * *------------------------------------------------------------------------- */ static herr_t test_filter_internal(hid_t fid, const char *name, hid_t dcpl, hsize_t *dset_size) { hid_t dataset; /* Dataset ID */ hid_t dxpl; /* Dataset xfer property list ID */ hid_t write_dxpl; /* Dataset xfer property list ID for writing */ hid_t sid; /* Dataspace ID */ const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */ const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */ void *tconv_buf = NULL; /* Temporary conversion buffer */ int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2]; size_t i, j; /* Local index variables */ int n = 0; 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 = HDmalloc((size_t)1000); if(H5Pset_buffer(dxpl, (size_t)1000, tconv_buf, NULL) < 0) goto error; if((write_dxpl = H5Pcopy(dxpl)) < 0) TEST_ERROR; TESTING(" filters (setup)"); /* Check if all the filters are available */ if(H5Pall_filters_avail(dcpl)!=TRUE) { H5_FAILED(); printf(" Line %d: Incorrect filter availability\n",__LINE__); goto error; } /* end if */ /* Create the dataset */ if((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 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) TEST_ERROR; for(i=0; i<(size_t)size[0]; i++) { for(j=0; j<(size_t)size[1]; j++) { if(0!=check[i][j]) { H5_FAILED(); printf(" Read a non-zero value.\n"); printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } } } PASSED(); /*---------------------------------------------------------------------- * STEP 2: Test filters by setting up a chunked dataset and writing * to it. *---------------------------------------------------------------------- */ TESTING(" filters (write)"); for(i=n=0; i