2005-10-11 11:27:47 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2005-10-11 11:27:47 +08:00
|
|
|
* 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 *
|
2007-02-07 22:56:24 +08:00
|
|
|
* 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. *
|
2005-10-11 11:27:47 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
2004-05-04 07:34:42 +08:00
|
|
|
#include "h5test.h"
|
|
|
|
|
|
|
|
#define ROWS 12
|
|
|
|
#define COLS 18
|
2015-03-02 02:48:54 +08:00
|
|
|
#define FLOAT_TOL 0.0001F
|
2004-05-04 07:34:42 +08:00
|
|
|
|
2009-03-11 03:00:39 +08:00
|
|
|
static int init_test(hid_t file_id);
|
|
|
|
static int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy);
|
|
|
|
static int test_trivial(const hid_t dxpl_id_simple);
|
|
|
|
static int test_poly(const hid_t dxpl_id_polynomial);
|
2012-03-16 04:53:14 +08:00
|
|
|
static int test_specials(hid_t file);
|
2009-03-11 03:00:39 +08:00
|
|
|
static int test_set(void);
|
|
|
|
static int test_getset(const hid_t dxpl_id_simple);
|
2004-10-06 06:44:17 +08:00
|
|
|
|
2004-11-12 01:15:33 +08:00
|
|
|
/* These are needed for multiple tests, so are declared here globally and are init'ed in init_test */
|
2010-02-20 10:23:44 +08:00
|
|
|
hid_t dset_id_int = -1;
|
|
|
|
hid_t dset_id_float = -1;
|
|
|
|
hid_t dset_id_int_chunk = -1;
|
|
|
|
hid_t dset_id_float_chunk = -1;
|
2004-11-12 01:15:33 +08:00
|
|
|
|
2004-10-06 06:44:17 +08:00
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
const float windchillFfloat[ROWS][COLS] =
|
2013-08-20 06:13:15 +08:00
|
|
|
{ {36.0f, 31.0f, 25.0f, 19.0f, 13.0f, 7.0f, 1.0f, -5.0f, -11.0f, -16.0f, -22.0f, -28.0f, -34.0f, -40.0f, -46.0f, -52.0f, -57.0f, -63.0f},
|
|
|
|
{34.0f, 27.0f, 21.0f, 15.0f, 9.0f, 3.0f, -4.0f, -10.0f, -16.0f, -22.0f, -28.0f, -35.0f, -41.0f, -47.0f, -53.0f, -59.0f, -66.0f, -72.0f} ,
|
|
|
|
{32.0f, 25.0f, 19.0f, 13.0f, 6.0f, 0.0f, -7.0f, -13.0f, -19.0f, -26.0f, -32.0f, -39.0f, -45.0f, -51.0f, -58.0f, -64.0f, -71.0f, -77.0f},
|
|
|
|
{30.0f, 24.0f, 17.0f, 11.0f, 4.0f, -2.0f, -9.0f, -15.0f, -22.0f, -29.0f, -35.0f, -42.0f, -48.0f, -55.0f, -61.0f, -68.0f, -74.0f, -81.0f},
|
|
|
|
{29.0f, 23.0f, 16.0f, 9.0f, 3.0f, -4.0f, -11.0f, -17.0f, -24.0f, -31.0f, -37.0f, -44.0f, -51.0f, -58.0f, -64.0f, -71.0f, -78.0f, -84.0f},
|
|
|
|
{28.0f, 22.0f, 15.0f, 8.0f, 1.0f, -5.0f, -12.0f, -19.0f, -26.0f, -33.0f, -39.0f, -46.0f, -53.0f, -60.0f, -67.0f, -73.0f, -80.0f, -87.0f},
|
|
|
|
{28.0f, 21.0f, 14.0f, 7.0f, 0.0f, -7.0f, -14.0f, -21.0f, -27.0f, -34.0f, -41.0f, -48.0f, -55.0f, -62.0f, -69.0f, -76.0f, -82.0f, -89.0f},
|
|
|
|
{27.0f, 20.0f, 13.0f, 6.0f, -1.0f, -8.0f, -15.0f, -22.0f, -29.0f, -36.0f, -43.0f, -50.0f, -57.0f, -64.0f, -71.0f, -78.0f, -84.0f, -91.0f},
|
|
|
|
{26.0f, 19.0f, 12.0f, 5.0f, -2.0f, -9.0f, -16.0f, -23.0f, -30.0f, -37.0f, -44.0f, -51.0f, -58.0f, -65.0f, -72.0f, -79.0f, -86.0f, -93.0f},
|
|
|
|
{26.0f, 19.0f, 12.0f, 4.0f, -3.0f, -10.0f, -17.0f, -24.0f, -31.0f, -38.0f, -45.0f, -52.0f, -60.0f, -67.0f, -74.0f, -81.0f, -88.0f, -95.0f},
|
|
|
|
{25.0f, 18.0f, 11.0f, 4.0f, -3.0f, -11.0f, -18.0f, -25.0f, -32.0f, -39.0f, -46.0f, -54.0f, -61.0f, -68.0f, -75.0f, -82.0f, -89.0f, -97.0f},
|
|
|
|
{25.0f, 17.0f, 10.0f, 3.0f, -4.0f, -11.0f, -19.0f, -26.0f, -33.0f, -40.0f, -48.0f, -55.0f, -62.0f, -69.0f, -76.0f, -84.0f, -91.0f, -98.0f}
|
2004-10-06 06:44:17 +08:00
|
|
|
};
|
2004-05-04 07:34:42 +08:00
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
const int transformData[ROWS][COLS] =
|
2004-10-15 03:56:27 +08:00
|
|
|
{ {36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63 },
|
2012-03-16 04:53:14 +08:00
|
|
|
{34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 1 } ,
|
|
|
|
{32, 25, 19, 13, 6, 2, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5 },
|
2009-04-21 00:54:52 +08:00
|
|
|
{30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 2, 9 },
|
|
|
|
{29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 6, 12 },
|
|
|
|
{28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 1, 8, 15 },
|
2012-03-16 04:53:14 +08:00
|
|
|
{28, 21, 14, 7, 6, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17 },
|
2009-04-21 00:54:52 +08:00
|
|
|
{27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 6, 12, 19 },
|
2012-03-16 04:53:14 +08:00
|
|
|
{26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 5, 7, 14, 21 },
|
2009-04-21 00:54:52 +08:00
|
|
|
{26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 2, 9, 16, 23},
|
|
|
|
{25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 3, 10, 17, 25},
|
|
|
|
{25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 4, 12, 19, 26}
|
2004-05-04 07:34:42 +08:00
|
|
|
};
|
2004-10-06 06:44:17 +08:00
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
#define UCOMPARE(TYPE,VAR1,VAR2,TOL) \
|
|
|
|
{ \
|
2004-10-29 11:32:24 +08:00
|
|
|
size_t i,j; \
|
2004-10-27 04:47:22 +08:00
|
|
|
\
|
2004-10-29 11:32:24 +08:00
|
|
|
for(i=0; i<ROWS; i++) \
|
2010-02-20 10:23:44 +08:00
|
|
|
for(j=0; j<COLS; j++) \
|
|
|
|
{ \
|
|
|
|
if(!( (((VAR1)[i][j] >= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] - TOL) < (TYPE)((VAR2)[i][j]))) || ( ((VAR1)[i][j] <= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] + TOL) > (TYPE)((VAR2)[i][j]))))) \
|
|
|
|
{ \
|
|
|
|
H5_FAILED(); \
|
|
|
|
fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
|
|
|
|
goto error; \
|
|
|
|
} \
|
|
|
|
} \
|
2004-10-27 04:47:22 +08:00
|
|
|
PASSED(); \
|
2005-08-14 04:53:35 +08:00
|
|
|
}
|
2004-10-27 04:47:22 +08:00
|
|
|
|
|
|
|
#define COMPARE(TYPE,VAR1,VAR2,TOL) \
|
|
|
|
{ \
|
2004-10-29 11:32:24 +08:00
|
|
|
size_t i,j; \
|
2004-10-27 04:47:22 +08:00
|
|
|
\
|
2004-10-29 11:32:24 +08:00
|
|
|
for(i=0; i<ROWS; i++) \
|
2010-02-20 10:23:44 +08:00
|
|
|
for(j=0; j<COLS; j++) \
|
|
|
|
{ \
|
|
|
|
if( !(((VAR1)[i][j] <= ((TYPE)(VAR2)[i][j] + TOL)) && ((VAR1)[i][j] >= ((TYPE)(VAR2)[i][j] - TOL))) ) \
|
|
|
|
{ \
|
|
|
|
H5_FAILED(); \
|
|
|
|
fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
|
|
|
|
goto error; \
|
|
|
|
} \
|
|
|
|
} \
|
2004-10-27 04:47:22 +08:00
|
|
|
PASSED(); \
|
2005-08-14 04:53:35 +08:00
|
|
|
}
|
2004-10-06 06:44:17 +08:00
|
|
|
|
2012-03-16 04:53:14 +08:00
|
|
|
#define COMPARE_INT(VAR1,VAR2) \
|
|
|
|
{ \
|
|
|
|
size_t i,j; \
|
|
|
|
\
|
|
|
|
for(i=0; i<ROWS; i++) \
|
|
|
|
for(j=0; j<COLS; j++) \
|
|
|
|
{ \
|
|
|
|
if( (VAR1)[i][j] != (VAR2)[i][j] ) \
|
|
|
|
{ \
|
|
|
|
H5_FAILED(); \
|
|
|
|
fprintf(stderr, " ERROR: data failed to match computed data\n"); \
|
|
|
|
goto error; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2004-11-12 01:15:33 +08:00
|
|
|
#define TEST_TYPE_CONTIG(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \
|
2004-11-04 01:28:26 +08:00
|
|
|
{ \
|
|
|
|
TYPE array[ROWS][COLS]; \
|
2004-11-12 01:15:33 +08:00
|
|
|
const char* f_to_c = "(5/9.0)*(x-32)"; \
|
|
|
|
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */ \
|
|
|
|
const char* utrans = "((x+100)/4)*3"; \
|
|
|
|
\
|
2009-04-21 00:54:52 +08:00
|
|
|
hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset, dset_nn, dt_nn; \
|
|
|
|
H5T_order_t order; \
|
2004-11-12 01:15:33 +08:00
|
|
|
hsize_t dim[2] = {ROWS, COLS}; \
|
|
|
|
\
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR; \
|
2009-04-21 00:54:52 +08:00
|
|
|
if((dset = H5Dcreate2(file_id, "/transformtest_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; \
|
|
|
|
\
|
|
|
|
if((dt_nn = H5Tcopy(HDF_TYPE)) < 0) TEST_ERROR \
|
|
|
|
if((order = H5Tget_order(dt_nn)) == H5T_ORDER_ERROR) TEST_ERROR \
|
|
|
|
if(H5Tset_order(dt_nn, order == H5T_ORDER_LE ? H5T_ORDER_BE : H5T_ORDER_LE) < 0) TEST_ERROR \
|
|
|
|
if((dset_nn = H5Dcreate2(file_id, "/nonnative_transformtest_"TEST_STR, dt_nn, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR \
|
|
|
|
if(H5Tclose(dt_nn) < 0) TEST_ERROR \
|
2004-11-12 01:15:33 +08:00
|
|
|
\
|
|
|
|
if(SIGNED) \
|
|
|
|
{ \
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
|
|
|
|
if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR; \
|
|
|
|
if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \
|
2009-04-21 00:54:52 +08:00
|
|
|
if(H5Dwrite(dset_nn, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
|
|
|
|
if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR; \
|
|
|
|
if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \
|
2009-04-21 00:54:52 +08:00
|
|
|
if(H5Dwrite(dset_nn, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
TESTING("contiguous, no data type conversion ("TEST_STR"->"TEST_STR")") \
|
|
|
|
\
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Dread(dset, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \
|
2009-04-21 00:54:52 +08:00
|
|
|
if(SIGNED) \
|
|
|
|
COMPARE(TYPE, array, COMPARE_DATA, 2) \
|
|
|
|
else \
|
|
|
|
UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
|
|
|
|
\
|
|
|
|
TESTING("contiguous, byte order conversion ("TEST_STR"->"TEST_STR")") \
|
|
|
|
\
|
|
|
|
if(H5Dread(dset_nn, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
if(SIGNED) \
|
|
|
|
COMPARE(TYPE, array, COMPARE_DATA, 2) \
|
|
|
|
else \
|
|
|
|
UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
|
2004-11-04 01:28:26 +08:00
|
|
|
\
|
2004-11-12 01:15:33 +08:00
|
|
|
if(SIGNED) \
|
|
|
|
{ \
|
|
|
|
TESTING("contiguous, with type conversion (float->"TEST_STR")") \
|
2004-11-04 01:28:26 +08:00
|
|
|
\
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Dread(dset_id_float, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \
|
2009-04-21 00:54:52 +08:00
|
|
|
COMPARE(TYPE, array, COMPARE_DATA, 2) \
|
2004-11-12 01:15:33 +08:00
|
|
|
} \
|
|
|
|
\
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Dclose(dset) < 0) TEST_ERROR; \
|
|
|
|
if(H5Sclose(dataspace) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define TEST_TYPE_CHUNK(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \
|
|
|
|
{ \
|
|
|
|
TYPE array[ROWS][COLS]; \
|
|
|
|
const char* f_to_c = "(5/9.0)*(x-32)"; \
|
|
|
|
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */ \
|
|
|
|
const char* utrans = "((x+100)/4)*3"; \
|
|
|
|
\
|
|
|
|
hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, memspace, dset_chunk, filespace; \
|
|
|
|
hsize_t dim[2] = {ROWS, COLS}; \
|
2010-02-20 10:23:44 +08:00
|
|
|
hsize_t offset[2] = {0, 0}; \
|
2004-11-12 01:15:33 +08:00
|
|
|
\
|
|
|
|
\
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
\
|
2010-02-20 10:23:44 +08:00
|
|
|
if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; \
|
|
|
|
if(H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
\
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if((dset_chunk = H5Dcreate2(file_id, "/transformtest_chunk_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR; \
|
2010-02-20 10:23:44 +08:00
|
|
|
if((filespace = H5Dget_space(dset_chunk)) < 0) TEST_ERROR \
|
|
|
|
if((memspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR \
|
2004-12-29 22:26:20 +08:00
|
|
|
if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
\
|
|
|
|
if(SIGNED) \
|
|
|
|
{ \
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
|
|
|
|
if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR; \
|
|
|
|
if(H5Dwrite(dset_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
|
|
|
|
if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR; \
|
|
|
|
if(H5Dwrite(dset_chunk, H5T_NATIVE_INT, dataspace, filespace, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
TESTING("chunked, no data type conversion ("TEST_STR"->"TEST_STR")") \
|
|
|
|
\
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Dread(dset_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) TEST_ERROR; \
|
2004-11-12 01:15:33 +08:00
|
|
|
if(SIGNED) \
|
|
|
|
COMPARE(TYPE, array, COMPARE_DATA, 2) \
|
|
|
|
else \
|
|
|
|
UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
|
2004-11-04 01:28:26 +08:00
|
|
|
\
|
|
|
|
if(SIGNED) \
|
|
|
|
{ \
|
2010-02-20 10:23:44 +08:00
|
|
|
TESTING("chunked, with type conversion (float->"TEST_STR")") \
|
2004-11-04 01:28:26 +08:00
|
|
|
\
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) TEST_ERROR; \
|
2010-02-20 10:23:44 +08:00
|
|
|
COMPARE(TYPE, array, COMPARE_DATA, 2) \
|
2004-11-04 01:28:26 +08:00
|
|
|
} \
|
2004-11-12 01:15:33 +08:00
|
|
|
\
|
2010-02-20 10:23:44 +08:00
|
|
|
\
|
|
|
|
if(H5Pclose(cparms) < 0) TEST_ERROR; \
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Dclose(dset_chunk) < 0) TEST_ERROR; \
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Sclose(dataspace) < 0) TEST_ERROR; \
|
|
|
|
if(H5Sclose(memspace) < 0) TEST_ERROR; \
|
2004-11-04 01:28:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define INVALID_SET_TEST(TRANSFORM) \
|
|
|
|
{ \
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Pset_data_transform(dxpl_id, TRANSFORM) < 0) \
|
2004-11-04 01:28:26 +08:00
|
|
|
{ \
|
|
|
|
PASSED(); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
H5_FAILED(); \
|
|
|
|
fprintf(stderr, " ERROR: Data transform allowed invalid TRANSFORM transform to be set\n"); \
|
|
|
|
goto error; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2004-10-06 06:44:17 +08:00
|
|
|
int main(void)
|
|
|
|
{
|
[svn-r18346] Description:
Bring Coverity fixes back from branch to trunk:
r18336:
Fix coverity issues 275, 276, 277, 323, 432, 433, and 434
r18337:
Fix Coverity issue #106: release free space section node on error
r18338:
Fixed Coverity #94 - In H5P_register, new_class wasn't closed when there's an
error after it's created.
r18339:
Fix Coverity #185 - In test_conv_str_1, BUF wasn't freed when there's an error
in this function.
r18340:
Correct error in r18337 that wasn't releasing indirect fractal heap block
early enough.
r18341:
Close nodes if any failed in the middle of allocating new nodes. Coverity 140
and 141
r18342:
Correct [another] problem w/r18337.
r18343:
Fix coverity items 185, 20, and 21.
r18344:
Fix Coverity 213 - In H5FD_family_close, the double pointer file->memb was
dereferenced without NULL checking
(We believe).
r18345:
Fix Coverity issue # 210; removed NULL check after pointer dereferenced in
H5HFdblock.c. Also assigned NULL to pointer in H5Pint.c to fix segmentation
fault.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-02-28 04:08:03 +08:00
|
|
|
hid_t dxpl_id_c_to_f = -1;
|
|
|
|
hid_t dxpl_id_c_to_f_copy = 1;
|
|
|
|
hid_t dxpl_id_simple = -1;
|
|
|
|
hid_t dxpl_id_polynomial = -1;
|
|
|
|
hid_t dxpl_id_polynomial_copy = -1;
|
|
|
|
hid_t dxpl_id_utrans_inv = -1;
|
|
|
|
hid_t file_id = -1;
|
2004-10-06 06:44:17 +08:00
|
|
|
|
2004-10-15 03:56:27 +08:00
|
|
|
const char* c_to_f = "(9/5.0)*x + 32";
|
2005-08-14 04:53:35 +08:00
|
|
|
const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
|
2004-10-15 03:56:27 +08:00
|
|
|
const char* polynomial = "(2+x)* ((x-8)/2)";
|
|
|
|
/* inverses the utrans transform in init_test to get back original array */
|
|
|
|
const char* utrans_inv = "(x/3)*4 - 100";
|
2008-09-16 23:52:51 +08:00
|
|
|
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if((file_id = H5Fcreate("dtransform.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
|
|
|
|
|
|
|
|
if((dxpl_id_c_to_f = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
|
|
|
|
if((dxpl_id_simple = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
|
|
|
|
if((dxpl_id_utrans_inv = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
|
|
|
|
if((dxpl_id_polynomial = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
|
|
|
|
if(H5Pset_data_transform(dxpl_id_c_to_f, c_to_f) < 0) TEST_ERROR;
|
|
|
|
if(H5Pset_data_transform(dxpl_id_polynomial, polynomial) < 0) TEST_ERROR;
|
|
|
|
if(H5Pset_data_transform(dxpl_id_simple, simple) < 0) TEST_ERROR;
|
|
|
|
if(H5Pset_data_transform(dxpl_id_utrans_inv, utrans_inv) < 0) TEST_ERROR;
|
2004-10-15 03:56:27 +08:00
|
|
|
if((dxpl_id_polynomial_copy = H5Pcopy(dxpl_id_polynomial)) < 0) TEST_ERROR;
|
|
|
|
if((dxpl_id_c_to_f_copy = H5Pcopy(dxpl_id_c_to_f)) < 0) TEST_ERROR;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-06 06:44:17 +08:00
|
|
|
/* Run all the tests */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2006-11-08 09:53:31 +08:00
|
|
|
if(init_test(file_id) < 0) TEST_ERROR;
|
2004-12-29 22:26:20 +08:00
|
|
|
if(test_set() < 0) TEST_ERROR;
|
2004-11-12 01:15:33 +08:00
|
|
|
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, char, H5T_NATIVE_CHAR, "char", transformData, 0);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned char, H5T_NATIVE_UCHAR, "uchar", transformData, 0);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_c_to_f, signed char, H5T_NATIVE_SCHAR, "schar", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_c_to_f, short, H5T_NATIVE_SHORT, "short", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned short, H5T_NATIVE_USHORT, "ushort", transformData, 0);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_c_to_f, int, H5T_NATIVE_INT, "int", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned int, H5T_NATIVE_UINT, "uint", transformData, 0);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_c_to_f, long, H5T_NATIVE_LONG, "long", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned long, H5T_NATIVE_ULONG, "ulong", transformData, 0);
|
2009-02-19 04:02:05 +08:00
|
|
|
TEST_TYPE_CONTIG(dxpl_id_c_to_f, long long, H5T_NATIVE_LLONG, "llong", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0);
|
2004-11-12 01:15:33 +08:00
|
|
|
TEST_TYPE_CONTIG(dxpl_id_c_to_f, float, H5T_NATIVE_FLOAT, "float", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CONTIG(dxpl_id_c_to_f, double, H5T_NATIVE_DOUBLE, "double", windchillFfloat, 1);
|
2005-07-23 09:55:12 +08:00
|
|
|
#if H5_SIZEOF_LONG_DOUBLE!=0
|
2004-11-12 01:15:33 +08:00
|
|
|
TEST_TYPE_CONTIG(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1);
|
2005-07-23 09:55:12 +08:00
|
|
|
#endif
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-11-12 01:15:33 +08:00
|
|
|
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, char, H5T_NATIVE_CHAR, "char", transformData, 0);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned char, H5T_NATIVE_UCHAR, "uchar", transformData, 0);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_c_to_f, signed char, H5T_NATIVE_SCHAR, "schar", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_c_to_f, short, H5T_NATIVE_SHORT, "short", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned short, H5T_NATIVE_USHORT, "ushort", transformData, 0);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_c_to_f, int, H5T_NATIVE_INT, "int", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned int, H5T_NATIVE_UINT, "uint", transformData, 0);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_c_to_f, long, H5T_NATIVE_LONG, "long", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned long, H5T_NATIVE_ULONG, "ulong", transformData, 0);
|
2009-02-19 04:02:05 +08:00
|
|
|
TEST_TYPE_CHUNK(dxpl_id_c_to_f, long long, H5T_NATIVE_LLONG, "llong", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0);
|
2004-11-12 01:15:33 +08:00
|
|
|
TEST_TYPE_CHUNK(dxpl_id_c_to_f, float, H5T_NATIVE_FLOAT, "float", windchillFfloat, 1);
|
|
|
|
TEST_TYPE_CHUNK(dxpl_id_c_to_f, double, H5T_NATIVE_DOUBLE, "double", windchillFfloat, 1);
|
2005-07-23 09:55:12 +08:00
|
|
|
#if H5_SIZEOF_LONG_DOUBLE!=0
|
2004-11-12 01:15:33 +08:00
|
|
|
TEST_TYPE_CHUNK(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1);
|
2005-07-23 09:55:12 +08:00
|
|
|
#endif
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2008-09-16 23:52:51 +08:00
|
|
|
if(test_copy(dxpl_id_c_to_f_copy, dxpl_id_polynomial_copy) < 0) TEST_ERROR;
|
2004-12-29 22:26:20 +08:00
|
|
|
if(test_trivial(dxpl_id_simple) < 0) TEST_ERROR;
|
|
|
|
if(test_poly(dxpl_id_polynomial) < 0) TEST_ERROR;
|
|
|
|
if(test_getset(dxpl_id_c_to_f) < 0) TEST_ERROR;
|
2012-03-16 04:53:14 +08:00
|
|
|
if(test_specials(file_id) < 0) TEST_ERROR;
|
2004-07-02 04:02:47 +08:00
|
|
|
|
2004-10-06 06:44:17 +08:00
|
|
|
/* Close the objects we opened/created */
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
if(H5Dclose(dset_id_int) < 0) TEST_ERROR;
|
|
|
|
if(H5Dclose(dset_id_int_chunk) < 0) TEST_ERROR;
|
|
|
|
if(H5Dclose(dset_id_float) < 0) TEST_ERROR;
|
|
|
|
if(H5Dclose(dset_id_float_chunk) < 0) TEST_ERROR;
|
|
|
|
if(H5Fclose(file_id) < 0) TEST_ERROR;
|
|
|
|
if(H5Pclose(dxpl_id_c_to_f) < 0) TEST_ERROR;
|
|
|
|
if(H5Pclose(dxpl_id_c_to_f_copy) < 0) TEST_ERROR;
|
|
|
|
if(H5Pclose(dxpl_id_polynomial) < 0) TEST_ERROR;
|
|
|
|
if(H5Pclose(dxpl_id_polynomial_copy) < 0) TEST_ERROR;
|
|
|
|
if(H5Pclose(dxpl_id_simple) < 0) TEST_ERROR;
|
|
|
|
if(H5Pclose(dxpl_id_utrans_inv) < 0) TEST_ERROR;
|
2004-09-17 02:12:19 +08:00
|
|
|
|
|
|
|
|
2004-10-06 06:44:17 +08:00
|
|
|
return 0;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-06 06:44:17 +08:00
|
|
|
error:
|
2010-02-20 10:23:44 +08:00
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
H5Dclose(dset_id_int);
|
|
|
|
H5Dclose(dset_id_int_chunk);
|
|
|
|
H5Dclose(dset_id_float);
|
|
|
|
H5Dclose(dset_id_float_chunk);
|
|
|
|
H5Fclose(file_id);
|
|
|
|
H5Pclose(dxpl_id_c_to_f);
|
|
|
|
H5Pclose(dxpl_id_c_to_f_copy);
|
|
|
|
H5Pclose(dxpl_id_polynomial);
|
|
|
|
H5Pclose(dxpl_id_polynomial_copy);
|
|
|
|
H5Pclose(dxpl_id_simple);
|
|
|
|
H5Pclose(dxpl_id_utrans_inv);
|
|
|
|
} H5E_END_TRY
|
2004-10-06 06:44:17 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-03-11 03:00:39 +08:00
|
|
|
static int
|
|
|
|
init_test(hid_t file_id)
|
2004-10-06 06:44:17 +08:00
|
|
|
{
|
|
|
|
const char* f_to_c = "(5/9.0)*(x-32)";
|
2004-10-15 03:56:27 +08:00
|
|
|
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */
|
|
|
|
const char* utrans = "((x+100)/4)*3";
|
2004-10-06 06:44:17 +08:00
|
|
|
|
[svn-r18346] Description:
Bring Coverity fixes back from branch to trunk:
r18336:
Fix coverity issues 275, 276, 277, 323, 432, 433, and 434
r18337:
Fix Coverity issue #106: release free space section node on error
r18338:
Fixed Coverity #94 - In H5P_register, new_class wasn't closed when there's an
error after it's created.
r18339:
Fix Coverity #185 - In test_conv_str_1, BUF wasn't freed when there's an error
in this function.
r18340:
Correct error in r18337 that wasn't releasing indirect fractal heap block
early enough.
r18341:
Close nodes if any failed in the middle of allocating new nodes. Coverity 140
and 141
r18342:
Correct [another] problem w/r18337.
r18343:
Fix coverity items 185, 20, and 21.
r18344:
Fix Coverity 213 - In H5FD_family_close, the double pointer file->memb was
dereferenced without NULL checking
(We believe).
r18345:
Fix Coverity issue # 210; removed NULL check after pointer dereferenced in
H5HFdblock.c. Also assigned NULL to pointer in H5Pint.c to fix segmentation
fault.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-02-28 04:08:03 +08:00
|
|
|
hid_t dataspace = -1;
|
|
|
|
hid_t dxpl_id_f_to_c = -1;
|
|
|
|
hid_t dxpl_id_utrans = -1;
|
|
|
|
hid_t cparms = -1;
|
|
|
|
hid_t filespace = -1;
|
2010-02-20 10:23:44 +08:00
|
|
|
hsize_t dim[2] = { ROWS, COLS };
|
|
|
|
hsize_t offset[2] = { 0, 0 };
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0)
|
|
|
|
TEST_ERROR
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0)
|
|
|
|
TEST_ERROR
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-11-12 01:15:33 +08:00
|
|
|
cparms = H5Pcreate(H5P_DATASET_CREATE);
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Pset_chunk(cparms, 2, dim) < 0)
|
|
|
|
TEST_ERROR
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
if((dataspace = H5Screate_simple(2, dim, NULL)) < 0)
|
|
|
|
TEST_ERROR
|
2004-07-02 04:02:47 +08:00
|
|
|
|
2004-11-12 01:15:33 +08:00
|
|
|
TESTING("Intializing test...")
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
if((dset_id_int = H5Dcreate2(file_id, "/default_int", H5T_NATIVE_INT,
|
|
|
|
dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id_f_to_c, windchillFfloat) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
if((dset_id_float = H5Dcreate2(file_id, "/default_float",
|
|
|
|
H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id_f_to_c, windchillFfloat) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
if((dset_id_int_chunk = H5Dcreate2(file_id, "/default_chunk_int",
|
|
|
|
H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
if((filespace = H5Dget_space(dset_id_int_chunk)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace,
|
|
|
|
dxpl_id_f_to_c, windchillFfloat) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
if((dset_id_float_chunk = H5Dcreate2(file_id, "/default_chunk_float",
|
|
|
|
H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace,
|
|
|
|
dxpl_id_f_to_c, windchillFfloat) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
if(H5Pclose(cparms) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Pclose(dxpl_id_f_to_c) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Pclose(dxpl_id_utrans) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Sclose(dataspace) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Sclose(filespace) < 0)
|
|
|
|
TEST_ERROR
|
2004-10-06 06:44:17 +08:00
|
|
|
|
2004-07-02 04:02:47 +08:00
|
|
|
PASSED();
|
2004-05-04 07:34:42 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
H5Pclose(cparms);
|
|
|
|
H5Pclose(dxpl_id_f_to_c);
|
|
|
|
H5Pclose(dxpl_id_utrans);
|
|
|
|
H5Sclose(dataspace);
|
|
|
|
H5Sclose(filespace);
|
|
|
|
} H5E_END_TRY
|
2004-10-06 06:44:17 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
return -1;
|
2004-10-06 06:44:17 +08:00
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2009-03-11 03:00:39 +08:00
|
|
|
static int
|
|
|
|
test_poly(const hid_t dxpl_id_polynomial)
|
2004-10-06 06:44:17 +08:00
|
|
|
{
|
|
|
|
float polyflres[ROWS][COLS];
|
2010-02-20 10:23:44 +08:00
|
|
|
int polyintread[ROWS][COLS];
|
2004-10-06 06:44:17 +08:00
|
|
|
float polyflread[ROWS][COLS];
|
2004-11-12 01:15:33 +08:00
|
|
|
int windchillC;
|
2004-10-06 06:44:17 +08:00
|
|
|
int row, col;
|
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++) {
|
2013-08-20 06:13:15 +08:00
|
|
|
windchillC = (int) ((5.0f / 9.0f) * (windchillFfloat[row][col] - 32));
|
2015-09-16 21:54:23 +08:00
|
|
|
polyflres[row][col] = ((2.0f + (float)windchillC) * (((float)windchillC - 8.0f) / 2.0f));
|
2010-02-20 10:23:44 +08:00
|
|
|
}
|
2004-10-06 06:44:17 +08:00
|
|
|
|
2004-10-15 03:56:27 +08:00
|
|
|
TESTING("data transform, polynomial transform (int->float)")
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id_polynomial, polyflread) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
2013-08-20 06:13:15 +08:00
|
|
|
COMPARE(float, polyflread, polyflres, 2.0f)
|
2004-05-07 06:44:38 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++) {
|
2013-08-20 06:13:15 +08:00
|
|
|
windchillC = (int) ((5.0f / 9.0f) * (windchillFfloat[row][col] - 32));
|
2010-02-20 10:23:44 +08:00
|
|
|
polyflres[row][col] = (float) ((2 + windchillC) * ((windchillC - 8) / 2));
|
|
|
|
}
|
2004-10-15 03:56:27 +08:00
|
|
|
|
2004-11-04 01:28:26 +08:00
|
|
|
TESTING("data transform, polynomial transform (float->int)")
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id_polynomial, polyintread) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
2004-11-04 01:28:26 +08:00
|
|
|
COMPARE(int, polyintread, polyflres, 4)
|
2004-10-15 03:56:27 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
error:
|
|
|
|
return -1;
|
2004-10-15 03:56:27 +08:00
|
|
|
}
|
|
|
|
|
2012-03-16 04:53:14 +08:00
|
|
|
static int
|
|
|
|
test_specials(hid_t file)
|
|
|
|
{
|
|
|
|
hid_t dxpl_id, dset_id, dataspace;
|
|
|
|
hsize_t dim[2] = { ROWS, COLS };
|
|
|
|
int read_buf[ROWS][COLS];
|
|
|
|
int data_res[ROWS][COLS];
|
|
|
|
int row, col;
|
|
|
|
const char* special1 = "x*-100";
|
|
|
|
const char* special2 = "100-x";
|
|
|
|
const char* special3 = "1000/x";
|
|
|
|
const char* special4 = "-x";
|
|
|
|
const char* special5 = "+x";
|
|
|
|
|
|
|
|
TESTING("data transform of some special cases")
|
|
|
|
|
|
|
|
if((dataspace = H5Screate_simple(2, dim, NULL)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
|
|
|
|
|
|
|
|
/*-----------------------------
|
|
|
|
* Operation 1: x*-100
|
|
|
|
*----------------------------*/
|
|
|
|
if(H5Pset_data_transform(dxpl_id, special1) < 0) TEST_ERROR;
|
|
|
|
|
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++)
|
|
|
|
data_res[row][col] = transformData[row][col] * -100;
|
|
|
|
|
|
|
|
if((dset_id = H5Dcreate2(file, "/special1", H5T_NATIVE_INT,
|
|
|
|
dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id, transformData) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
H5P_DEFAULT, read_buf) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
COMPARE_INT(read_buf, data_res)
|
|
|
|
|
|
|
|
if(H5Dclose(dset_id) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
/*-----------------------------
|
|
|
|
* Operation 2: 100-x
|
|
|
|
*----------------------------*/
|
|
|
|
if(H5Pset_data_transform(dxpl_id, special2) < 0) TEST_ERROR;
|
|
|
|
|
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++)
|
|
|
|
data_res[row][col] = 100 - transformData[row][col];
|
|
|
|
|
|
|
|
if((dset_id = H5Dcreate2(file, "/special2", H5T_NATIVE_INT,
|
|
|
|
dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id, transformData) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
H5P_DEFAULT, read_buf) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
COMPARE_INT(read_buf, data_res)
|
|
|
|
|
|
|
|
if(H5Dclose(dset_id) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
/*-----------------------------
|
|
|
|
* Operation 3: 1000/x
|
|
|
|
*----------------------------*/
|
|
|
|
if(H5Pset_data_transform(dxpl_id, special3) < 0) TEST_ERROR;
|
|
|
|
|
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++)
|
|
|
|
data_res[row][col] = 1000 / transformData[row][col];
|
|
|
|
|
|
|
|
if((dset_id = H5Dcreate2(file, "/special3", H5T_NATIVE_INT,
|
|
|
|
dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id, transformData) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
H5P_DEFAULT, read_buf) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
COMPARE_INT(read_buf, data_res)
|
|
|
|
|
|
|
|
if(H5Dclose(dset_id) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
/*-----------------------------
|
|
|
|
* Operation 4: -x
|
|
|
|
*----------------------------*/
|
|
|
|
if(H5Pset_data_transform(dxpl_id, special4) < 0) TEST_ERROR;
|
|
|
|
|
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++)
|
|
|
|
data_res[row][col] = -1 * transformData[row][col];
|
|
|
|
|
|
|
|
if((dset_id = H5Dcreate2(file, "/special4", H5T_NATIVE_INT,
|
|
|
|
dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id, transformData) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
H5P_DEFAULT, read_buf) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
COMPARE_INT(read_buf, data_res)
|
|
|
|
|
|
|
|
if(H5Dclose(dset_id) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
/*-----------------------------
|
|
|
|
* Operation 5: +x
|
|
|
|
*----------------------------*/
|
|
|
|
if(H5Pset_data_transform(dxpl_id, special5) < 0) TEST_ERROR;
|
|
|
|
|
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++)
|
|
|
|
data_res[row][col] = transformData[row][col];
|
|
|
|
|
|
|
|
if((dset_id = H5Dcreate2(file, "/special5", H5T_NATIVE_INT,
|
|
|
|
dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id, transformData) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
H5P_DEFAULT, read_buf) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
COMPARE_INT(read_buf, data_res)
|
|
|
|
|
|
|
|
if(H5Dclose(dset_id) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
|
|
|
|
if(H5Pclose(dxpl_id) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(H5Sclose(dataspace) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
PASSED();
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-03-11 03:00:39 +08:00
|
|
|
static int
|
|
|
|
test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy)
|
2004-10-06 06:44:17 +08:00
|
|
|
{
|
2004-11-12 01:15:33 +08:00
|
|
|
int windchillC;
|
2004-10-15 03:56:27 +08:00
|
|
|
float polyflres[ROWS][COLS];
|
2004-10-06 06:44:17 +08:00
|
|
|
int polyintread[ROWS][COLS];
|
|
|
|
int windchillFintread[ROWS][COLS];
|
|
|
|
int row, col;
|
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++) {
|
2013-08-20 06:13:15 +08:00
|
|
|
windchillC = (int) ((5.0f / 9.0f) * (windchillFfloat[row][col] - 32));
|
2010-02-20 10:23:44 +08:00
|
|
|
polyflres[row][col] = (float) ((2 + windchillC) * ((windchillC - 8) / 2));
|
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-11-12 01:15:33 +08:00
|
|
|
TESTING("data transform, linear transform w/ copied property")
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id_c_to_f_copy, windchillFintread) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
2004-11-12 01:15:33 +08:00
|
|
|
COMPARE(int, windchillFintread, windchillFfloat, 2)
|
2004-09-17 02:12:19 +08:00
|
|
|
|
2004-10-06 06:44:17 +08:00
|
|
|
TESTING("data transform, polynomial transform w/ copied property")
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id_polynomial_copy, polyintread) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
2004-11-12 01:15:33 +08:00
|
|
|
COMPARE(int, polyintread, polyflres, 2)
|
2004-09-17 02:12:19 +08:00
|
|
|
|
2004-10-06 06:44:17 +08:00
|
|
|
return 0;
|
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
error:
|
2004-10-06 06:44:17 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2009-03-11 03:00:39 +08:00
|
|
|
static int
|
|
|
|
test_trivial(const hid_t dxpl_id_simple)
|
2004-10-06 06:44:17 +08:00
|
|
|
{
|
|
|
|
float windchillFfloatread[ROWS][COLS];
|
|
|
|
int windchillFintread[ROWS][COLS];
|
|
|
|
int row, col;
|
2004-10-15 03:56:27 +08:00
|
|
|
|
2004-05-07 06:44:38 +08:00
|
|
|
TESTING("data transform, trivial transform, without type conversion")
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id_simple, windchillFfloatread) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++) {
|
2013-08-20 06:13:15 +08:00
|
|
|
if((windchillFfloatread[row][col] - 4.8f) > FLOAT_TOL)
|
2010-02-20 10:23:44 +08:00
|
|
|
FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
PASSED()
|
2004-05-07 06:44:38 +08:00
|
|
|
|
|
|
|
TESTING("data transform, trivial transform, with type conversion")
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id_simple, windchillFintread) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++) {
|
|
|
|
if(windchillFintread[row][col] != 4)
|
|
|
|
FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n")
|
|
|
|
}
|
|
|
|
|
|
|
|
PASSED()
|
2004-05-07 06:44:38 +08:00
|
|
|
|
2004-10-06 06:44:17 +08:00
|
|
|
return 0;
|
2004-05-04 07:34:42 +08:00
|
|
|
error:
|
2004-10-06 06:44:17 +08:00
|
|
|
return -1;
|
2004-05-04 07:34:42 +08:00
|
|
|
}
|
|
|
|
|
2009-03-11 03:00:39 +08:00
|
|
|
static int
|
|
|
|
test_getset(const hid_t dxpl_id_c_to_f)
|
2004-10-21 05:09:54 +08:00
|
|
|
{
|
2010-02-20 10:23:44 +08:00
|
|
|
int row;
|
|
|
|
int col;
|
|
|
|
float windchillFfloatread[ROWS][COLS];
|
|
|
|
const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
|
|
|
|
const char *c_to_f = "(9/5.0)*x + 32";
|
|
|
|
char *ptrgetTest = NULL;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-21 05:09:54 +08:00
|
|
|
TESTING("H5Pget_data_transform")
|
2010-02-20 10:23:44 +08:00
|
|
|
|
|
|
|
if(NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(simple) + 1)))
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
if(H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f) + 1) < 0)
|
|
|
|
TEST_ERROR
|
2004-10-27 10:12:02 +08:00
|
|
|
if(HDstrcmp(c_to_f, ptrgetTest) != 0)
|
2010-02-20 10:23:44 +08:00
|
|
|
FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n")
|
2004-10-21 05:09:54 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
PASSED()
|
|
|
|
|
|
|
|
HDfree(ptrgetTest);
|
|
|
|
ptrgetTest = NULL;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-11-12 01:15:33 +08:00
|
|
|
TESTING("data transform, read after reseting of transform property")
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Pset_data_transform(dxpl_id_c_to_f, simple) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
|
|
|
|
dxpl_id_c_to_f, windchillFfloatread) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
for(row = 0; row < ROWS; row++)
|
|
|
|
for(col = 0; col < COLS; col++) {
|
2013-08-20 06:13:15 +08:00
|
|
|
if((windchillFfloatread[row][col] - 4.8f) > FLOAT_TOL)
|
2010-02-20 10:23:44 +08:00
|
|
|
FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n")
|
|
|
|
}
|
2004-10-21 05:09:54 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
PASSED()
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-21 05:09:54 +08:00
|
|
|
TESTING("H5Pget_data_transform, after resetting transform property")
|
2010-02-20 10:23:44 +08:00
|
|
|
|
2010-08-26 04:27:07 +08:00
|
|
|
if(NULL == (ptrgetTest = (char *)HDcalloc((size_t)1, HDstrlen(simple) + 1)))
|
2010-02-20 10:23:44 +08:00
|
|
|
TEST_ERROR
|
|
|
|
if(H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(simple) + 1) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if(HDstrcmp(simple, ptrgetTest) != 0)
|
|
|
|
FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n")
|
|
|
|
|
|
|
|
PASSED()
|
|
|
|
|
|
|
|
HDfree(ptrgetTest);
|
|
|
|
ptrgetTest = NULL;
|
2004-10-21 05:09:54 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
2010-02-20 10:23:44 +08:00
|
|
|
if(ptrgetTest)
|
|
|
|
HDfree(ptrgetTest);
|
|
|
|
|
|
|
|
return -1;
|
2004-10-21 05:09:54 +08:00
|
|
|
}
|
|
|
|
|
2009-03-11 03:00:39 +08:00
|
|
|
static int
|
|
|
|
test_set(void)
|
2004-10-27 04:47:22 +08:00
|
|
|
{
|
2010-02-20 10:23:44 +08:00
|
|
|
hid_t dxpl_id = -1;
|
2010-09-28 03:02:48 +08:00
|
|
|
H5E_auto2_t func;
|
2010-02-20 10:23:44 +08:00
|
|
|
const char *str = "(9/5.0)*x + 32";
|
|
|
|
char *ptrgetTest = NULL;
|
|
|
|
|
|
|
|
TESTING("H5Pget_data_transform (get before set)")
|
|
|
|
|
|
|
|
if(NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(str) + 1)))
|
|
|
|
TEST_ERROR
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
|
|
|
|
TEST_ERROR
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
/* Test get before set */
|
2010-09-28 03:02:48 +08:00
|
|
|
H5Eget_auto2(H5E_DEFAULT, &func, NULL);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2010-09-28 03:02:48 +08:00
|
|
|
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
|
2010-02-20 10:23:44 +08:00
|
|
|
|
|
|
|
if(H5Pget_data_transform(dxpl_id, ptrgetTest, HDstrlen(str) + 1) < 0)
|
|
|
|
PASSED()
|
|
|
|
else
|
|
|
|
FAIL_PUTS_ERROR(" ERROR: Data transform get before set succeeded (it shouldn't have)\n");
|
|
|
|
|
|
|
|
HDfree(ptrgetTest);
|
|
|
|
ptrgetTest = NULL;
|
2004-10-21 05:09:54 +08:00
|
|
|
|
2004-11-04 01:28:26 +08:00
|
|
|
TESTING("H5Pset_data_transform (set with NULL transform)");
|
|
|
|
INVALID_SET_TEST(NULL);
|
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
TESTING("H5Pset_data_transform (set with invalid transform 1)")
|
2004-11-04 01:28:26 +08:00
|
|
|
INVALID_SET_TEST("\0");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
TESTING("H5Pset_data_transform (set with invalid transform 2)")
|
2004-11-04 01:28:26 +08:00
|
|
|
INVALID_SET_TEST(" ");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
TESTING("H5Pset_data_transform (set with invalid transform 3)")
|
2004-11-04 01:28:26 +08:00
|
|
|
INVALID_SET_TEST("x+");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
TESTING("H5Pset_data_transform (set with invalid transform 4)")
|
2004-11-04 01:28:26 +08:00
|
|
|
INVALID_SET_TEST("(x+5");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
TESTING("H5Pset_data_transform (set with invalid transform 5)")
|
2004-11-04 01:28:26 +08:00
|
|
|
INVALID_SET_TEST("+");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
TESTING("H5Pset_data_transform (set with invalid transform 6)")
|
2004-11-04 01:28:26 +08:00
|
|
|
INVALID_SET_TEST("(9/5)*x + x**2");
|
2004-10-15 03:56:27 +08:00
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
TESTING("H5Pset_data_transform (set with invalid transform 7)")
|
2004-11-04 01:28:26 +08:00
|
|
|
INVALID_SET_TEST("(9/5)x");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
TESTING("H5Pset_data_transform (set with invalid transform 8)")
|
2004-11-04 01:28:26 +08:00
|
|
|
INVALID_SET_TEST("(9/5)*x + x^2");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2010-09-28 03:02:48 +08:00
|
|
|
H5Eset_auto2(H5E_DEFAULT, func, NULL);
|
2004-05-04 07:34:42 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
if(H5Pclose(dxpl_id) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
|
2004-10-27 04:47:22 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
2010-02-20 10:23:44 +08:00
|
|
|
if(ptrgetTest)
|
|
|
|
HDfree(ptrgetTest);
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
H5Pclose(dxpl_id);
|
|
|
|
} H5E_END_TRY
|
2004-10-27 04:47:22 +08:00
|
|
|
|
2010-02-20 10:23:44 +08:00
|
|
|
return -1;
|
2004-10-27 04:47:22 +08:00
|
|
|
}
|
2010-02-20 10:23:44 +08:00
|
|
|
|