diff --git a/CMakeLists.txt b/CMakeLists.txt index bd7f19091..ac8d0068e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,7 @@ set(PROJECT_VERSION 5.0.0) include(CheckIPOSupported) - - +cmake_policy(SET CMP0074 NEW) include(cmake/project_version.cmake) # Include additional modules that are used unconditionally diff --git a/slsReceiverSoftware/include/BinaryFile.h b/slsReceiverSoftware/include/BinaryFile.h index 1a5f5ab28..1ac9ff8ab 100755 --- a/slsReceiverSoftware/include/BinaryFile.h +++ b/slsReceiverSoftware/include/BinaryFile.h @@ -47,14 +47,13 @@ class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFi /** * Print all member values */ - void PrintMembers(TLogLevel level = logDEBUG1); + void PrintMembers(TLogLevel level = logDEBUG1) override; /** * Create file - * @param fnum current frame index to include in file name * @returns OK or FAIL */ - int CreateFile(uint64_t fnum); + int CreateFile() override; /** * Create master file @@ -71,17 +70,17 @@ class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFi */ int CreateMasterFile(bool mfwenable, bool en, uint32_t size, uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp, - uint64_t ap); + uint64_t ap) override; /** * Close Current File */ - void CloseCurrentFile(); + void CloseCurrentFile() override; /** * Close all Files */ - void CloseAllFiles(); + void CloseAllFiles() override; /** * Write data to file @@ -91,7 +90,7 @@ class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFi * @param nump number of packets caught * @returns OK or FAIL */ - int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump); + int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) override; @@ -101,7 +100,7 @@ class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFi * Get Type * @return type */ - fileFormat GetFileType(); + fileFormat GetFileType() override; diff --git a/slsReceiverSoftware/include/BinaryFileStatic.h b/slsReceiverSoftware/include/BinaryFileStatic.h index b528f8d73..3fbd8c25a 100755 --- a/slsReceiverSoftware/include/BinaryFileStatic.h +++ b/slsReceiverSoftware/include/BinaryFileStatic.h @@ -10,6 +10,7 @@ #include "ansi.h" +#include "logger.h" #include #include @@ -33,43 +34,39 @@ class BinaryFileStatic { * @param fpath file path * @param fnameprefix file name prefix (includes scan and position variables) * @param findex file index - * @param frindexenable frame index enable - * @param fnum frame number index + * @param subfindex sub file index * @param dindex readout index * @param numunits number of units per readout. eg. eiger has 2 udp units per readout * @param unitindex unit index * @returns complete file name created */ - static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable, - uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0) - { - std::ostringstream osfn; - osfn << fpath << "/" << fnameprefix; - if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex); - if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum; - osfn << "_" << findex; - osfn << ".raw"; - return osfn.str(); + static std::string CreateFileName(char *fpath, char *fprefix, + uint64_t findex, uint64_t subfindex, + int dindex, int numunits = 1, + int unitindex = 0) { + std::ostringstream os; + os << fpath << "/" << fprefix << "_d" + << (dindex * numunits + unitindex) << "_f" << subfindex << '_' + << findex << ".raw"; + return os.str(); } - /** + /** * Create file names for master file * @param fpath file path * @param fnameprefix file name prefix (includes scan and position variables) * @param findex file index * @returns master file name */ - std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex) - { - std::ostringstream osfn; - osfn << fpath << "/" << fnameprefix; - osfn << "_master"; - osfn << "_" << findex; - osfn << ".raw"; - return osfn.str(); + static std::string CreateMasterFileName(char *fpath, char *fnameprefix, + uint64_t findex) { + std::ostringstream os; + os << fpath << "/" << fnameprefix << "_master" + << "_" << findex << ".raw"; + return os.str(); } - /** + /** * Close File * @param fd file pointer */ diff --git a/slsReceiverSoftware/include/File.h b/slsReceiverSoftware/include/File.h index 00ca02feb..2a0dfb761 100755 --- a/slsReceiverSoftware/include/File.h +++ b/slsReceiverSoftware/include/File.h @@ -50,6 +50,8 @@ class File : private virtual slsDetectorDefs { */ std::string GetCurrentFileName(); + + void resetSubFileIndex(); /** * Print all member values */ @@ -81,30 +83,19 @@ class File : private virtual slsDetectorDefs { /** * Create file - * @param fnum current frame index to include in file name * @returns OK or FAIL */ - virtual int CreateFile(uint64_t fnum){ - FILE_LOG(logERROR) << "This is a generic function CreateFile that should be " - "overloaded by a derived class"; - return OK; - } + virtual int CreateFile() = 0; /** * Close Current File */ - virtual void CloseCurrentFile() { - FILE_LOG(logERROR) << "This is a generic function CloseCurrentFile that should be " - "overloaded by a derived class"; - } + virtual void CloseCurrentFile() = 0; /** * Close Files */ - virtual void CloseAllFiles() { - FILE_LOG(logERROR) << "This is a generic function that should be overloaded " - "by a derived class"; - } + virtual void CloseAllFiles() = 0; /** * Write data to file @@ -113,11 +104,7 @@ class File : private virtual slsDetectorDefs { * @param nump number of packets caught * @param OK or FAIL */ - virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) { - FILE_LOG(logERROR) << "This is a generic function WriteToFile that " - "should be overloaded by a derived class"; - return FAIL; - } + virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) = 0; /** * Create master file @@ -134,11 +121,7 @@ class File : private virtual slsDetectorDefs { */ virtual int CreateMasterFile(bool mfwenable, bool en, uint32_t size, uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, - uint64_t sp, uint64_t ap) { - FILE_LOG(logERROR) << "This is a generic function CreateMasterFile that " - "should be overloaded by a derived class"; - return OK; - } + uint64_t sp, uint64_t ap) = 0; // HDf5 specific /** @@ -150,6 +133,7 @@ class File : private virtual slsDetectorDefs { FILE_LOG(logERROR) << "This is a generic function SetNumberofPixels that " "should be overloaded by a derived class"; } + /** * End of Acquisition @@ -193,6 +177,9 @@ class File : private virtual slsDetectorDefs { /** File Index */ uint64_t* fileIndex; + /** Sub file index */ + uint64_t subFileIndex{0}; + /** Over write enable */ bool* overWriteEnable; diff --git a/slsReceiverSoftware/include/HDF5File.h b/slsReceiverSoftware/include/HDF5File.h index 3d0b95c16..0a93ed712 100755 --- a/slsReceiverSoftware/include/HDF5File.h +++ b/slsReceiverSoftware/include/HDF5File.h @@ -69,7 +69,7 @@ class HDF5File : private virtual slsDetectorDefs, public File, public HDF5FileSt * @param fnum current frame index to include in file name * @returns OK or FAIL */ - int CreateFile(uint64_t fnum); + int CreateFile(); /** * Close Current File diff --git a/slsReceiverSoftware/include/HDF5FileStatic.h b/slsReceiverSoftware/include/HDF5FileStatic.h index 0a7955d4f..fc771ab99 100755 --- a/slsReceiverSoftware/include/HDF5FileStatic.h +++ b/slsReceiverSoftware/include/HDF5FileStatic.h @@ -40,26 +40,24 @@ public: * @param fpath file path * @param fnameprefix file name prefix (includes scan and position variables) * @param findex file index - * @param frindexenable frame index enable - * @param fnum frame number index + * @param subfindex sub file index * @param dindex readout index * @param numunits number of units per readout. eg. eiger has 2 udp units per readout * @param unitindex unit index * @returns complete file name created */ - static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable, - uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0) - { - std::ostringstream osfn; - osfn << fpath << "/" << fnameprefix; - if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex); - if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum; - osfn << "_" << findex; - osfn << ".h5"; - return osfn.str(); + static std::string CreateFileName(char *fpath, char *fprefix, + uint64_t findex, uint64_t subfindex, + int dindex, int numunits = 1, + int unitindex = 0) { + std::ostringstream os; + os << fpath << "/" << fprefix << "_d" + << (dindex * numunits + unitindex) << "_f" << subfindex << '_' + << findex << ".h5"; + return os.str(); } - /** + /** * Create master file name * @param fpath file path * @param fnameprefix file name prefix (includes scan and position variables) @@ -68,12 +66,10 @@ public: */ static std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex) { - std::ostringstream osfn; - osfn << fpath << "/" << fnameprefix; - osfn << "_master"; - osfn << "_" << findex; - osfn << ".h5"; - return osfn.str(); + std::ostringstream os; + os << fpath << "/" << fnameprefix << "_master" + << "_" << findex << ".h5"; + return os.str(); } /** @@ -111,7 +107,7 @@ public: delete fd; fd = 0; } - } catch(Exception error) { + } catch(const Exception& error) { FILE_LOG(logERROR) << "Could not close HDF5 handles of index " << ind; error.printErrorStack(); } @@ -129,7 +125,7 @@ public: delete fd; fd = 0; } - } catch(Exception error) { + } catch(const Exception& error) { FILE_LOG(logERROR) << "Could not close master HDF5 handles"; error.printErrorStack(); } @@ -177,7 +173,7 @@ public: dset->write(buf, dtype, memspace, *dspace); memspace.close(); } - catch(Exception error){ + catch(const Exception& error){ FILE_LOG(logERROR) << "Could not write to file in object " << ind; error.printErrorStack(); return 1; @@ -239,7 +235,7 @@ public: dset_para[13]->write((char*)storage, parameterDataTypes[13], memspace, *dspace_para); }i=14; } - catch(Exception error){ + catch(const Exception& error){ FILE_LOG(logERROR) << "Could not write parameters (index:" << i << ") to file in object " << ind; error.printErrorStack(); return 1; @@ -282,7 +278,7 @@ public: dspace_para = new DataSpace(dset_para[0]->getSpace()); } - catch(Exception error){ + catch(const Exception& error){ FILE_LOG(logERROR) << "Could not extend dataset in object " << ind; error.printErrorStack(); return 1; @@ -417,7 +413,7 @@ public: fd->close(); - } catch(Exception error) { + } catch(const Exception& error) { FILE_LOG(logERROR) << "Could not create master HDF5 handles"; error.printErrorStack(); if (fd) fd->close(); @@ -521,7 +517,7 @@ public: dset_para.push_back(ds); } } - catch(Exception error){ + catch(const Exception& error){ FILE_LOG(logERROR) << "Could not create HDF5 handles in object " << ind; error.printErrorStack(); if (fd) fd->close(); @@ -675,8 +671,9 @@ public: //source file name std::string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex, - frindexenable, framesSaved, dindex, numunits, i); + j, dindex, numunits, i); + FILE_LOG(logERROR) << srcFileName; // find relative path std::string relative_srcFileName = srcFileName; { @@ -688,7 +685,7 @@ public: //source dataset name std::ostringstream osfn; osfn << "/data"; - if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << framesSaved; + if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << j; std::string srcDatasetName = osfn.str(); //source dataspace @@ -861,7 +858,7 @@ public: newDataset->write(data_out,datatype); newfd->close(); oldfd->close(); - } catch(Exception error){ + } catch(const Exception& error){ FILE_LOG(logERROR) << "Could not copy virtual files"; error.printErrorStack(); free(data_out); diff --git a/slsReceiverSoftware/src/BinaryFile.cpp b/slsReceiverSoftware/src/BinaryFile.cpp index 6b9ec97e9..24923a9e9 100755 --- a/slsReceiverSoftware/src/BinaryFile.cpp +++ b/slsReceiverSoftware/src/BinaryFile.cpp @@ -42,12 +42,12 @@ slsDetectorDefs::fileFormat BinaryFile::GetFileType() { } -int BinaryFile::CreateFile(uint64_t fnum) { +int BinaryFile::CreateFile() { numFramesInFile = 0; numActualPacketsInFile = 0; currentFileName = BinaryFileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex, - (*numImages > 1), fnum, *detIndex, *numUnitsPerDetector, index); + subFileIndex, *detIndex, *numUnitsPerDetector, index); if (BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE) == FAIL) return FAIL; @@ -72,7 +72,8 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_ // check if maxframesperfile = 0 for infinite if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) { CloseCurrentFile(); - CreateFile(fnum); + ++subFileIndex; + CreateFile(); } numFramesInFile++; numActualPacketsInFile += nump; diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index d115d1fd6..ea0a9bc37 100755 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -252,11 +252,12 @@ int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, if (file == nullptr) return FAIL; file->CloseAllFiles(); + file->resetSubFileIndex(); if (file->CreateMasterFile(*masterFileWriteEnable, en, generalData->imageSize, generalData->nPixelsX, generalData->nPixelsY, at, st, sp, ap) == FAIL) return FAIL; - if (file->CreateFile(currentFrameIndex) == FAIL) + if (file->CreateFile() == FAIL) return FAIL; return OK; } diff --git a/slsReceiverSoftware/src/File.cpp b/slsReceiverSoftware/src/File.cpp index b72324e39..e0d439ee3 100755 --- a/slsReceiverSoftware/src/File.cpp +++ b/slsReceiverSoftware/src/File.cpp @@ -38,6 +38,10 @@ std::string File::GetCurrentFileName() { return currentFileName; } +void File::resetSubFileIndex(){ + subFileIndex = 0u; +} + void File::PrintMembers(TLogLevel level) { FILE_LOG(level) << "\nGeneral Writer Variables:" << std::endl << "Index: " << index << std::endl diff --git a/slsReceiverSoftware/src/HDF5File.cpp b/slsReceiverSoftware/src/HDF5File.cpp index ec16271c8..c462a8520 100755 --- a/slsReceiverSoftware/src/HDF5File.cpp +++ b/slsReceiverSoftware/src/HDF5File.cpp @@ -128,22 +128,23 @@ void HDF5File::UpdateDataType() { } -int HDF5File::CreateFile(uint64_t fnum) { +int HDF5File::CreateFile() { numFilesinAcquisition++; numFramesInFile = 0; numActualPacketsInFile = 0; currentFileName = HDF5FileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex, - (*numImages > 1), fnum, *detIndex, *numUnitsPerDetector, index); + subFileIndex, *detIndex, *numUnitsPerDetector, index); //first time - if(!fnum) UpdateDataType(); + if(subFileIndex == 0u) + UpdateDataType(); uint64_t framestosave = ((*maxFramesPerFile == 0) ? *numImages : // infinite images - (((extNumImages - fnum) > (*maxFramesPerFile)) ? // save up to maximum at a time - (*maxFramesPerFile) : (extNumImages-fnum))); + (((extNumImages - subFileIndex) > (*maxFramesPerFile)) ? // save up to maximum at a time + (*maxFramesPerFile) : (extNumImages-subFileIndex))); pthread_mutex_lock(&Mutex); if (HDF5FileStatic::CreateDataFile(index, *overWriteEnable, currentFileName, (*numImages > 1), - fnum, framestosave, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX), + subFileIndex, framestosave, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX), datatype, filefd, dataspace, dataset, HDF5_WRITER_VERSION, MAX_CHUNKED_IMAGES, dataspace_para, dataset_para, @@ -199,7 +200,8 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t // check if maxframesperfile = 0 for infinite if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) { CloseCurrentFile(); - CreateFile(fnum); + ++subFileIndex; + CreateFile(); } numFramesInFile++; numActualPacketsInFile += nump; diff --git a/slsReceiverSoftware/tests/CMakeLists.txt b/slsReceiverSoftware/tests/CMakeLists.txt index d8cc5e694..d8e89f687 100755 --- a/slsReceiverSoftware/tests/CMakeLists.txt +++ b/slsReceiverSoftware/tests/CMakeLists.txt @@ -1,24 +1,4 @@ -# include_directories( -# ${PROJECT_SOURCE_DIR}/catch -# ) - -# set(SOURCES -# test.cpp -# test-GeneralData.cpp -# ) - -#target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test-GeneralData.cpp) - -# add_executable(testSlsReceiver ${SOURCES}) -# target_link_libraries(testSlsReceiver -# slsSupportLib -# slsDetectorShared -# slsReceiverShared -# pthread -# rt -# ) -# set_target_properties(testSlsReceiver PROPERTIES -# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -# ) -# #TODO! Move to automatic test discovery -# add_test(test-testSlsReceiver ${CMAKE_BINARY_DIR}/bin/testSlsReceiver) \ No newline at end of file +target_sources(tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/test-GeneralData.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test-FileNames.cpp +) \ No newline at end of file diff --git a/slsReceiverSoftware/tests/test-FileNames.cpp b/slsReceiverSoftware/tests/test-FileNames.cpp new file mode 100644 index 000000000..14495ff7d --- /dev/null +++ b/slsReceiverSoftware/tests/test-FileNames.cpp @@ -0,0 +1,147 @@ +#include "BinaryFile.h" +#include "BinaryFileStatic.h" +#ifdef HDF5C +#include "HDF5FileStatic.h" +#endif + +#include "catch.hpp" + +SCENARIO("File name creation raw files", "[receiver]") { + GIVEN("These parameters and a binary file") { + + std::string fpath = "/home/test"; + std::string fnameprefix = "hej"; + uint64_t findex{0}; + uint64_t fnum{0}; + int dindex{0}; + int numunits{1}; + int unitindex{0}; + + WHEN("called with default arguments and true") { + auto fname = BinaryFileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex); + THEN("filename contains frame index") { + REQUIRE(fname == "/home/test/hej_d0_f0_0.raw"); + } + } + WHEN("the file index is set") { + fnum = 123456; + auto fname = BinaryFileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex); + THEN("The frame number is in the file name") { + REQUIRE(fname == "/home/test/hej_d0_f123456_0.raw"); + } + } + WHEN("setting numunits ") { + dindex = 2; + numunits = 2; + unitindex = 0; + auto fname = BinaryFileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex, numunits, + unitindex); + + unitindex = 1; + auto fname2 = BinaryFileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex, numunits, + unitindex); + THEN("this gets reflected in d number") { + REQUIRE(fname == "/home/test/hej_d4_f0_0.raw"); + REQUIRE(fname2 == "/home/test/hej_d5_f0_0.raw"); + } + } + WHEN("measurements index is set") { + findex = 96; + dindex = 0; + auto fname = BinaryFileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex); + THEN("this is printed in the file name") { + REQUIRE(fname == "/home/test/hej_d0_f0_96.raw"); + } + } + } +} + +SCENARIO("Creating master file name", "[receiver]") { + GIVEN("these parameters") { + std::string fpath = "/home/test"; + std::string fnameprefix = "hej"; + uint64_t findex{0}; + + WHEN("the master file name is created") { + THEN("all parameters are found") { + BinaryFileStatic b; + auto fname = + b.CreateMasterFileName(&fpath[0], &fnameprefix[0], findex); + REQUIRE(fname == "/home/test/hej_master_0.raw"); + } + } + WHEN("flie index is changed") { + THEN("its visible in the file name") { + findex = 398; + BinaryFileStatic b; + auto fname = + b.CreateMasterFileName(&fpath[0], &fnameprefix[0], findex); + REQUIRE(fname == "/home/test/hej_master_398.raw"); + } + } + } +} + +#ifdef HDF5C + +SCENARIO("File name creation hdf5 files", "[receiver]") { + GIVEN("Some paramters") { + + std::string fpath = "/home/test"; + std::string fnameprefix = "hej"; + uint64_t findex{0}; + uint64_t fnum{0}; + int dindex{0}; + int numunits{1}; + int unitindex{0}; + + WHEN("called with default arguments and true for frindexenable") { + auto fname = HDF5FileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex); + THEN("filename contains frame index") { + REQUIRE(fname == "/home/test/hej_d0_f0_0.h5"); + } + } + WHEN("the frame number is set") { + fnum = 123456; + auto fname = HDF5FileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex); + THEN("The frame number is in the file name") { + REQUIRE(fname == "/home/test/hej_d0_f123456_0.h5"); + } + } + WHEN("setting numunits ") { + dindex = 2; + numunits = 2; + unitindex = 0; + auto fname = HDF5FileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex, numunits, + unitindex); + + unitindex = 1; + auto fname2 = HDF5FileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex, numunits, + unitindex); + THEN("this gets reflected in d number") { + REQUIRE(fname == "/home/test/hej_d4_f0_0.h5"); + REQUIRE(fname2 == "/home/test/hej_d5_f0_0.h5"); + } + } + WHEN("set findex") { + findex = 96; + dindex = 0; + auto fname = HDF5FileStatic::CreateFileName( + &fpath[0], &fnameprefix[0], findex, fnum, dindex); + THEN("this is printed in the file name") { + REQUIRE(fname == "/home/test/hej_d0_f0_96.h5"); + } + } + } +} + +#endif \ No newline at end of file diff --git a/slsReceiverSoftware/tests/test-GeneralData.cpp b/slsReceiverSoftware/tests/test-GeneralData.cpp index 996ad612f..df0713469 100755 --- a/slsReceiverSoftware/tests/test-GeneralData.cpp +++ b/slsReceiverSoftware/tests/test-GeneralData.cpp @@ -9,51 +9,51 @@ // using namespace sls; -TEST_CASE("Parse jungfrauctb header", "[receiver]") { +// TEST_CASE("Parse jungfrauctb header", "[receiver]") { - struct packet { - unsigned char emptyHeader[6]; - unsigned char reserved[4]; - unsigned char packetNumber[1]; - unsigned char frameNumber[3]; - unsigned char bunchid[8]; - unsigned char data[UDP_PACKET_DATA_BYTES]; - } __attribute__((packed)); +// struct packet { +// unsigned char emptyHeader[6]; +// unsigned char reserved[4]; +// unsigned char packetNumber[1]; +// unsigned char frameNumber[3]; +// unsigned char bunchid[8]; +// unsigned char data[UDP_PACKET_DATA_BYTES]; +// } __attribute__((packed)); - MoenchData data; +// MoenchData data; - packet test_packet; - test_packet.packetNumber[0] = 53u; - test_packet.frameNumber[0] = 32u; - test_packet.frameNumber[1] = 15u; - test_packet.frameNumber[2] = 91u; +// packet test_packet; +// test_packet.packetNumber[0] = 53u; +// test_packet.frameNumber[0] = 32u; +// test_packet.frameNumber[1] = 15u; +// test_packet.frameNumber[2] = 91u; - test_packet.bunchid[0] = 91u; - test_packet.bunchid[1] = 25u; - test_packet.bunchid[2] = 15u; - test_packet.bunchid[3] = 1u; - test_packet.bunchid[4] = 32u; - test_packet.bunchid[5] = 251u; - test_packet.bunchid[6] = 18u; - test_packet.bunchid[7] = 240u; +// test_packet.bunchid[0] = 91u; +// test_packet.bunchid[1] = 25u; +// test_packet.bunchid[2] = 15u; +// test_packet.bunchid[3] = 1u; +// test_packet.bunchid[4] = 32u; +// test_packet.bunchid[5] = 251u; +// test_packet.bunchid[6] = 18u; +// test_packet.bunchid[7] = 240u; - int index = 0; - char *packetData = reinterpret_cast(&test_packet); - uint32_t dynamicRange{0}; - bool oddStartingPacket{0}; - uint64_t frameNumber{0}; - uint32_t packetNumber{0}; - uint32_t subFrameNumber{0}; - uint64_t bunchId{0}; +// int index = 0; +// char *packetData = reinterpret_cast(&test_packet); +// uint32_t dynamicRange{0}; +// bool oddStartingPacket{0}; +// uint64_t frameNumber{0}; +// uint32_t packetNumber{0}; +// uint32_t subFrameNumber{0}; +// uint64_t bunchId{0}; - data.GetHeaderInfo(index, packetData, dynamicRange, oddStartingPacket, - frameNumber, packetNumber, subFrameNumber, bunchId); +// data.GetHeaderInfo(index, packetData, dynamicRange, oddStartingPacket, +// frameNumber, packetNumber, subFrameNumber, bunchId); - CHECK(packetNumber == 53); - CHECK(frameNumber == 0x5b0f20); - CHECK(bunchId == 0xf012fb20010f195b); - CHECK(subFrameNumber == -1); -} +// CHECK(packetNumber == 53); +// CHECK(frameNumber == 0x5b0f20); +// CHECK(bunchId == 0xf012fb20010f195b); +// CHECK(subFrameNumber == -1); +// } TEST_CASE("Parse header gotthard data", "[receiver]") { GotthardData data; diff --git a/slsSupportLib/tests/test-CmdLineParser.cpp b/slsSupportLib/tests/test-CmdLineParser.cpp index 4e8ef67e8..144938c96 100755 --- a/slsSupportLib/tests/test-CmdLineParser.cpp +++ b/slsSupportLib/tests/test-CmdLineParser.cpp @@ -2,6 +2,8 @@ #include "catch.hpp" #include #include + + // tests to add // help for all docs // command for all depreciated commands diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a98ca51f6..62f3fe847 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -38,12 +38,11 @@ if (SLS_USE_RECEIVER) ) endif (SLS_USE_RECEIVER) + set_target_properties(tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) - - include(CTest) include(Catch) catch_discover_tests(tests)