From 2048e0bff92e65442c454d7bd103d15a1a298325 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Thu, 26 Feb 2015 15:39:51 -0500 Subject: [svn-r26321] Fix for HDFFV-9042. tested: h5commit --- hl/src/H5PT.c | 3 ++ hl/test/test_packet.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index 7a0bc20..6ed1ac0 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -130,6 +130,9 @@ hid_t H5PTcreate_fl ( hid_t loc_id, if((table->type_id = H5Tcopy(dtype_id)) < 0) goto out; + if((table->type_id = H5Tget_native_type(table->type_id, H5T_DIR_DEFAULT)) < 0) + goto out; + H5PT_create_index(table); table->size = 0; diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c index 9d3074d..c7a1c27 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -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 */ -- cgit v0.12