From dc1a467d22a54b111f868624e1fb69405e7606b7 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 10 Oct 2019 08:43:34 +0200 Subject: [PATCH] Add executable to test GetData --- tests/CMakeLists.txt | 12 +++++++++--- tests/testGetData.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 tests/testGetData.c diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 905da56..e8aac93 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,12 +12,18 @@ file( ./* ) -ADD_EXECUTABLE (testParallel ${source_files} ) - +ADD_EXECUTABLE (testParallel testParallel.c ) target_link_libraries( testParallel ${CMAKE_THREAD_LIBS_INIT} ${DDCLIENTLIBRARY} ) -install (TARGETS testParallel DESTINATION tests) +ADD_EXECUTABLE (testGetData testGetData.c ) +target_link_libraries( + testGetData + ${CMAKE_THREAD_LIBS_INIT} + ${DDCLIENTLIBRARY} +) + +install (TARGETS testParallel testGetData DESTINATION tests) diff --git a/tests/testGetData.c b/tests/testGetData.c new file mode 100644 index 0000000..e7a8c43 --- /dev/null +++ b/tests/testGetData.c @@ -0,0 +1,82 @@ +/*============================================================= + * testGetData.c + * Test data collection for a a given parameter (hard coded) + * Oct 2019, V.1.0, Renard + *=============================================================*/ +#include +#include +#include +#include +#include +#include +#include + +#define DATA_VI "mes:mag:orb\0" +#define DATA_STARTTIME "2012000000000000\0" +#define DATA_TIMEINT "0000010000000000\0" +#define DATA_TIMENAME "Time\0" +#define DATA_PARAMNAME "B_MSO\0" + + +/* + * Main + */ +int main() +{ + char ViName[100]; + char StartTime[17]; + char TimeInt[17]; + char ParamName[100]; + char TimeName[100]; + + strcpy(ViName,DATA_VI); + strcpy(StartTime, DATA_STARTTIME); + strcpy(TimeInt, DATA_TIMEINT); + strcpy(ParamName, DATA_PARAMNAME); + strcpy(TimeName, DATA_TIMENAME); + + char* ParNames[2] = {TimeName, ParamName}; + + int ID, error; + + double RealTime; + DD_data_t *data; + + ID = DD_SetVariable(ViName); + if(ID < 0) + { + error = DD_Close(99); + printf("[ERROR]\n"); + return 0; + } + + error = DD_SetTimeInfo(ID, StartTime, &RealTime); + if(error < 0) + { + error = DD_Close(ID); + printf("[ERROR]\n"); + return 0; + } + + do + { + error = DD_GetMultiData(ID, 2, ParNames, TimeInt, &data, 1); + if(error < 0) + { + error = DD_Close(ID); + printf("[ERROR]\n"); + return 0; + } + if(error == MOREDELAY) + { + error = MOREDATA; + } + } + while(error == MOREDATA); + + error = DD_Close(ID); + + printf("[SUCESS]\n"); + + return 1; +} -- libgit2 0.21.2