summaryrefslogtreecommitdiffstats
path: root/hl/test
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2015-03-25 16:21:30 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2015-03-25 16:21:30 (GMT)
commit1361515c5198b0144097701a5c232e48ddd4a865 (patch)
tree1754214e888fba8098e6844bb027800c5a23c3ac /hl/test
parent3898ea081a0bd34b4f30a7aeec88ac1431e9c4a5 (diff)
downloadhdf5-1361515c5198b0144097701a5c232e48ddd4a865.zip
hdf5-1361515c5198b0144097701a5c232e48ddd4a865.tar.gz
hdf5-1361515c5198b0144097701a5c232e48ddd4a865.tar.bz2
[svn-r26576] Merged r26321,r26405,r26417 from the trunk into the branch.
Tested: h5committest
Diffstat (limited to 'hl/test')
-rw-r--r--hl/test/h5hltest.h2
-rw-r--r--hl/test/test_ds.c2
-rw-r--r--hl/test/test_dset_opt.c12
-rw-r--r--hl/test/test_lite.c18
-rw-r--r--hl/test/test_packet.c91
-rw-r--r--hl/test/test_table.c46
6 files changed, 129 insertions, 42 deletions
diff --git a/hl/test/h5hltest.h b/hl/test/h5hltest.h
index 809c4ec..e8292d2 100644
--- a/hl/test/h5hltest.h
+++ b/hl/test/h5hltest.h
@@ -33,7 +33,7 @@
#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);}
#define TESTING3(WHAT) {printf("%-70s", "" WHAT); fflush(stdout);}
-/* Implrements verbose 'assert' with 'goto error' exit */
+/* Implements verbose 'assert' with 'goto error' exit */
#define VERIFY(condition, string) do { if (!(condition)) FAIL_PUTS_ERROR(string) } while(0)
#endif /* _H5HLTEST_H */
diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c
index d071fd5..3d5b728 100644
--- a/hl/test/test_ds.c
+++ b/hl/test/test_ds.c
@@ -3134,7 +3134,7 @@ static int test_simple(void)
if(H5DSget_scale_name(dsid, name_out, (size_t)name_len+1) < 0)
goto out;
- if(HDstrncmp("Latitude set 0",name_out, name_len)!=0)
+ if(HDstrncmp("Latitude set 0",name_out, (size_t)name_len)!=0)
goto out;
if(name_out) {
HDfree(name_out);
diff --git a/hl/test/test_dset_opt.c b/hl/test/test_dset_opt.c
index b0800a0..95ce535 100644
--- a/hl/test/test_dset_opt.c
+++ b/hl/test/test_dset_opt.c
@@ -501,20 +501,20 @@ filter_bogus1(unsigned int flags, size_t UNUSED cd_nelmts,
size_t *buf_size, void **buf)
{
int *int_ptr=(int *)*buf; /* Pointer to the data values */
- ssize_t buf_left=*buf_size; /* Amount of data buffer left to process */
+ ssize_t buf_left=(ssize_t)*buf_size; /* Amount of data buffer left to process */
if(flags & H5Z_FLAG_REVERSE) { /* read */
/* Substract the "add on" value to all the data values */
while(buf_left>0) {
*int_ptr++ -= (int)ADD_ON;
- buf_left -= sizeof(int);
+ buf_left -= (ssize_t)sizeof(int);
} /* end while */
} /* end if */
else { /* write */
/* Add the "add on" value to all the data values */
while(buf_left>0) {
*int_ptr++ += (int)ADD_ON;
- buf_left -= sizeof(int);
+ buf_left -= (ssize_t)sizeof(int);
} /* end while */
} /* end else */
@@ -538,20 +538,20 @@ filter_bogus2(unsigned int flags, size_t UNUSED cd_nelmts,
size_t *buf_size, void **buf)
{
int *int_ptr=(int *)*buf; /* Pointer to the data values */
- ssize_t buf_left=*buf_size; /* Amount of data buffer left to process */
+ ssize_t buf_left=(ssize_t)*buf_size; /* Amount of data buffer left to process */
if(flags & H5Z_FLAG_REVERSE) { /* read */
/* Substract the "add on" value to all the data values */
while(buf_left>0) {
*int_ptr++ /= (int)FACTOR;
- buf_left -= sizeof(int);
+ buf_left -= (ssize_t)sizeof(int);
} /* end while */
} /* end if */
else { /* write */
/* Add the "add on" value to all the data values */
while(buf_left>0) {
*int_ptr++ *= (int)FACTOR;
- buf_left -= sizeof(int);
+ buf_left -= (ssize_t)sizeof(int);
} /* end while */
} /* end else */
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index d94d1ee..fccc85f 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -300,7 +300,7 @@ static int test_dsets( void )
for (i = 0; i < DIM; i++)
{
- if ( data_float_in[i] != data_float_out[i] ) {
+ if(!FLT_ABS_EQUAL(data_float_in[i],data_float_out[i])) {
goto out;
}
}
@@ -311,7 +311,7 @@ static int test_dsets( void )
for (i = 0; i < DIM; i++)
{
- if ( data_float_in[i] != data_float_out[i] ) {
+ if(!FLT_ABS_EQUAL(data_float_in[i],data_float_out[i])) {
goto out;
}
}
@@ -336,7 +336,7 @@ static int test_dsets( void )
for (i = 0; i < DIM; i++)
{
- if ( data_double_in[i] != data_double_out[i] ) {
+ if(!DBL_ABS_EQUAL(data_double_in[i],data_double_out[i])) {
goto out;
}
}
@@ -347,7 +347,7 @@ static int test_dsets( void )
for (i = 0; i < DIM; i++)
{
- if ( data_double_in[i] != data_double_out[i] ) {
+ if(!DBL_ABS_EQUAL(data_double_in[i],data_double_out[i])) {
goto out;
}
}
@@ -959,7 +959,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
for (i = 0; i < 5; i++)
{
- if ( attr_float_in[i] != attr_float_out[i] ) {
+ if(!FLT_ABS_EQUAL(attr_float_in[i],attr_float_out[i])) {
return -1;
}
}
@@ -970,7 +970,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
for (i = 0; i < 5; i++)
{
- if ( attr_float_in[i] != attr_float_out[i] ) {
+ if(!FLT_ABS_EQUAL(attr_float_in[i],attr_float_out[i])) {
return -1;
}
}
@@ -1003,7 +1003,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
for (i = 0; i < 5; i++)
{
- if ( attr_double_in[i] != attr_double_out[i] ) {
+ if(!DBL_ABS_EQUAL(attr_double_in[i],attr_double_out[i])) {
return -1;
}
}
@@ -1014,7 +1014,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
for (i = 0; i < 5; i++)
{
- if ( attr_double_in[i] != attr_double_out[i] ) {
+ if(!DBL_ABS_EQUAL(attr_double_in[i],attr_double_out[i])) {
return -1;
}
}
@@ -1046,7 +1046,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
TESTING("H5LTget_attribute_info");
- if(NULL==(dims_out = (hsize_t*) HDmalloc( sizeof(hsize_t) * rank_out ))) return -1;
+ if(NULL==(dims_out = (hsize_t*) HDmalloc( sizeof(hsize_t) * (size_t)rank_out ))) return -1;
if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, &type_size) < 0 ) {
HDfree( dims_out );
diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c
index a53b96d..256892b 100644
--- a/hl/test/test_packet.c
+++ b/hl/test/test_packet.c
@@ -75,8 +75,8 @@ static int cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf )
if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) ||
rbuf[i].lati != wbuf[j].lati ||
rbuf[i].longi != wbuf[j].longi ||
- rbuf[i].pressure != wbuf[j].pressure ||
- rbuf[i].temperature != wbuf[j].temperature ) {
+ !FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) ||
+ !DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) {
return -1;
}
return 0;
@@ -895,6 +895,92 @@ error:
return -1;
}
+/*-------------------------------------------------------------------------
+ * test_rw_non-native_dt
+ *
+ * test reading and writing packet table using datatypes that are not
+ * native.
+ *
+ *-------------------------------------------------------------------------
+ */
+static int test_rw_nonnative_dt(hid_t fid)
+{
+ hid_t ptable; /* Packet table identifier */
+
+ herr_t err; /* Function return status */
+ hsize_t count; /* Number of records in the table */
+
+ int x; /* Loop variable */
+
+ /* Buffers to hold data */
+ int writeBuffer[5];
+ int readBuffer[5];
+
+ TESTING("reading/writing non-native packet table");
+
+ /* Initialize buffers */
+ for(x=0; x<5; x++) {
+ writeBuffer[x]=x;
+ readBuffer[x] = -1;
+ }
+
+ /* Create a fixed-length packet table within the file */
+ /* This table's "packets" will be simple integers and it will use no compression */
+ if(H5Tget_order(H5T_NATIVE_INT) == H5T_ORDER_LE) {
+ ptable = H5PTcreate_fl(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, -1);
+ } else {
+ ptable = H5PTcreate_fl(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, -1);
+ }
+ if(ptable == H5I_INVALID_HID)
+ goto out;
+
+ /* Write one packet to the packet table */
+ if( (err = H5PTappend(ptable, (hsize_t)1, &(writeBuffer[0]))) < 0 )
+ goto out;
+
+ /* Write several packets to the packet table */
+ if( (err = H5PTappend(ptable, (hsize_t)4, &(writeBuffer[1]))) < 0)
+ goto out;
+
+ if( (err = H5PTclose(ptable)) < 0)
+ goto out;
+
+ /* Open the Packet table */
+ if( (ptable = H5PTopen(fid, "Packet Test Dataset, Non-native")) < 0)
+ goto out;
+
+ /* Get the number of packets in the packet table. This should be five. */
+ if( (err = H5PTget_num_packets(ptable, &count)) < 0)
+ goto out;
+
+ if( (int)count != 5 )
+ goto out;
+
+ /* Initialize packet table's "current record" */
+ if( (err = H5PTcreate_index(ptable)) < 0)
+ goto out;
+
+ /* Iterate through packets, read each one back */
+ for(x=0; x<5; x++) {
+ if( (err = H5PTget_next(ptable, (hsize_t)1, &(readBuffer[x]))) < 0)
+ goto out;
+ if( x != readBuffer[x])
+ goto out;
+ }
+
+ /* Close the packet table */
+ if( (err = H5PTclose(ptable)) < 0)
+ goto out;
+
+ PASSED();
+ return 0;
+
+ out:
+ H5_FAILED();
+ if( H5PTis_valid(ptable) < 0)
+ H5PTclose(ptable);
+ return -1;
+}
/*-------------------------------------------------------------------------
* test_error
@@ -1035,6 +1121,7 @@ static int test_packet_table(hid_t fid)
test_read(fid);
test_get_next(fid);
test_big_table(fid);
+ test_rw_nonnative_dt(fid);
#ifdef VLPT_REMOVED
test_varlen(fid);
#endif /* VLPT_REMOVED */
diff --git a/hl/test/test_table.c b/hl/test/test_table.c
index 4aac9de..0870546 100644
--- a/hl/test/test_table.c
+++ b/hl/test/test_table.c
@@ -175,14 +175,14 @@ static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf )
if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) ||
rbuf[i].lati != wbuf[j].lati ||
rbuf[i].longi != wbuf[j].longi ||
- rbuf[i].pressure != wbuf[j].pressure ||
- rbuf[i].temperature != wbuf[j].temperature )
+ !FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) ||
+ !DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) )
{
HDfprintf(stderr,"read and write buffers have differences\n");
HDfprintf(stderr,"%s %ld %f %f %d\n",
- rbuf[i].name,rbuf[i].longi,rbuf[i].pressure,rbuf[i].temperature,rbuf[i].lati);
+ rbuf[i].name,rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].temperature,rbuf[i].lati);
HDfprintf(stderr,"%s %ld %f %f %d\n",
- wbuf[j].name,wbuf[j].longi,wbuf[j].pressure,wbuf[j].temperature,wbuf[j].lati);
+ wbuf[j].name,wbuf[j].longi,(double)wbuf[j].pressure,wbuf[j].temperature,wbuf[j].lati);
return -1;
}
return 0;
@@ -1147,14 +1147,14 @@ static int test_table(hid_t fid, int do_write)
{
if ( i >= 2 && i <= 4 )
{
- if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati ||
+ if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati ||
rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi ||
- rbuf[i].pressure != pressure_in[i-NRECORDS_ADD+1] )
+ !FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) )
{
HDfprintf(stderr,"%ld %f %d\n",
- rbuf[i].longi,rbuf[i].pressure,rbuf[i].lati);
+ rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].lati);
HDfprintf(stderr,"%ld %f %d\n",
- position_in[i].longi,pressure_in[i],position_in[i].lati);
+ position_in[i].longi,(double)pressure_in[i],position_in[i].lati);
goto out;
}
}
@@ -1209,9 +1209,9 @@ static int test_table(hid_t fid, int do_write)
goto out;
/* Compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS; i++ )
+ for ( i = 0; i < NRECORDS; i++ )
{
- if ( pressure_out[i] != pressure_in[i] ) {
+ if ( !FLT_ABS_EQUAL(pressure_out[i], pressure_in[i]) ) {
goto out;
}
}
@@ -1274,7 +1274,7 @@ static int test_table(hid_t fid, int do_write)
for( i = 0; i < NRECORDS; i++ )
{
if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) ||
- namepre_out[i].pressure != namepre_in[i].pressure ) {
+ !FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) {
goto out;
}
}
@@ -1303,7 +1303,7 @@ static int test_table(hid_t fid, int do_write)
{
hsize_t iistart = start;
if ( ( HDstrcmp( namepre_out[i].name, namepre_in[iistart+i].name ) != 0 ) ||
- namepre_out[i].pressure != namepre_in[iistart+i].pressure ) {
+ !FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart+i].pressure) ) {
goto out;
}
}
@@ -1362,7 +1362,7 @@ static int test_table(hid_t fid, int do_write)
{
if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati ||
rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi ||
- rbuf[i].pressure != pressure_in[i-NRECORDS_ADD+1] )
+ !FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) )
goto out;
}
}
@@ -1415,7 +1415,7 @@ static int test_table(hid_t fid, int do_write)
/* compare the extracted table with the initial values */
for( i = 0; i < NRECORDS; i++ )
{
- if ( pressure_out[i] != pressure_in[i] ) {
+ if ( !FLT_ABS_EQUAL(pressure_out[i], pressure_in[i]) ) {
goto out;
}
}
@@ -1480,10 +1480,10 @@ static int test_table(hid_t fid, int do_write)
/* compare the extracted table with the initial values */
for( i = 0; i < NRECORDS; i++ )
{
- if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) ||
- namepre_out[i].pressure != namepre_in[i].pressure ) {
- goto out;
- }
+ if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) ||
+ !FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) {
+ goto out;
+ }
}
/* reset buffer */
@@ -1511,8 +1511,8 @@ static int test_table(hid_t fid, int do_write)
for( i = 0; i < 3; i++ )
{
int iistart = (int) start;
- if ( ( HDstrcmp( namepre_out[i].name, wbuf[iistart+i].name ) != 0 ) ||
- namepre_out[i].pressure != wbuf[iistart+i].pressure ) {
+ if ( ( HDstrcmp( namepre_out[i].name, wbuf[iistart+(int)i].name ) != 0 ) ||
+ !FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart+(int)i].pressure) ) {
goto out;
}
}
@@ -1555,8 +1555,8 @@ static int test_table(hid_t fid, int do_write)
if ( ( HDstrcmp( rbuf2[i].name, wbuf[i].name ) != 0 ) ||
rbuf2[i].lati != wbuf[i].lati ||
rbuf2[i].longi != wbuf[i].longi ||
- rbuf2[i].pressure != wbuf[i].pressure ||
- rbuf2[i].temperature != wbuf[i].temperature ||
+ !FLT_ABS_EQUAL(rbuf2[i].pressure,wbuf[i].pressure) ||
+ !DBL_ABS_EQUAL(rbuf2[i].temperature,wbuf[i].temperature) ||
rbuf2[i].new_field != buf_new[i] ) {
goto out;
}
@@ -1596,7 +1596,7 @@ static int test_table(hid_t fid, int do_write)
if ( ( HDstrcmp( rbuf3[i].name, wbuf[i].name ) != 0 ) ||
rbuf3[i].lati != wbuf[i].lati ||
rbuf3[i].longi != wbuf[i].longi ||
- rbuf3[i].temperature != wbuf[i].temperature ) {
+ !DBL_ABS_EQUAL(rbuf3[i].temperature,wbuf[i].temperature) ) {
goto out;
}
}