From: Michal MalĂ˝ Date: Tue, 10 Mar 2015 21:22:00 +0000 (+0100) Subject: Add simple testing tool and build it on demand X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=7af4cc23a867dff402504d289af10f2e5de83ddc;p=libHPCS.git Add simple testing tool and build it on demand --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6146e81..c1595de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,3 +17,10 @@ set(libHPCS_SRCS add_library(HPCS SHARED ${libHPCS_SRCS}) +if (${BuildTestTool}) + set(libHPCS_test_SRCS + test_tool.c) + + add_executable(test_tool ${libHPCS_test_SRCS}) + target_link_libraries(test_tool HPCS) +endif() diff --git a/test_tool.c b/test_tool.c new file mode 100644 index 0000000..eebe9d9 --- /dev/null +++ b/test_tool.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include "libhpcs.h" + +int main(int argc, char** argv) +{ + struct HPCS_MeasuredData* mdata; + enum HPCS_RetCode hret; + size_t di; + + if (argc < 2) { + printf("No filename specified\n"); + return EXIT_FAILURE; + } + + mdata = hpcs_alloc(); + if (mdata == NULL) { + printf("Out of memory\n"); + return EXIT_FAILURE; + } + + hret = hpcs_read_file(argv[1], mdata); + if (hret != HPCS_OK) { + printf("Cannot parse file: %s\n", hpcs_error_to_string(hret)); + return EXIT_FAILURE; + } + + for (di = 0; di < mdata->data_count; di++) + printf("Time: %.17lg, Value: %.17lg\n", mdata->data[di].time, mdata->data[di].value); + + hpcs_free(mdata); + + return EXIT_SUCCESS; +}