diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-10-24 14:27:37 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-10-24 14:27:37 (GMT) |
commit | f653b779eb0e2280c227302b22af336325b16a76 (patch) | |
tree | 561f29bb3a742027d2994a9a9e87df693cc5d4b5 /hl/test/test_packet.c | |
parent | 1be95fbe104fb52f1361a4fe7b05ec07e72e9855 (diff) | |
download | hdf5-f653b779eb0e2280c227302b22af336325b16a76.zip hdf5-f653b779eb0e2280c227302b22af336325b16a76.tar.gz hdf5-f653b779eb0e2280c227302b22af336325b16a76.tar.bz2 |
Purpose: Fixed Packet Table issues
Description:
- Removed calls to H5Tget_native_type from PT APIs because it is up to the
application, whether it wants the buffer to be read into memory in the
machine’s native architecture. Currently, however, the PT doesn't
allow an application to specify memory datatype. Perhaps, a new API can
be added to provide that capability.
- Added calls to H5Tcopy to H5PTcreate/H5PTcreate_fl/H5PTopen to save a
copy of the application's datatype or the dataset's datatype.
- Added various missing H5Tclose to the packet table tests, and various
error checkings.
Note: leave out changes to test_packet_vlen.c for 1.8 to wait on QAK about
merging the commit ec2fbe0883f9e76df60bcfbebbd4b6f62d5a09e6
[svn-r30158] first.
Platforms tested:
Linux/32 2.6 (jam)
Linux/64 (platypus)
Darwin (osx1010test)
Diffstat (limited to 'hl/test/test_packet.c')
-rw-r--r-- | hl/test/test_packet.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c index 0bd5292..f577947 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -72,8 +72,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 || - !FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) || - !DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) { + !H5_FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) || + !H5_DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) { return FAIL; } return SUCCEED; @@ -95,8 +95,10 @@ make_particle_type(void) return FAIL; /* Insert fields. */ - string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, (size_t)16 ); + if ((string_type = H5Tcopy(H5T_C_S1)) < 0) + return FAIL; + if (H5Tset_size(string_type, (size_t)16) < 0) + return FAIL; if ( H5Tinsert(type_id, "Name", HOFFSET(particle_t, name) , string_type ) < 0 ) return FAIL; @@ -133,8 +135,10 @@ static int create_hl_table(hid_t fid) herr_t status; /* Initialize the field field_type */ - string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, (size_t)16 ); + if ((string_type = H5Tcopy(H5T_C_S1)) < 0) + return FAIL; + if (H5Tset_size(string_type, (size_t)16) < 0) + return FAIL; field_type[0] = string_type; field_type[1] = H5T_NATIVE_INT; field_type[2] = H5T_NATIVE_INT; @@ -152,12 +156,14 @@ static int create_hl_table(hid_t fid) field_names, part_offset, field_type, chunk_size, fill_data, compress, testPart ); -if(status<0) - return FAIL; -else - return SUCCEED; -} + if (H5Tclose(string_type) < 0) + return FAIL; + if(status<0) + return FAIL; + else + return SUCCEED; +} /*------------------------------------------------------------------------- @@ -183,7 +189,8 @@ static int test_create_close(hid_t fid) /* Create the table */ table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1); - H5Tclose(part_t); + if (H5Tclose(part_t) < 0) + goto error; if( H5PTis_valid(table) < 0) goto error; if( H5PTis_varlen(table) != 0) @@ -248,7 +255,7 @@ static int test_append(hid_t fid) { herr_t err; hid_t table; - hsize_t count; + hsize_t count = 0; TESTING("H5PTappend"); @@ -458,7 +465,8 @@ static int test_big_table(hid_t fid) /* Create a new table */ table = H5PTcreate_fl(fid, "Packet Test Dataset2", part_t, (hsize_t)33, -1); - H5Tclose(part_t); + if (H5Tclose(part_t) < 0) + goto error; if( H5PTis_valid(table) < 0) goto error; @@ -536,7 +544,8 @@ static int test_opaque(hid_t fid) /* Create a new table */ table = H5PTcreate_fl(fid, "Packet Test Dataset3", part_t, (hsize_t)100, -1); - H5Tclose(part_t); + if( H5Tclose(part_t) < 0) + goto error; if( H5PTis_valid(table) < 0) goto error; @@ -743,9 +752,9 @@ static int test_rw_nonnative_dt(hid_t fid) /* 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); + ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT); } else { - ptable = H5PTcreate_fl(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, -1); + ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, H5P_DEFAULT); } if(ptable == H5I_INVALID_HID) goto error; @@ -973,7 +982,8 @@ int main(void) status = 1; /* Close the file */ - H5Fclose(fid); + if (H5Fclose(fid) < 0) + status = 1; return status; } |