diff --git a/unitTesting/CMakeLists.txt b/unitTesting/CMakeLists.txt index eca30b2584efd2cc5d643ae5db42645ee0d47b44..8c7d08250e71b907626f2efc9312638e8c86319b 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 0000000000000000000000000000000000000000..87d51629625b977cdb0befd14000c126f56668d7 --- /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 0000000000000000000000000000000000000000..7bf749deec4cf7ff01d2d58e76f8c662e51bb0b4 --- /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 +