summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-06-06 00:45:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-06-06 00:45:37 (GMT)
commitdd6c8994c01cd31b5230e98838f11e4c229fdb34 (patch)
tree3b30f5bc0090c7d25ab67248422891a6a0e19a8d /test
parent60aebe36b64de110a2a73bc66726e77fba299711 (diff)
downloadhdf5-dd6c8994c01cd31b5230e98838f11e4c229fdb34.zip
hdf5-dd6c8994c01cd31b5230e98838f11e4c229fdb34.tar.gz
hdf5-dd6c8994c01cd31b5230e98838f11e4c229fdb34.tar.bz2
[svn-r30017] Description:
Bring warning cleanusp in r29990, 29993, 29997, 29999, 30004 from revise_chunks branch to trunk. Tested on: MacOSX/64 10.11.5 (amazon) w/serial, parallel & production. (h5committest forthcoming)
Diffstat (limited to 'test')
-rw-r--r--test/cross_read.c324
-rw-r--r--test/gen_cross.c4
-rw-r--r--test/gen_deflate.c112
-rw-r--r--test/gen_file_image.c71
-rw-r--r--test/h5test.c2
-rw-r--r--test/istore.c6
-rw-r--r--test/pool.c2
-rw-r--r--test/tattr.c40
-rw-r--r--test/tconfig.c4
9 files changed, 304 insertions, 261 deletions
diff --git a/test/cross_read.c b/test/cross_read.c
index b2fae89..8df81f0 100644
--- a/test/cross_read.c
+++ b/test/cross_read.c
@@ -64,9 +64,9 @@ const char *FILENAME[] = {
/*-------------------------------------------------------------------------
- * Function: open_dataset
+ * Function: check_data_i
*
- * Purpose: Read and compare the data from a dataset.
+ * Purpose: Read and compare the integer data from a dataset.
*
* Return: Success: 0
* Failure: 1
@@ -74,112 +74,143 @@ const char *FILENAME[] = {
* Programmer: Raymond Lu
* 17 May 2011
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-static int check_data(const char *dsetname, hid_t fid, hbool_t floating_number)
+static int
+check_data_i(const char *dsetname, hid_t fid)
{
- hid_t dataset; /* handles */
- double data_in[NX+1][NY]; /* input buffer */
- double data_out[NX+1][NY]; /* output buffer */
- long long int_data_in[NX+1][NY]; /* input buffer */
- long long int_data_out[NX+1][NY]; /* output buffer */
- int i, j;
- unsigned nerrors = 0;
-
- /*
- * Open the regular dataset.
+ hid_t did = -1; /* dataset ID */
+ long long data_in[NX+1][NY]; /* input buffer */
+ long long data_out[NX+1][NY]; /* output buffer */
+ int i, j; /* iterators */
+ int nerrors = 0; /* # errors in dataset values */
+
+ /* Open the dataset. */
+ if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Initialization. */
+ /* Input (last row is different) */
+ for(i = 0; i < NX; i++)
+ for(j = 0; j < NY; j++)
+ data_in[i][j] = i + j;
+ for(i = 0; i < NY; i++)
+ data_in[NX][i] = -2;
+ /* Output */
+ HDmemset(data_out, 0, (NX+1) * NY * sizeof(long long));
+
+ /* Read data from hyperslab in the file into the hyperslab in
+ * memory and display.
*/
- if((dataset = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0)
- TEST_ERROR;
+ if(H5Dread(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_out) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Check results */
+ for(i = 0; i < (NX + 1); i++)
+ for(j = 0; j < NY; j++)
+ if(data_out[i][j] != data_in[i][j])
+ if(!nerrors++) {
+ H5_FAILED();
+ printf("element [%d][%d] is %lld but should have been %lld\n",
+ (int)i, (int)j, data_out[i][j], data_in[i][j]);
+ } /* end if */
+
+ /* Close/release resources. */
+ if(H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
- /*
- * Data and output buffer initialization.
- */
- for (j = 0; j < NX; j++) {
- for (i = 0; i < NY; i++) {
- data_in[j][i] = ((double)(i + j + 1))/3;
- data_out[j][i] = 0.0F;
-
- int_data_in[j][i] = i + j;
- int_data_out[j][i] = 0;
- }
- }
- for (i = 0; i < NY; i++) {
- data_in[NX][i] = -2.2F;
- data_out[NX][i] = 0.0F;
+ /* Failure */
+ if(nerrors) {
+ printf("total of %d errors out of %d elements\n", nerrors, (int)(NX*NY));
+ return 1;
+ } /* end if */
+
+ PASSED();
+ return 0;
- int_data_in[NX][i] = -2;
- int_data_out[NX][i] = 0;
- }
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ } H5E_END_TRY;
+ return 1;
+} /* end check_data_i() */
- /*
- * Read data from hyperslab in the file into the hyperslab in
+
+/*-------------------------------------------------------------------------
+ * Function: check_data_f
+ *
+ * Purpose: Read and compare the floating-point data from a dataset.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Raymond Lu
+ * 17 May 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+check_data_f(const char *dsetname, hid_t fid)
+{
+ hid_t did = -1; /* dataset ID */
+ double data_in[NX+1][NY]; /* input buffer */
+ double data_out[NX+1][NY]; /* output buffer */
+ int i, j; /* iterators */
+ int nerrors = 0; /* # of errors in dataset values */
+
+ /* Open the dataset. */
+ if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Initialization. */
+ /* Input (last row is different) */
+ for(i = 0; i < NX; i++)
+ for(j = 0; j < NY; j++)
+ data_in[i][j] = ((double)(i + j + 1)) / (double)3.0F;
+ for(i = 0; i < NY; i++)
+ data_in[NX][i] = -2.2F;
+ /* Output */
+ HDmemset(data_out, 0, (NX+1) * NY * sizeof(double));
+
+ /* Read data from hyperslab in the file into the hyperslab in
* memory and display.
*/
- if(floating_number) {
- if(H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- data_out) < 0)
- TEST_ERROR;
-
- /* Check results */
- for (j=0; j<(NX+1); j++) {
- for (i=0; i<NY; i++) {
- if (!H5_DBL_REL_EQUAL(data_out[j][i], data_in[j][i], 0.001F)) {
- if (!nerrors++) {
- H5_FAILED();
- printf("element [%d][%d] is %g but should have been %g\n",
- j, i, data_out[j][i], data_in[j][i]);
- }
- }
- }
- }
- } else {
- if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT,
- int_data_out) < 0)
- TEST_ERROR;
-
- /* Check results */
- for (j=0; j<(NX+1); j++) {
- for (i=0; i<NY; i++) {
- if (int_data_out[j][i] != int_data_in[j][i]) {
- if (!nerrors++) {
- H5_FAILED();
- printf("element [%d][%d] is %d but should have been %d\n",
- j, i, (int)int_data_out[j][i],
- (int)int_data_in[j][i]);
- }
- }
- }
- }
- }
-
- /*
- * Close/release resources.
- */
- if(H5Dclose(dataset) < 0)
- TEST_ERROR
+ if(H5Dread(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_out) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Check results */
+ for(i = 0; i < (NX + 1); i++)
+ for(j = 0; j < NY; j++)
+ if(!H5_DBL_REL_EQUAL(data_out[i][j], data_in[i][j], (double)0.001F))
+ if(!nerrors++) {
+ H5_FAILED();
+ printf("element [%d][%d] is %g but should have been %g\n",
+ (int)i, (int)j, data_out[i][j], data_in[i][j]);
+ } /* end if */
+
+ /* Close/release resources. */
+ if(H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/* Failure */
- if (nerrors) {
- printf("total of %d errors out of %d elements\n", nerrors, NX*NY);
+ if(nerrors) {
+ printf("total of %d errors out of %d elements\n", nerrors, (int)(NX*NY));
return 1;
- }
+ } /* end if */
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
- H5Dclose(dataset);
+ H5Dclose(did);
} H5E_END_TRY;
return 1;
-}
+} /* end check_data_f() */
/*-------------------------------------------------------------------------
- * Function: open_dataset
+ * Function: check_file
*
* Purpose: Handle each dataset from the data file.
*
@@ -189,125 +220,122 @@ error:
* Programmer: Raymond Lu
* 21 January 2011
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-static int open_dataset(char *fname)
+static int
+check_file(char *filename)
{
- const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */
- hid_t file; /* handles */
- unsigned nerrors = 0;
- const char *not_supported= " filter is not enabled.";
+ const char *pathname = H5_get_srcdir_filename(filename); /* Corrected test file name */
+ hid_t fid = -1; /* file ID */
+ int nerrors = 0; /* # of datasets with errors */
+ const char *not_supported= " filter is not enabled."; /* no filter message */
- /*
- * Open the file.
- */
- if((file = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- TEST_ERROR;
+ /* Open the file. */
+ if((fid = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
TESTING("regular dataset of LE DOUBLE");
- nerrors += check_data(DATASETNAME, file, TRUE);
+ nerrors += check_data_f(DATASETNAME, fid);
TESTING("regular dataset of BE DOUBLE");
- nerrors += check_data(DATASETNAME1, file, TRUE);
+ nerrors += check_data_f(DATASETNAME1, fid);
TESTING("dataset of LE FLOAT with scale-offset filter");
- nerrors += check_data(DATASETNAME2, file, TRUE);
+ nerrors += check_data_f(DATASETNAME2, fid);
TESTING("dataset of BE FLOAT with scale-offset filter");
- nerrors += check_data(DATASETNAME3, file, TRUE);
+ nerrors += check_data_f(DATASETNAME3, fid);
TESTING("dataset of LE DOUBLE with scale-offset filter");
- nerrors += check_data(DATASETNAME4, file, TRUE);
+ nerrors += check_data_f(DATASETNAME4, fid);
TESTING("dataset of BE DOUBLE with scale-offset filter");
- nerrors += check_data(DATASETNAME5, file, TRUE);
+ nerrors += check_data_f(DATASETNAME5, fid);
TESTING("dataset of LE CHAR with scale-offset filter");
- nerrors += check_data(DATASETNAME6, file, FALSE);
+ nerrors += check_data_i(DATASETNAME6, fid);
TESTING("dataset of BE CHAR with scale-offset filter");
- nerrors += check_data(DATASETNAME7, file, FALSE);
+ nerrors += check_data_i(DATASETNAME7, fid);
TESTING("dataset of LE SHORT with scale-offset filter");
- nerrors += check_data(DATASETNAME8, file, FALSE);
+ nerrors += check_data_i(DATASETNAME8, fid);
TESTING("dataset of BE SHORT with scale-offset filter");
- nerrors += check_data(DATASETNAME9, file, FALSE);
+ nerrors += check_data_i(DATASETNAME9, fid);
TESTING("dataset of LE INT with scale-offset filter");
- nerrors += check_data(DATASETNAME10, file, FALSE);
+ nerrors += check_data_i(DATASETNAME10, fid);
TESTING("dataset of BE INT with scale-offset filter");
- nerrors += check_data(DATASETNAME11, file, FALSE);
+ nerrors += check_data_i(DATASETNAME11, fid);
TESTING("dataset of LE LONG LONG with scale-offset filter");
- nerrors += check_data(DATASETNAME12, file, FALSE);
+ nerrors += check_data_i(DATASETNAME12, fid);
TESTING("dataset of BE LONG LONG with scale-offset filter");
- nerrors += check_data(DATASETNAME13, file, FALSE);
+ nerrors += check_data_i(DATASETNAME13, fid);
TESTING("dataset of LE FLOAT with Fletcher32 filter");
- nerrors += check_data(DATASETNAME14, file, TRUE);
+ nerrors += check_data_f(DATASETNAME14, fid);
TESTING("dataset of BE FLOAT with Fletcher32 filter");
- nerrors += check_data(DATASETNAME15, file, TRUE);
+ nerrors += check_data_f(DATASETNAME15, fid);
TESTING("dataset of LE FLOAT with Deflate filter");
#ifdef H5_HAVE_FILTER_DEFLATE
- nerrors += check_data(DATASETNAME16, file, TRUE);
+ nerrors += check_data_f(DATASETNAME16, fid);
#else /*H5_HAVE_FILTER_DEFLATE*/
SKIPPED();
- puts(not_supported);
+ HDputs(not_supported);
#endif /*H5_HAVE_FILTER_DEFLATE*/
TESTING("dataset of BE FLOAT with Deflate filter");
#ifdef H5_HAVE_FILTER_DEFLATE
- nerrors += check_data(DATASETNAME17, file, TRUE);
+ nerrors += check_data_f(DATASETNAME17, fid);
#else /*H5_HAVE_FILTER_DEFLATE*/
SKIPPED();
- puts(not_supported);
+ HDputs(not_supported);
#endif /*H5_HAVE_FILTER_DEFLATE*/
TESTING("dataset of LE FLOAT with Szip filter");
#ifdef H5_HAVE_FILTER_SZIP
- nerrors += check_data(DATASETNAME18, file, TRUE);
+ nerrors += check_data_f(DATASETNAME18, fid);
#else /*H5_HAVE_FILTER_SZIP*/
SKIPPED();
- puts(not_supported);
+ HDputs(not_supported);
#endif /*H5_HAVE_FILTER_SZIP*/
TESTING("dataset of BE FLOAT with Szip filter");
#ifdef H5_HAVE_FILTER_SZIP
- nerrors += check_data(DATASETNAME19, file, TRUE);
+ nerrors += check_data_f(DATASETNAME19, fid);
#else /*H5_HAVE_FILTER_SZIP*/
SKIPPED();
- puts(not_supported);
+ HDputs(not_supported);
#endif /*H5_HAVE_FILTER_SZIP*/
TESTING("dataset of LE FLOAT with Shuffle filter");
- nerrors += check_data(DATASETNAME20, file, TRUE);
+ nerrors += check_data_f(DATASETNAME20, fid);
TESTING("dataset of BE FLOAT with Shuffle filter");
- nerrors += check_data(DATASETNAME21, file, TRUE);
+ nerrors += check_data_f(DATASETNAME21, fid);
TESTING("dataset of LE FLOAT with Nbit filter");
- nerrors += check_data(DATASETNAME22, file, TRUE);
+ nerrors += check_data_f(DATASETNAME22, fid);
TESTING("dataset of BE FLOAT with Nbit filter");
- nerrors += check_data(DATASETNAME23, file, TRUE);
+ nerrors += check_data_f(DATASETNAME23, fid);
- if(H5Fclose(file))
- TEST_ERROR
- return 0;
+ if(H5Fclose(fid))
+ FAIL_STACK_ERROR
+ return nerrors;
error:
H5E_BEGIN_TRY {
- H5Fclose(file);
+ H5Fclose(fid);
} H5E_END_TRY;
return nerrors;
-}
+} /* end check_file() */
/*-------------------------------------------------------------------------
@@ -315,35 +343,37 @@ error:
*
* Purpose: Tests reading files created on LE and BE systems.
*
- * Return: Success: exit(0)
- * Failure: exit(1)
+ * Return: EXIT_SUCCESS/EXIT_FAILURE
*
* Programmer: Raymond Lu
* Thursday, March 23, 2006
*
*-------------------------------------------------------------------------
*/
-int main(void)
+int
+main(void)
{
char filename[1024];
- unsigned nerrors = 0;
+ int nerrors = 0;
h5_reset();
- puts("Testing reading data created on Linux");
- h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof filename);
- nerrors += open_dataset(filename);
+ HDputs("\n");
+ HDputs("Testing reading data created on Linux");
+ h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename));
+ nerrors += check_file(filename);
- puts("Testing reading data created on Solaris");
- h5_fixname(FILENAME[2], H5P_DEFAULT, filename, sizeof filename);
- nerrors += open_dataset(filename);
+ HDputs("\n");
+ HDputs("Testing reading data created on Solaris");
+ h5_fixname(FILENAME[2], H5P_DEFAULT, filename, sizeof(filename));
+ nerrors += check_file(filename);
- if (nerrors) {
- printf("***** %u FAILURE%s! *****\n",
- nerrors, 1==nerrors?"":"S");
- HDexit(1);
- }
+ if(nerrors) {
+ printf("***** %d FAILURE%s! *****\n", nerrors, 1 == nerrors ? "" : "S");
+ return EXIT_FAILURE;
+ } /* end if */
printf("All data type tests passed.\n");
- return 0;
-}
+ return EXIT_SUCCESS;
+} /* end main() */
+
diff --git a/test/gen_cross.c b/test/gen_cross.c
index 816064d..d7c424a 100644
--- a/test/gen_cross.c
+++ b/test/gen_cross.c
@@ -401,7 +401,7 @@ create_scale_offset_dsets_char(hid_t fid, hid_t fsid, hid_t msid)
*/
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
- data[j][i] = i + j;
+ data[j][i] = (char)(i + j);
}
/*
* 0 1 2 3 4 5
@@ -500,7 +500,7 @@ create_scale_offset_dsets_short(hid_t fid, hid_t fsid, hid_t msid)
*/
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
- data[j][i] = i + j;
+ data[j][i] = (short)(i + j);
}
/*
* 0 1 2 3 4 5
diff --git a/test/gen_deflate.c b/test/gen_deflate.c
index 2d0b746..3a9370d 100644
--- a/test/gen_deflate.c
+++ b/test/gen_deflate.c
@@ -14,16 +14,18 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Programmer: Quincey Koziol
* Thursday, November 14, 2002
*
- * Purpose: Create a dataset compressed with the deflate filter.
- * This program is used to create the test file `tdeflate.h5' which has
- * a dataset compressed with the "deflate" I/O filter. This dataset will
- * be used to verify the correct behavior of the library when a filter is
- * not available for a dataset which requires it.
+ * Purpose: Create a dataset compressed with the deflate filter.
+ * This program is used to create the test file `tdeflate.h5'
+ * which has a dataset compressed with the "deflate" I/O filter.
+ * This dataset will be used to verify the correct behavior of
+ * the library when a filter is not available for a dataset which
+ * requires it.
*/
-#include "hdf5.h"
+
+#include "h5test.h"
#define TESTFILE "deflate.h5"
@@ -34,80 +36,86 @@
#define CHUNK_DIM1 50
#define CHUNK_DIM2 50
-/* Dataset data */
-int data[SPACE_DIM1][SPACE_DIM2];
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose:
- *
- * Return: Success:
- *
- * Failure:
+ * Return: EXIT_SUCCESS/EXIT_FAILURE
*
* Programmer: Quincey Koziol
* Thursday, November 14, 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
main(void)
{
- hid_t file, space, dset, dcpl;
- hsize_t dims[SPACE_RANK]={SPACE_DIM1,SPACE_DIM2};
- hsize_t chunk_dims[SPACE_RANK]={CHUNK_DIM1,CHUNK_DIM2};
- size_t i,j; /* Local index variables */
+ hid_t fid = -1, sid = -1, did = -1, dcpl_id = -1;
+ hsize_t dims[SPACE_RANK] = {SPACE_DIM1, SPACE_DIM2};
+ hsize_t chunk_dims[SPACE_RANK] = {CHUNK_DIM1, CHUNK_DIM2};
+ size_t i,j; /* Local index variables */
+ int *data = NULL; /* Dataset data */
/* Initialize the data */
/* (Try for something easily compressible) */
- for(i=0; i<SPACE_DIM1; i++)
- for(j=0; j<SPACE_DIM2; j++)
- data[i][j] = (int)(j % 5);
+ if(NULL == (data = (int *)HDmalloc(SPACE_DIM1 * SPACE_DIM2 * sizeof(int))))
+ TEST_ERROR
+
+ for(i = 0; i < SPACE_DIM1; i++)
+ for(j = 0; j < SPACE_DIM2; j++)
+ data[(i * SPACE_DIM2) + j] = (int)(j % 5);
/* Create the file */
- file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if(file<0)
- printf("file<0!\n");
+ if((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Create the dataspace */
- space = H5Screate_simple(SPACE_RANK, dims, NULL);
- if(space<0)
- printf("space<0!\n");
+ if((sid = H5Screate_simple(SPACE_RANK, dims, NULL)) < 0)
+ FAIL_STACK_ERROR
/* Create the dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- if(dcpl<0)
- printf("dcpl<0!\n");
+ if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
/* Set up for deflated data */
- if(H5Pset_chunk(dcpl, 2, chunk_dims)<0)
- printf("H5Pset_chunk() failed!\n");
- if(H5Pset_deflate(dcpl, 9)<0)
- printf("H5Pset_deflate() failed!\n");
+ if(H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_deflate(dcpl_id, 9) < 0)
+ FAIL_STACK_ERROR
/* Create the compressed dataset */
- dset = H5Dcreate2(file, "Dataset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- if(dset<0)
- printf("dset<0!\n");
+ if((did = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Write the data to the dataset */
- if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data)<0)
- printf("H5Dwrite() failed!\n");
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ FAIL_STACK_ERROR
/* Close everything */
- if(H5Pclose(dcpl)<0)
- printf("H5Pclose() failed!\n");
- if(H5Dclose(dset)<0)
- printf("H5Dclose() failed!\n");
- if(H5Sclose(space)<0)
- printf("H5Sclose() failed!\n");
- if(H5Fclose(file)<0)
- printf("H5Fclose() failed!\n");
-
- return 0;
-}
+ if(H5Pclose(dcpl_id) < 0)
+ FAIL_STACK_ERROR
+ if(H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
+ if(H5Sclose(sid) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ HDfree(data);
+
+ return EXIT_SUCCESS;
+
+error:
+ if(data)
+ HDfree(data);
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl_id);
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+
+ return EXIT_FAILURE;
+} /* end main() */
diff --git a/test/gen_file_image.c b/test/gen_file_image.c
index bc9de29..0637473 100644
--- a/test/gen_file_image.c
+++ b/test/gen_file_image.c
@@ -14,13 +14,13 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Programmer: Quincey Koziol
* Friday, March 30, 2012
*
- * Purpose: Create a simple file for use with the file image tests.
+ * Purpose: Create a simple file for use with the file image tests.
*
*/
-#include "hdf5.h"
+#include "h5test.h"
#define TESTFILE "file_image_core_test.h5"
@@ -29,18 +29,11 @@
#define SPACE_DIM1 128
#define SPACE_DIM2 32
-/* Dataset data */
-int data[SPACE_DIM1][SPACE_DIM2];
-
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose:
- *
- * Return: Success:
- *
- * Failure:
+ * Return: EXIT_SUCCESS/EXIT_FAILURE
*
* Programmer: Quincey Koziol
* Friday, March 30, 2012
@@ -50,42 +43,54 @@ int data[SPACE_DIM1][SPACE_DIM2];
int
main(void)
{
- hid_t file, space, dset;
+ hid_t fid = -1, sid = -1, did = -1;
hsize_t dims[SPACE_RANK] = {SPACE_DIM1, SPACE_DIM2};
- size_t i, j; /* Local index variables */
+ size_t i,j; /* Local index variables */
+ int *data = NULL; /* Dataset data */
/* Initialize the data */
+ if(NULL == (data = (int *)HDmalloc(SPACE_DIM1 * SPACE_DIM2 * sizeof(int))))
+ TEST_ERROR
+
for(i = 0; i < SPACE_DIM1; i++)
for(j = 0; j < SPACE_DIM2; j++)
- data[i][j] = (int)(j % 5);
+ data[(i * SPACE_DIM2) + j] = (int)(j % 5);
/* Create the file */
- file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if(file < 0)
- printf("file < 0!\n");
+ if((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Create the dataspace */
- space = H5Screate_simple(SPACE_RANK, dims, NULL);
- if(space < 0)
- printf("space < 0!\n");
+ if((sid = H5Screate_simple(SPACE_RANK, dims, NULL)) < 0)
+ FAIL_STACK_ERROR
/* Create the compressed dataset */
- dset = H5Dcreate2(file, "Dataset1", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if(dset < 0)
- printf("dset < 0!\n");
+ if((did = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Write the data to the dataset */
- if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
- printf("H5Dwrite() failed!\n");
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ FAIL_STACK_ERROR
/* Close everything */
- if(H5Dclose(dset) < 0)
- printf("H5Dclose() failed!\n");
- if(H5Sclose(space) < 0)
- printf("H5Sclose() failed!\n");
- if(H5Fclose(file) < 0)
- printf("H5Fclose() failed!\n");
+ if(H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
+ if(H5Sclose(sid) < 0)
+ FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
+
+ return EXIT_SUCCESS;
+
+error:
+ if(data)
+ HDfree(data);
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
- return 0;
-}
+ return EXIT_FAILURE;
+} /* end main() */
diff --git a/test/h5test.c b/test/h5test.c
index 8181ff9..39731a2 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -836,7 +836,7 @@ h5_fileaccess(void)
/* In-memory driver with write tracking and paging on */
if (H5Pset_fapl_core(fapl, (size_t)1, TRUE)<0) return -1;
if (H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096)<0) return -1;
- } else if (!HDstrcmp(name, "split")) {
+ } else if (!HDstrcmp(name, "split")) {
/* Split meta data and raw data each using default driver */
if (H5Pset_fapl_split(fapl,
"-m.h5", H5P_DEFAULT,
diff --git a/test/istore.c b/test/istore.c
index ec7542a..68668d8 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -529,9 +529,9 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks,
if((mspace=H5Screate_simple(ndims,size,NULL)) < 0) TEST_ERROR;
for (ctr=0; ctr<nblocks; ctr++) {
- offset[0] = (hsize_t)(HDrandom() % (TEST_SPARSE_SIZE-nx));
- offset[1] = (hsize_t)(HDrandom() % (TEST_SPARSE_SIZE-ny));
- offset[2] = (hsize_t)(HDrandom() % (TEST_SPARSE_SIZE-nz));
+ offset[0] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE-nx));
+ offset[1] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE-ny));
+ offset[2] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE-nz));
/* Select region in file dataspace */
if(H5Sselect_hyperslab(fspace,H5S_SELECT_SET,offset,NULL,size,NULL) < 0) TEST_ERROR;
diff --git a/test/pool.c b/test/pool.c
index 83c862b..7d80096 100644
--- a/test/pool.c
+++ b/test/pool.c
@@ -671,7 +671,7 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
/* Shuffle pointers to free */
for(u = 0; u < MPOOL_NUM_RANDOM; u++) {
- swap_idx = (size_t)(HDrandom() % (MPOOL_NUM_RANDOM - u)) + u;
+ swap_idx = (size_t)(HDrandom() % (int)(MPOOL_NUM_RANDOM - u)) + u;
swap_ptr = spc[u];
spc[u] = spc[swap_idx];
spc[swap_idx] = swap_ptr;
diff --git a/test/tattr.c b/test/tattr.c
index 585246a..e7b3ece 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -146,7 +146,7 @@ typedef struct {
unsigned ncalled; /* # of times callback is entered */
unsigned nskipped; /* # of attributes skipped */
int stop; /* # of iterations to stop after */
- int64_t curr; /* Current creation order value */
+ hsize_t curr; /* Current creation order value */
size_t max_visit; /* Size of "visited attribute" flag array */
hbool_t *visited; /* Pointer to array of "visited attribute" flags */
} attr_iter_info_t;
@@ -522,7 +522,7 @@ test_attr_flush(hid_t fapl)
ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
CHECK(ret, FAIL, "H5Awrite");
- if(!H5_DBL_ABS_EQUAL(rdata,0.0F))
+ if(!H5_DBL_ABS_EQUAL(rdata, H5_DOUBLE(0.0)))
TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,(double)0.0F);
ret=H5Fflush(fil, H5F_SCOPE_GLOBAL);
@@ -531,7 +531,7 @@ test_attr_flush(hid_t fapl)
ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
CHECK(ret, FAIL, "H5Awrite");
- if(!H5_DBL_ABS_EQUAL(rdata,0.0F))
+ if(!H5_DBL_ABS_EQUAL(rdata, H5_DOUBLE(0.0)))
TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,(double)0.0F);
ret=H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata);
@@ -780,7 +780,7 @@ test_attr_compound_read(hid_t fapl)
size_t offset; /* Attribute datatype field offset */
hid_t field; /* Attribute field datatype */
struct attr4_struct read_data4[ATTR4_DIM1][ATTR4_DIM2]; /* Buffer for reading 4th attribute */
- size_t name_len; /* Length of attribute name */
+ ssize_t name_len; /* Length of attribute name */
H5O_info_t oinfo; /* Object info */
int i, j; /* Local index variables */
herr_t ret; /* Generic return value */
@@ -1187,7 +1187,7 @@ test_attr_mult_read(hid_t fapl)
int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */
int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */
double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {{{0}}}; /* Buffer for reading 3rd attribute */
- size_t name_len; /* Length of attribute name */
+ ssize_t name_len; /* Length of attribute name */
H5O_info_t oinfo; /* Object info */
int i, j, k; /* Local index values */
herr_t ret; /* Generic return value */
@@ -1510,7 +1510,7 @@ test_attr_delete(hid_t fapl)
hid_t dataset; /* Dataset ID */
hid_t attr; /* Attribute ID */
char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */
- size_t name_len; /* Length of attribute name */
+ ssize_t name_len; /* Length of attribute name */
H5O_info_t oinfo; /* Object info */
herr_t ret; /* Generic return value */
@@ -2078,7 +2078,7 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr)
/* Re-open all the attributes by index and verify the data */
for(u = 0; u < max_attr; u++) {
- size_t name_len; /* Length of attribute name */
+ ssize_t name_len; /* Length of attribute name */
char check_name[ATTR_NAME_LEN]; /* Buffer for checking attribute names */
/* Open attribute */
@@ -5560,7 +5560,7 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing creation order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
if(HDstrcmp(attrname, tmpname))
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
@@ -5585,7 +5585,7 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing native order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
if(HDstrcmp(attrname, tmpname))
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
@@ -5606,7 +5606,7 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing creation order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
if(HDstrcmp(attrname, tmpname))
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
@@ -5626,7 +5626,7 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing name order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
if(HDstrcmp(attrname, tmpname))
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
@@ -5651,7 +5651,7 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing name order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
if(HDstrcmp(attrname, tmpname))
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
@@ -5760,7 +5760,7 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Check for query on non-existant attribute */
ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &ainfo, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
- ret = H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_name_by_idx");
/* Create attributes, up to limit of compact form */
@@ -5797,7 +5797,7 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
- ret = H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_name_by_idx");
/* Create more attributes, to push into dense form */
@@ -5847,7 +5847,7 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
- ret = H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_name_by_idx");
} /* end for */
@@ -6074,7 +6074,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Verify the name for first attribute in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
if(order == H5_ITER_INC)
sprintf(attrname, "attr %02u", (u + 1));
else
@@ -6199,7 +6199,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Verify the name for first attribute in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
if(order == H5_ITER_INC)
sprintf(attrname, "attr %02u", (u + 1));
else
@@ -6310,7 +6310,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Verify the name for first attribute in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
if(order == H5_ITER_INC)
sprintf(attrname, "attr %02u", ((u * 2) + 1));
else
@@ -6359,7 +6359,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Verify the name for first attribute in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
if(order == H5_ITER_INC)
sprintf(attrname, "attr %02u", ((u * 2) + 3));
else
@@ -9864,7 +9864,7 @@ test_attr_bug3(hid_t fcpl, hid_t fapl)
wdata1[u][v] = (int)((u * dims1[1]) + v);
for(u = 0; u < dims2[0]; u++)
for(v = 0; v < dims2[1]; v++)
- wdata2[u][v] = (int)((u * dims2[1]) + v);
+ wdata2[u][v] = (unsigned)((u * dims2[1]) + v);
/* Write data to the attributes */
ret = H5Awrite(aid1, H5T_NATIVE_INT, wdata1);
diff --git a/test/tconfig.c b/test/tconfig.c
index 6c1321a..3ae26c2 100644
--- a/test/tconfig.c
+++ b/test/tconfig.c
@@ -42,8 +42,8 @@
/* Needs this extra step so that we can print the macro name. */
#define vrfy_macrosize(type, macro, macroname) \
if (sizeof(type) != macro) \
- TestErrPrintf("Error: sizeof(%s) is %d but %s is %d\n", \
- #type, (int)sizeof(type), macroname, (int)macro);
+ TestErrPrintf("Error: sizeof(%s) is %zu but %s is %d\n", \
+ #type, sizeof(type), macroname, (int)macro);
/* local routine prototypes */
void test_config_ctypes(void);