summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRobert E. McGrath <mcgrath@ncsa.uiuc.edu>2004-11-02 19:12:06 (GMT)
committerRobert E. McGrath <mcgrath@ncsa.uiuc.edu>2004-11-02 19:12:06 (GMT)
commit3f0abcc71f1803b59d8ca64b9ec642235fdfc1c9 (patch)
treecdad2edff464edf39f132edc8082615f1ca51738 /test
parentf7c4277bbbbe531ba37b36bb6b2e1b3f2966efea (diff)
downloadhdf5-3f0abcc71f1803b59d8ca64b9ec642235fdfc1c9.zip
hdf5-3f0abcc71f1803b59d8ca64b9ec642235fdfc1c9.tar.gz
hdf5-3f0abcc71f1803b59d8ca64b9ec642235fdfc1c9.tar.bz2
[svn-r9494] Purpose:
Fix SZIP filter to dynmically detect encoder. Description: Solution: See: http://hdf.ncsa.uiuc.edu/RFC/SZIP/Szip_dynamic_12_Oct.pdf Changes to library tests, contingent on detecting SZIP encoder.
Diffstat (limited to 'test')
-rw-r--r--test/dsets.c194
-rw-r--r--test/h5test.c47
-rw-r--r--test/h5test.h4
-rw-r--r--test/tmisc.c16
4 files changed, 158 insertions, 103 deletions
diff --git a/test/dsets.c b/test/dsets.c
index 6b29031..638a865 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -1782,7 +1782,7 @@ test_filters(hid_t file)
hsize_t deflate_size; /* Size of dataset with deflate filter */
#endif /* H5_HAVE_FILTER_DEFLATE */
-#if (defined H5_HAVE_FILTER_SZIP) && (defined H5_SZIP_CAN_ENCODE)
+#ifdef H5_HAVE_FILTER_SZIP
hsize_t szip_size; /* Size of dataset with szip filter */
unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK;
unsigned szip_pixels_per_block=4;
@@ -1886,26 +1886,27 @@ test_filters(hid_t file)
*/
#ifdef H5_HAVE_FILTER_SZIP
TESTING("szip filter (with encoder)");
- if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
- if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error;
+ if ( h5_szip_can_encode() == 1) {
+ if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error;
-#ifdef H5_SZIP_CAN_ENCODE
puts("");
if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block)<0) goto error;
if(test_filter_internal(file,DSET_SZIP_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&szip_size)<0) goto error;
-#else
+ if (H5Pclose (dc)<0) goto error;
+ } else {
SKIPPED();
-#endif
+ }
+
+ TESTING("szip filter (without encoder)");
- TESTING("szip filter (without encoder)");
-#ifndef H5_SZIP_CAN_ENCODE
+ if ( h5_szip_can_encode() != 1) {
puts("");
if(test_filter_noencoder(NOENCODER_SZIP_DATASET) < 0) goto error;
-#else
+ } else {
SKIPPED();
-#endif
+ }
- if (H5Pclose (dc)<0) goto error;
#else /* H5_HAVE_FILTER_SZIP */
TESTING("szip filter");
SKIPPED();
@@ -1987,29 +1988,30 @@ test_filters(hid_t file)
if (H5Pset_shuffle (dc)<0) goto error;
/* Make sure encoding is enabled */
-#ifdef H5_SZIP_CAN_ENCODE
+ if ( h5_szip_can_encode() == 1) {
puts("");
if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block)<0) goto error;
if(test_filter_internal(file,DSET_SHUF_SZIP_FLET_NAME,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&combo_size)<0) goto error;
-#else
+ } else {
SKIPPED();
-#endif
+ }
+
+ TESTING("shuffle+szip+checksum filters(checksum first, without encoder)");
- TESTING("shuffle+szip+checksum filters(checksum first, without encoder)");
-#ifndef H5_SZIP_CAN_ENCODE
+ if ( h5_szip_can_encode() != 1) {
puts("");
if (test_filter_noencoder(NOENCODER_SZIP_SHUFF_FLETCH_DATASET) < 0) goto error;
-#else
+ } else {
SKIPPED();
-#endif
+ }
/* Clean up objects used for this test */
if (H5Pclose (dc)<0) goto error;
TESTING("shuffle+szip+checksum filters(checksum last, with encoder)");
/* Make sure encoding is enabled */
-#ifdef H5_SZIP_CAN_ENCODE
+ if ( h5_szip_can_encode() == 1) {
puts("");
if((dc = H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error;
@@ -2022,9 +2024,9 @@ test_filters(hid_t file)
/* Clean up objects used for this test */
if (H5Pclose (dc)<0) goto error;
-#else
+ } else {
SKIPPED();
-#endif /* H5_SZIP_CAN_ENCODE */
+ }
#else /* H5_HAVE_FILTER_SZIP && H5_HAVE_FILTER_SHUFFLE && H5_HAVE_FILTER_FLETCHER32 */
TESTING("shuffle+szip+fletcher32 filters");
@@ -2758,10 +2760,10 @@ static herr_t
test_can_apply_szip(hid_t
#ifndef H5_HAVE_FILTER_SZIP
UNUSED
-#endif /* H5_HAVE_FILTER_SSZIP */
+#endif /* H5_HAVE_FILTER_SZIP */
file)
{
-#if (defined H5_HAVE_FILTER_SZIP) & (defined H5_SZIP_CAN_ENCODE)
+#ifdef H5_HAVE_FILTER_SZIP
hid_t dsid; /* Dataset ID */
hid_t sid; /* Dataspace ID */
hid_t dcpl; /* Dataspace creation property list ID */
@@ -2772,160 +2774,157 @@ file)
const hsize_t chunk_dims[2] = {250, 2048}; /* Chunk dimensions */
const hsize_t chunk_dims2[2] = {2, 1}; /* Chunk dimensions */
herr_t ret; /* Status value */
-#else /* H5_HAVE_FILTER_SZIP & H5_SZIP_CAN_ENCODE */
- #ifdef H5_HAVE_FILTER_SZIP
- const char *not_supported= " Szip encoding is not enabled.";
- #else /* H5_HAVE_FILTER_SZIP */
- const char *not_supported= " Szip filter is not enabled.";
- #endif /* H5_HAVE_FILTER_SZIP */
-#endif /* H5_HAVE_FILTER_SSZIP & H5_SZIP_CAN_ENCODE */
+#endif /* H5_HAVE_FILTER_SZIP */
TESTING("dataset szip filter 'can apply' callback");
-#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE)
+#ifdef H5_HAVE_FILTER_SZIP
+ if (h5_szip_can_encode() == 1) {
/* Create the data space */
- if ((sid = H5Screate_simple(2, dims, NULL))<0) {
+ if ((sid = H5Screate_simple(2, dims, NULL))<0) {
H5_FAILED();
printf(" Line %d: Can't open dataspace\n",__LINE__);
goto error;
- } /* end if */
+ } /* end if */
- /* Create dcpl with special filter */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) {
+ /* Create dcpl with special filter */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) {
H5_FAILED();
printf(" Line %d: Can't create dcpl\n",__LINE__);
goto error;
- } /* end if */
- if(H5Pset_chunk(dcpl, 2, chunk_dims)<0) {
+ } /* end if */
+ if(H5Pset_chunk(dcpl, 2, chunk_dims)<0) {
H5_FAILED();
printf(" Line %d: Can't set chunk sizes\n",__LINE__);
goto error;
- } /* end if */
+ } /* end if */
- /* Set (invalid at property set time) szip parameters */
- szip_pixels_per_block=3;
- H5E_BEGIN_TRY {
+ /* Set (invalid at property set time) szip parameters */
+ szip_pixels_per_block=3;
+ H5E_BEGIN_TRY {
ret=H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block);
- } H5E_END_TRY;
- if(ret>=0) {
+ } H5E_END_TRY;
+ if(ret>=0) {
H5_FAILED();
printf(" Line %d: Shouldn't be able to set szip filter\n",__LINE__);
goto error;
- }
+ }
- /* Set (invalid at property set time) szip parameters */
- szip_pixels_per_block=512;
- H5E_BEGIN_TRY {
+ /* Set (invalid at property set time) szip parameters */
+ szip_pixels_per_block=512;
+ H5E_BEGIN_TRY {
ret=H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block);
- } H5E_END_TRY;
- if(ret>=0) {
+ } H5E_END_TRY;
+ if(ret>=0) {
H5_FAILED();
printf(" Line %d: Shouldn't be able to set szip filter\n",__LINE__);
goto error;
- }
+ }
- /* Set (invalid at dataset creation time) szip parameters */
- szip_pixels_per_block=2;
- if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block)<0) {
+ /* Set (invalid at dataset creation time) szip parameters */
+ szip_pixels_per_block=2;
+ if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block)<0) {
H5_FAILED();
printf(" Line %d: Can't set szip filter\n",__LINE__);
goto error;
- }
+ }
- /* Create new dataset */
- /* (Should succeed; according to the new algorithm, scanline should be reset
+ /* Create new dataset */
+ /* (Should succeed; according to the new algorithm, scanline should be reset
to 2*128 satisfying 'maximum blocks per scanline' condition) */
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY {
dsid = H5Dcreate(file, DSET_CAN_APPLY_SZIP_NAME, H5T_NATIVE_INT, sid, dcpl);
- } H5E_END_TRY;
- if (dsid <=0) {
+ } H5E_END_TRY;
+ if (dsid <=0) {
H5_FAILED();
printf(" Line %d: Should have created dataset!\n",__LINE__);
goto error;
- } /* end if */
+ } /* end if */
- /* Close dataset */
- if(H5Dclose(dsid)<0) {
+ /* Close dataset */
+ if(H5Dclose(dsid)<0) {
H5_FAILED();
printf(" Line %d: Can't close dataset\n",__LINE__);
goto error;
- } /* end if */
+ } /* end if */
- /* Close dataspace */
- if(H5Sclose(sid)<0) {
+ /* Close dataspace */
+ if(H5Sclose(sid)<0) {
H5_FAILED();
printf(" Line %d: Can't close dataspace\n",__LINE__);
goto error;
- } /* end if */
+ } /* end if */
- /* Close dataset creation property list */
- if(H5Pclose(dcpl)<0) {
+ /* Close dataset creation property list */
+ if(H5Pclose(dcpl)<0) {
H5_FAILED();
printf(" Line %d: Can't close dcpl\n",__LINE__);
goto error;
- } /* end if */
+ } /* end if */
- /* Create another data space */
- if ((sid = H5Screate_simple(2, dims2, NULL))<0) {
+ /* Create another data space */
+ if ((sid = H5Screate_simple(2, dims2, NULL))<0) {
H5_FAILED();
printf(" Line %d: Can't open dataspace\n",__LINE__);
goto error;
- } /* end if */
+ } /* end if */
- /* Create dcpl with special filter */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) {
+ /* Create dcpl with special filter */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) {
H5_FAILED();
printf(" Line %d: Can't create dcpl\n",__LINE__);
goto error;
- } /* end if */
- if(H5Pset_chunk(dcpl, 2, chunk_dims2)<0) {
+ } /* end if */
+ if(H5Pset_chunk(dcpl, 2, chunk_dims2)<0) {
H5_FAILED();
printf(" Line %d: Can't set chunk sizes\n",__LINE__);
goto error;
- } /* end if */
+ } /* end if */
- /* Set (invalid at dataset creation time) szip parameters */
- szip_pixels_per_block=32;
- if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block)<0) {
+ /* Set (invalid at dataset creation time) szip parameters */
+ szip_pixels_per_block=32;
+ if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block)<0) {
H5_FAILED();
printf(" Line %d: Can't set szip filter\n",__LINE__);
goto error;
- }
+ }
- /* Create new dataset */
- /* (Should fail because the 'can apply' filter should indicate inappropriate combination) */
- H5E_BEGIN_TRY {
+ /* Create new dataset */
+ /* (Should fail because the 'can apply' filter should indicate inappropriate combination) */
+ H5E_BEGIN_TRY {
dsid = H5Dcreate(file, DSET_CAN_APPLY_SZIP_NAME, H5T_NATIVE_INT, sid, dcpl);
- } H5E_END_TRY;
- if (dsid >=0) {
+ } H5E_END_TRY;
+ if (dsid >=0) {
H5_FAILED();
printf(" Line %d: Shouldn't have created dataset!\n",__LINE__);
H5Dclose(dsid);
goto error;
- } /* end if */
+ } /* end if */
- /* Close dataspace */
- if(H5Sclose(sid)<0) {
+ /* Close dataspace */
+ if(H5Sclose(sid)<0) {
H5_FAILED();
printf(" Line %d: Can't close dataspace\n",__LINE__);
goto error;
- } /* end if */
+ } /* end if */
- /* Close dataset creation property list */
- if(H5Pclose(dcpl)<0) {
+ /* Close dataset creation property list */
+ if(H5Pclose(dcpl)<0) {
H5_FAILED();
printf(" Line %d: Can't close dcpl\n",__LINE__);
goto error;
- } /* end if */
-
+ } /* end if */
PASSED();
-#else /* H5_HAVE_FILTER_SZIP and H5_SZIP_CAN_ENCODE */
+} else {
SKIPPED();
- puts(not_supported);
+ puts(" Szip encoding is not enabled.");
+}
+#else /* H5_HAVE_FILTER_SZIP */
+ SKIPPED();
+ puts(" Szip filter is not enabled.");
#endif /* H5_HAVE_FILTER_SZIP */
-
return 0;
#ifdef H5_HAVE_FILTER_SZIP
@@ -2934,6 +2933,7 @@ error:
#endif /* H5_HAVE_FILTER_SZIP */
} /* end test_can_apply_szip() */
+
/* This message derives from H5Z */
const H5Z_class_t H5Z_SET_LOCAL[1] = {{
H5Z_CLASS_T_VERS,
diff --git a/test/h5test.c b/test/h5test.c
index 042c763..5344fe2 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -799,3 +799,50 @@ print_func(const char *format, ...)
return ret_value;
}
+#ifdef H5_HAVE_FILTER_SZIP
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_szip_can_encode
+ *
+ * Purpose: Retrieve the filter config flags for szip, tell if
+ * encoder is available.
+ *
+ * Return: 1: decode+encode is enabled
+ * 0: only decode is enabled
+ * -1: other
+ *
+ * Programmer:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int h5_szip_can_encode(void )
+{
+
+ herr_t status;
+ unsigned int filter_config_flags;
+
+ status =H5Zget_filter_info(H5Z_FILTER_SZIP, &filter_config_flags);
+ if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
+ /* filter present but neither encode nor decode is supported (???) */
+ return -1;
+ } else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ H5Z_FILTER_CONFIG_DECODE_ENABLED) {
+ /* decoder only: read but not write */
+ return 0;
+ } else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
+ /* encoder only: write but not read (???) */
+ return -1;
+ } else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
+ return 1;
+ }
+}
+#endif /* H5_HAVE_FILTER_SZIP */
diff --git a/test/h5test.h b/test/h5test.h
index 886a681..ac73506 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -140,6 +140,10 @@ H5TEST_DLL int TestErrPrintf(const char *format, ...);
H5TEST_DLL void SetTest(const char *testname, int action);
+#ifdef H5_HAVE_FILTER_SZIP
+H5TEST_DLL int h5_szip_can_encode(void);
+#endif /* H5_HAVE_FILTER_SZIP */
+
#ifdef H5_HAVE_PARALLEL
H5TEST_DLL int h5_set_info_object(void);
H5TEST_DLL void h5_dump_info_object(MPI_Info info);
diff --git a/test/tmisc.c b/test/tmisc.c
index 65a0110..3447b82 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -3499,7 +3499,8 @@ test_misc20(void)
and encoder is available.
EIP 2004/8/04
*/
-#if defined H5_HAVE_FILTER_SZIP && defined H5_SZIP_CAN_ENCODE
+#if defined H5_HAVE_FILTER_SZIP
+
/****************************************************************
**
** test_misc21(): Test that late allocation time is treated the same
@@ -3517,6 +3518,7 @@ test_misc21(void)
chunk_size[2]={MISC21_CHUNK_DIM0,MISC21_CHUNK_DIM1};
herr_t ret; /* Generic return value */
+ if (h5_szip_can_encode() != 1) return;
/* Output message about test being performed */
MESSAGE(5, ("Testing late allocation time w/chunks & filters\n"));
@@ -3595,6 +3597,7 @@ test_misc22(void)
unsigned int cd_values[32];
int correct;
+ if (h5_szip_can_encode() != 1) return;
idts[0]=H5Tcopy(H5T_NATIVE_UINT8);
idts[1]=H5Tcopy(H5T_NATIVE_UINT16);
idts[2]=H5Tcopy(H5T_NATIVE_UINT32);
@@ -3708,7 +3711,7 @@ test_misc22(void)
HDfree(buf);
} /* end test_misc22() */
-#endif /* H5_SZIP_CAN_ENCODE & H5_HAVE_FILTER_SZIP */
+#endif /* H5_HAVE_FILTER_SZIP */
/****************************************************************
**
@@ -3741,10 +3744,10 @@ test_misc(void)
test_misc18(); /* Test new object header information in H5G_stat_t struct */
test_misc19(); /* Test incrementing & decrementing ref count on IDs */
test_misc20(); /* Test problems with truncated dimensions in version 2 of storage layout message */
-#if defined H5_HAVE_FILTER_SZIP & defined H5_SZIP_CAN_ENCODE
+#if defined H5_HAVE_FILTER_SZIP
test_misc21(); /* Test that "late" allocation time is treated the same as "incremental", for chunked datasets w/a filters */
test_misc22(); /* check szip bits per pixel */
-#endif /* H5_SZIP_CAN_ENCODE & H5_HAVE_FILTER_SZIP */
+#endif /* H5_HAVE_FILTER_SZIP */
} /* test_misc() */
@@ -3789,8 +3792,9 @@ cleanup_misc(void)
HDremove(MISC18_FILE);
HDremove(MISC19_FILE);
HDremove(MISC20_FILE);
-#if defined H5_HAVE_FILTER_SZIP & defined H5_SZIP_CAN_ENCODE
+#if defined H5_HAVE_FILTER_SZIP
HDremove(MISC21_FILE);
HDremove(MISC22_FILE);
-#endif /* H5_SZIP_CAN_ENCODE & H5_HAVE_FILTER_SZIP */
+#endif /* H5_HAVE_FILTER_SZIP */
}
+