From 4e4d7eef13b040899a950c36cb2738361533526b Mon Sep 17 00:00:00 2001 From: Francois Keith <keith@lirmm.fr> Date: Sat, 15 Mar 2014 00:49:40 +0100 Subject: [PATCH] Add another 'unit test' for the interpreter. This unit test shows that after a given number of run of the same file, the error changes. Unfortunately, this can not be automatically verified, since the result is printed in the python error stream, and cannot be redirected. --- unitTesting/CMakeLists.txt | 13 +++++++++++-- unitTesting/interpreter-test-runfile.cc | 21 +++++++++++++++++++++ unitTesting/test_python_error.py | 9 +++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 unitTesting/interpreter-test-runfile.cc create mode 100644 unitTesting/test_python_error.py diff --git a/unitTesting/CMakeLists.txt b/unitTesting/CMakeLists.txt index eca30b2..8c7d082 100644 --- a/unitTesting/CMakeLists.txt +++ b/unitTesting/CMakeLists.txt @@ -26,10 +26,19 @@ ADD_DEFINITIONS(${DYNAMIC_GRAPH_CFLAGS}) SET(EXECUTABLE_NAME interpreter-test) - ADD_EXECUTABLE(${EXECUTABLE_NAME} interpreter-test.cc) TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} dynamic-graph-python) -TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${DYNAMIC_GRAPH_LIBRARIES} -lpthread -ldl -lutil) +ADD_TEST(${EXECUTABLE_NAME} ${EXECUTABLE_NAME}) + +## Test runfile +SET(EXECUTABLE_NAME interpreter-test-runfile) +ADD_EXECUTABLE(${EXECUTABLE_NAME} interpreter-test-runfile.cc) +TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} dynamic-graph-python) ADD_TEST(${EXECUTABLE_NAME} ${EXECUTABLE_NAME}) +ADD_CUSTOM_COMMAND(TARGET interpreter-test-runfile POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/unitTesting/test_python_error.py + ${CMAKE_BINARY_DIR}/unitTesting +) + diff --git a/unitTesting/interpreter-test-runfile.cc b/unitTesting/interpreter-test-runfile.cc new file mode 100644 index 0000000..87d5162 --- /dev/null +++ b/unitTesting/interpreter-test-runfile.cc @@ -0,0 +1,21 @@ +// The purpose of this unit test is to check the interpreter::runPythonFile method +#include "dynamic-graph/python/interpreter.hh" + +int main(int argc, char ** argv) +{ + // execute numerous time the same file. + // While running 1025, we can notice a change in the error. + // unfortunately, it can not be shown using a redirection of the streams + int numTest = 1025; + if (argc > 1) + numTest = atoi(argv[1]); + + dynamicgraph::python::Interpreter interp; + + for (int i=0; i<numTest; ++i) + { + interp.runPythonFile("test_python_error.py"); + } + + return 0; +} diff --git a/unitTesting/test_python_error.py b/unitTesting/test_python_error.py new file mode 100644 index 0000000..7bf749d --- /dev/null +++ b/unitTesting/test_python_error.py @@ -0,0 +1,9 @@ +import sys, os + +pkgConfigPath = os.environ.get("PKG_CONFIG_PATH") +if pkgConfigPath == None: + pkgConfigPath = '' +pathList = re.split(':', pkgConfigPath) + +print pathList + -- GitLab