diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2019-08-15 21:46:00 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2019-08-15 21:46:15 (GMT) |
commit | 64e6665b5442fc3f46cc7e2b00fe0a1b59f03b22 (patch) | |
tree | 138fc73e4863a87dee28574d4d827b2f5a403d84 /hl | |
parent | 3a504899eef1a66031c6f52623c24bb4e51ca51e (diff) | |
download | hdf5-64e6665b5442fc3f46cc7e2b00fe0a1b59f03b22.zip hdf5-64e6665b5442fc3f46cc7e2b00fe0a1b59f03b22.tar.gz hdf5-64e6665b5442fc3f46cc7e2b00fe0a1b59f03b22.tar.bz2 |
Add HD prefix to tests
Diffstat (limited to 'hl')
-rw-r--r-- | hl/c++/test/ptableTest.cpp | 122 | ||||
-rw-r--r-- | hl/c++/test/ptableTest.h | 2 | ||||
-rw-r--r-- | hl/test/h5hltest.h | 4 | ||||
-rw-r--r-- | hl/test/test_table.c | 110 |
4 files changed, 118 insertions, 120 deletions
diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp index 340912e..f41dbb3 100644 --- a/hl/c++/test/ptableTest.cpp +++ b/hl/c++/test/ptableTest.cpp @@ -31,33 +31,33 @@ int main(void) fileID = H5Fcreate(TEST_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if(fileID <0) { - fprintf(stderr, "Couldn't create file.\n"); + HDfprintf(stderr, "Couldn't create file.\n"); num_errors = 1; } else { - num_errors += BasicTest(); + num_errors += BasicTest(); - num_errors += TestCompoundDatatype(); + num_errors += TestCompoundDatatype(); - num_errors += TestGetPacket(); + num_errors += TestGetPacket(); - num_errors += TestGetNext(); + num_errors += TestGetNext(); - num_errors += TestCompress(); + num_errors += TestCompress(); - num_errors += TestErrors(); + num_errors += TestErrors(); - num_errors += SystemTest(); + num_errors += SystemTest(); - /* Test data corruption in packed structs */ - num_errors += TestHDFFV_9758(); + /* Test data corruption in packed structs */ + num_errors += TestHDFFV_9758(); /* Terminate access to the file. */ err = H5Fclose(fileID); if( err < 0 ) { - fprintf(stderr, "Failed to close file.\n"); + HDfprintf(stderr, "Failed to close file.\n"); num_errors++; } @@ -81,7 +81,7 @@ int BasicTest() hsize_t count; int error; - TESTING("basic functionality") + TESTING2("basic functionality") FL_PacketTable wrapper(fileID, H5P_DEFAULT, BASICTEST_PT, H5T_NATIVE_INT, 1); if(! wrapper.IsValid()) @@ -137,7 +137,7 @@ int TestCompoundDatatype() hsize_t count; int error; - TESTING("compound datatypes") + TESTING2("compound datatypes") /* Create compound datatype */ typedef struct compoundType @@ -206,7 +206,7 @@ int TestGetNext() int records[2]; int i; - TESTING("GetNextPacket") + TESTING2("GetNextPacket") /* Create a dataset */ FL_PacketTable wrapper(fileID, H5P_DEFAULT, GETNEXT_PT, H5T_NATIVE_INT, 500); @@ -268,20 +268,20 @@ int TestCompress() unsigned int config = 0; size_t cd_nelemts = 0; - TESTING("compression") + TESTING2("compression") #ifdef H5_HAVE_FILTER_DEFLATE try { - /* Prepare property list to set compression, randomly use deflate */ - DSetCreatPropList dscreatplist; - dscreatplist.setDeflate(6); + /* Prepare property list to set compression, randomly use deflate */ + DSetCreatPropList dscreatplist; + dscreatplist.setDeflate(6); /* Create packet table with compression. */ FL_PacketTable wrapper(fileID, COMPRESS_PT, H5T_NATIVE_CHAR, 100, dscreatplist.getId()); - /* Close the property list */ - dscreatplist.close(); + /* Close the property list */ + dscreatplist.close(); - /* Verify that the deflate filter is set */ + /* Verify that the deflate filter is set */ /* Create an HDF5 C++ file object */ H5File file; @@ -293,10 +293,10 @@ int TestCompress() DSetCreatPropList dcpl = dset.getCreatePlist(); - char filter_name[8]; + char filter_name[8]; dcpl.getFilterById(H5Z_FILTER_DEFLATE, flags, cd_nelemts, NULL, 8, filter_name, config); - if (HDstrncmp(filter_name, "deflate", 7) != 0) - H5_FAILED() + if (HDstrncmp(filter_name, "deflate", 7) != 0) + H5_FAILED() } catch (Exception e) { H5_FAILED(); return 1; @@ -304,7 +304,7 @@ int TestCompress() PASSED(); #else SKIPPED(); - puts(" deflate filter not enabled"); + HDputs(" deflate filter not enabled"); #endif /* H5_HAVE_FILTER_DEFLATE */ return 0; } @@ -315,7 +315,7 @@ int TestGetPacket() int record; int theRecs[3]; int i; - TESTING("GetPacket") + TESTING2("GetPacket") /* Create a dataset. Does not need to specify property list because there is no compression. */ @@ -353,7 +353,7 @@ const char* PT_TESTERROR = "/TestErrors"; int TestErrors() { - TESTING("error conditions") + TESTING2("error conditions") /* Create a dataset */ FL_PacketTable wrapper(fileID, PT_TESTERROR, H5T_NATIVE_INT, 1); @@ -464,7 +464,7 @@ const char* PT_SYSTEMTST1 = "/SystemTest1"; const char* PT_SYSTEMTST2 = "/SystemTest2"; int SystemTest() { - TESTING("multiple datatypes") + TESTING2("multiple datatypes") hid_t dtypeID1, dtypeID2; hsize_t count; @@ -560,16 +560,16 @@ error: /*------------------------------------------------------------------------- * TestHDFFV_9758(): Test that a packet table with compound datatype which - * contains string type can be created and written correctly. (HDFFV-9758) + * contains string type can be created and written correctly. (HDFFV-9758) * * Notes: - * Previously, data of the field that follows the string was read back - * as garbage when #pragma pack(1) is used. + * Previously, data of the field that follows the string was read back + * as garbage when #pragma pack(1) is used. * 2016/10/20 -BMR * Updated: - * #pragma pack(1) caused failure on Emu because Sparc cannot - * access misaligned data. Changed it to pack() to do the - * default alignment. + * #pragma pack(1) caused failure on Emu because Sparc cannot + * access misaligned data. Changed it to pack() to do the + * default alignment. * 2016/10/25 -BMR *------------------------------------------------------------------------- */ @@ -592,57 +592,57 @@ int TestHDFFV_9758() }; s1_t s1[NUM_PACKETS]; - + for (hsize_t i = 0; i < NUM_PACKETS; i++) { s1[i].a = i; s1[i].b = 1.f * static_cast<float>(i * i); s1[i].c = 1. / (i + 1); - sprintf(s1[i].d, "string%d", (int)i); + HDsprintf(s1[i].d, "string%d", (int)i); s1[i].e = 100+i; } - TESTING("data corruption in packed structs (HDFFV-9758)") + TESTING2("data corruption in packed structs (HDFFV-9758)") // Build a compound datatype compound_type = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); if (compound_type < 0) - goto error; - + goto error; + err = H5Tinsert(compound_type, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT); if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); if (err < 0) - goto error; + goto error; strtype = H5Tcopy (H5T_C_S1); if (compound_type < 0) - goto error; + goto error; err = H5Tset_size (strtype, STRING_LENGTH); /* create string */ if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "d_name", HOFFSET(s1_t, d), strtype); if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "e_name", HOFFSET(s1_t, e), H5T_NATIVE_INT); if (err < 0) - goto error; + goto error; { // so ptable will go out of scope before PASSED // Create a packet table FL_PacketTable ptable(fileID, "/examplePacketTable", compound_type, 1); if (!ptable.IsValid()) - goto error; + goto error; // Add packets to the table for (size_t i = 0; i < NUM_PACKETS; i++) { - /* Appends one packet at the current position */ + /* Appends one packet at the current position */ err = ptable.AppendPacket(s1 + i); if (err < 0) goto error; } @@ -650,11 +650,11 @@ int TestHDFFV_9758() // Check packet count const hsize_t count = ptable.GetPacketCount(err); if (err < 0) - goto error; - + goto error; + if (count != NUM_PACKETS) { - std::cerr + std::cerr << "Number of packets in packet table should be " << NUM_PACKETS << " but is " << count << endl; } @@ -663,16 +663,16 @@ int TestHDFFV_9758() ptable.ResetIndex(); for (size_t i = 0; i < NUM_PACKETS; i++) { - s1_t s2; - memset(&s2, 0, sizeof(s1_t)); - err = ptable.GetNextPacket(&s2); - if (err < 0) - goto error; - - if (s2.a != s1[i].a || s2.e != s1[i].e) - goto error; - else if (HDstrcmp(s2.d, s1[i].d)) - goto error; + s1_t s2; + HDmemset(&s2, 0, sizeof(s1_t)); + err = ptable.GetNextPacket(&s2); + if (err < 0) + goto error; + + if (s2.a != s1[i].a || s2.e != s1[i].e) + goto error; + else if (HDstrcmp(s2.d, s1[i].d)) + goto error; } } // end of ptable block diff --git a/hl/c++/test/ptableTest.h b/hl/c++/test/ptableTest.h index 8af7bff..e1ba950 100644 --- a/hl/c++/test/ptableTest.h +++ b/hl/c++/test/ptableTest.h @@ -21,9 +21,9 @@ #ifndef PTABLETEST #define PTABLETEST +#include "h5hltest.h" #include "H5PacketTable.h" #include "H5Cpp.h" -#include "h5hltest.h" static hid_t fileID; diff --git a/hl/test/h5hltest.h b/hl/test/h5hltest.h index f368b8e..5dd3c20 100644 --- a/hl/test/h5hltest.h +++ b/hl/test/h5hltest.h @@ -28,8 +28,8 @@ #include "H5HLprivate2.h" /* Macros used in HL tests */ -#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);} -#define TESTING3(WHAT) {printf("%-70s", "" WHAT); fflush(stdout);} +#define HL_TESTING2(WHAT) {HDprintf("%-70s", "Testing " WHAT); HDfflush(stdout);} +#define HL_TESTING3(WHAT) {HDprintf("%-70s", "" WHAT); HDfflush(stdout);} /* Implements verbose 'assert' with 'goto error' exit */ #define VERIFY(condition, string) do { if (!(condition)) FAIL_PUTS_ERROR(string) } while(0) diff --git a/hl/test/test_table.c b/hl/test/test_table.c index 0215697..e849175 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -51,8 +51,6 @@ #define NRECORDS 8 #define NRECORDS_ADD 3 -#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);} - /*------------------------------------------------------------------------- * structure used for all tests, a particle with properties *------------------------------------------------------------------------- @@ -117,7 +115,7 @@ typedef struct particle3_t *------------------------------------------------------------------------- */ -/* Push current alignment rule forcing 4-byte alignment boundary +/* Push current alignment rule forcing 4-byte alignment boundary * to the internal stack ... */ #pragma pack(push,4) @@ -129,7 +127,7 @@ typedef struct particle3_t float aty[3]; float rro[2]; } particle4_t; -/* +/* * ... and restore original alignment rules from stack */ #pragma pack(pop) @@ -164,14 +162,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 || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) || - !H5_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) ) { HDfprintf(stderr,"read and write buffers have differences\n"); HDfprintf(stderr,"%s %ld %f %f %d\n", - rbuf[i].name,rbuf[i].longi,(double)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,(double)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; @@ -424,7 +422,7 @@ static int test_table(hid_t fid, int do_write) sizeof( rbuf[0].lati) }; - const char *field_names4[NFIELDS+1] = + const char *field_names4[NFIELDS+1] = { "F1", "F2", "F3", "F4", "F5", "F6"}; hid_t field_type4[NFIELDS+1]; particle4_t fill_data[1] = { {9999999, -9999999, 999999, {999,999,999},{999,999,999}, {999,999}} }; @@ -883,7 +881,7 @@ static int test_table(hid_t fid, int do_write) /*------------------------------------------------------------------------ * Functions tested: * - * H5TBdelete_record -- With differing memory layout from machine memory + * H5TBdelete_record -- With differing memory layout from machine memory * layout. HDFFV-8055 * *------------------------------------------------------------------------- @@ -892,45 +890,45 @@ static int test_table(hid_t fid, int do_write) { TESTING2("deleting records (differing memory layout)"); - dims = 3; - arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + dims = 3; + arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); - dims = 2; - arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + dims = 2; + arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); - /* Initialize the field field_type */ - field_type4[0] = H5T_NATIVE_UINT32; - field_type4[1] = H5T_NATIVE_DOUBLE; - field_type4[2] = H5T_NATIVE_DOUBLE; - field_type4[3] = arry3_32f; - field_type4[4] = arry3_32f; - field_type4[5] = arry2_32f; + /* Initialize the field field_type */ + field_type4[0] = H5T_NATIVE_UINT32; + field_type4[1] = H5T_NATIVE_DOUBLE; + field_type4[2] = H5T_NATIVE_DOUBLE; + field_type4[3] = arry3_32f; + field_type4[4] = arry3_32f; + field_type4[5] = arry2_32f; - /* Make the table */ - if (H5TBmake_table("Table Title",fid,"table",NFIELDS+1,(hsize_t)NRECORDS, + /* Make the table */ + if (H5TBmake_table("Table Title",fid,"table",NFIELDS+1,(hsize_t)NRECORDS, tbl_size, field_names4, tbl_offset, field_type4, chunk_size, fill_data, compress, p_data)<0) - goto out; - /* Delete records */ - start = 3; - nrecords = 3; - if (H5TBdelete_record(fid, "table", start, nrecords)<0) - goto out;; - /* Get table info */ - if (H5TBget_table_info(fid,"table", &nfields_out, &nrecords_out)<0) - goto out; - /* check */ - if( (int)nfields_out != (int)NFIELDS+1) - goto out; - - if( (int)nrecords_out != (int)NRECORDS-3) - goto out; - - /* close type */ - H5Tclose(arry3_32f); - H5Tclose(arry2_32f); - - PASSED(); + goto out; + /* Delete records */ + start = 3; + nrecords = 3; + if (H5TBdelete_record(fid, "table", start, nrecords)<0) + goto out;; + /* Get table info */ + if (H5TBget_table_info(fid,"table", &nfields_out, &nrecords_out)<0) + goto out; + /* check */ + if( (int)nfields_out != (int)NFIELDS+1) + goto out; + + if( (int)nrecords_out != (int)NRECORDS-3) + goto out; + + /* close type */ + H5Tclose(arry3_32f); + H5Tclose(arry2_32f); + + PASSED(); } /*------------------------------------------------------------------------- @@ -1138,10 +1136,10 @@ 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 || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) + !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) { HDfprintf(stderr,"%ld %f %d\n", - rbuf[i].longi,(double)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,(double)pressure_in[i],position_in[i].lati); goto out; @@ -1191,7 +1189,7 @@ static int test_table(hid_t fid, int do_write) if ( H5TBread_fields_name(fid,"table10","DoesNotExist",start,nrecords, sizeof(float),0,field_sizes_pre,pressure_out) >=0) goto out; - + /* read the "Pressure" field */ if ( H5TBread_fields_name(fid,"table10","Pressure",start,nrecords, sizeof(float),0,field_sizes_pre,pressure_out)<0) @@ -1263,7 +1261,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 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { goto out; } } @@ -1292,7 +1290,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 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart+i].pressure) ) { + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart+i].pressure) ) { goto out; } } @@ -1351,7 +1349,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 || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) + !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) goto out; } } @@ -1470,8 +1468,8 @@ 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 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { - goto out; + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { + goto out; } } @@ -1501,7 +1499,7 @@ static int test_table(hid_t fid, int do_write) { int iistart = (int) start; if ( ( HDstrcmp( namepre_out[i].name, wbuf[iistart+(int)i].name ) != 0 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart+(int)i].pressure) ) { + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart+(int)i].pressure) ) { goto out; } } @@ -1544,8 +1542,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 || - !H5_FLT_ABS_EQUAL(rbuf2[i].pressure,wbuf[i].pressure) || - !H5_DBL_ABS_EQUAL(rbuf2[i].temperature,wbuf[i].temperature) || + !H5_FLT_ABS_EQUAL(rbuf2[i].pressure,wbuf[i].pressure) || + !H5_DBL_ABS_EQUAL(rbuf2[i].temperature,wbuf[i].temperature) || rbuf2[i].new_field != buf_new[i] ) { goto out; } @@ -1585,7 +1583,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 || - !H5_DBL_ABS_EQUAL(rbuf3[i].temperature,wbuf[i].temperature) ) { + !H5_DBL_ABS_EQUAL(rbuf3[i].temperature,wbuf[i].temperature) ) { goto out; } } |