diff options
Diffstat (limited to 'hl/c++')
-rw-r--r-- | hl/c++/examples/CMakeTests.cmake | 4 | ||||
-rw-r--r-- | hl/c++/src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | hl/c++/test/CMakeTests.cmake | 9 | ||||
-rw-r--r-- | hl/c++/test/ptableTest.cpp | 126 | ||||
-rw-r--r-- | hl/c++/test/ptableTest.h | 2 |
5 files changed, 80 insertions, 63 deletions
diff --git a/hl/c++/examples/CMakeTests.cmake b/hl/c++/examples/CMakeTests.cmake index 103ec2b..7bc614b 100644 --- a/hl/c++/examples/CMakeTests.cmake +++ b/hl/c++/examples/CMakeTests.cmake @@ -21,12 +21,14 @@ add_test ( COMMAND ${CMAKE_COMMAND} -E remove PTcppexampleFL.h5 + ptExampleFL.txt ) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME HL_CPP_ex_ptExampleFL COMMAND $<TARGET_FILE:ptExampleFL>) + add_test (NAME HL_CPP_ex_ptExampleFL COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:ptExampleFL>) else () add_test (NAME HL_CPP_ex_ptExampleFL COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$<TARGET_FILE:ptExampleFL>" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt index 1911d62..9964160 100644 --- a/hl/c++/src/CMakeLists.txt +++ b/hl/c++/src/CMakeLists.txt @@ -108,7 +108,7 @@ install ( COMPONENT hlcpplibraries ) -if (NOT WIN32) +if (NOT WIN32 AND NOT MINGW) set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in diff --git a/hl/c++/test/CMakeTests.cmake b/hl/c++/test/CMakeTests.cmake index 785abca..3d0f93a 100644 --- a/hl/c++/test/CMakeTests.cmake +++ b/hl/c++/test/CMakeTests.cmake @@ -16,10 +16,16 @@ ############################################################################## ############################################################################## +add_test ( + NAME HL_CPP_ptableTest-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove ${example}.txt +) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME HL_CPP_ptableTest COMMAND $<TARGET_FILE:hl_ptableTest>) + add_test (NAME HL_CPP_ptableTest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hl_ptableTest>) else () add_test (NAME HL_CPP_ptableTest COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$<TARGET_FILE:hl_ptableTest>" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -30,3 +36,4 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () +set_tests_properties (HL_CPP_ptableTest PROPERTIES DEPENDS HL_CPP_ptableTest-clear-objects) diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp index 340912e..e873503 100644 --- a/hl/c++/test/ptableTest.cpp +++ b/hl/c++/test/ptableTest.cpp @@ -36,22 +36,22 @@ int main(void) } 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); @@ -81,7 +81,8 @@ int BasicTest() hsize_t count; int error; - TESTING("basic functionality") + printf("Testing %-62s", "basic functionality"); + HDfflush(stdout); FL_PacketTable wrapper(fileID, H5P_DEFAULT, BASICTEST_PT, H5T_NATIVE_INT, 1); if(! wrapper.IsValid()) @@ -137,7 +138,8 @@ int TestCompoundDatatype() hsize_t count; int error; - TESTING("compound datatypes") + printf("Testing %-62s", "compound datatypes"); + HDfflush(stdout); /* Create compound datatype */ typedef struct compoundType @@ -206,7 +208,8 @@ int TestGetNext() int records[2]; int i; - TESTING("GetNextPacket") + printf("Testing %-62s", "GetNextPacket"); + HDfflush(stdout); /* Create a dataset */ FL_PacketTable wrapper(fileID, H5P_DEFAULT, GETNEXT_PT, H5T_NATIVE_INT, 500); @@ -268,20 +271,21 @@ int TestCompress() unsigned int config = 0; size_t cd_nelemts = 0; - TESTING("compression") + printf("Testing %-62s", "compression"); + HDfflush(stdout); #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 +297,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 +308,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 +319,8 @@ int TestGetPacket() int record; int theRecs[3]; int i; - TESTING("GetPacket") + printf("Testing %-62s", "GetPacket"); + HDfflush(stdout); /* Create a dataset. Does not need to specify property list because there is no compression. */ @@ -353,7 +358,8 @@ const char* PT_TESTERROR = "/TestErrors"; int TestErrors() { - TESTING("error conditions") + printf("Testing %-62s", "error conditions"); + HDfflush(stdout); /* Create a dataset */ FL_PacketTable wrapper(fileID, PT_TESTERROR, H5T_NATIVE_INT, 1); @@ -464,7 +470,8 @@ const char* PT_SYSTEMTST1 = "/SystemTest1"; const char* PT_SYSTEMTST2 = "/SystemTest2"; int SystemTest() { - TESTING("multiple datatypes") + printf("Testing %-62s", "multiple datatypes"); + HDfflush(stdout); hid_t dtypeID1, dtypeID2; hsize_t count; @@ -560,16 +567,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 +599,58 @@ 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)") + printf("Testing %-62s", "data corruption in packed structs (HDFFV-9758)"); + HDfflush(stdout); // 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 +658,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 +671,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; |