From 30c0e861094d0058ac589dddb2cf83bb32d09a83 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Sun, 18 Dec 2016 16:42:50 +0300 Subject: [PATCH] dcop/tests: run dcop tests in a safer manner Signed-off-by: Alexander Golubev (cherry picked from commit f2d8e88f099f908075d3d7b166fdb40d9be6c1c5) --- dcop/tests/CMakeLists.txt | 1 + dcop/tests/generate.pl | 3 ++- dcop/tests/run-tests.sh | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dcop/tests/CMakeLists.txt b/dcop/tests/CMakeLists.txt index 3cdb3f7b4..4530db268 100644 --- a/dcop/tests/CMakeLists.txt +++ b/dcop/tests/CMakeLists.txt @@ -38,6 +38,7 @@ add_test( NAME "dcop/dcop-tests" COMMAND sh -x "${CMAKE_CURRENT_SOURCE_DIR}/run-tests.sh" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ) +set_tests_properties( dcop/dcop-tests PROPERTIES TIMEOUT 30) ##### test.h and files ########################## diff --git a/dcop/tests/generate.pl b/dcop/tests/generate.pl index 9ef1f13fc..e7e8d4fd6 100755 --- a/dcop/tests/generate.pl +++ b/dcop/tests/generate.pl @@ -11,7 +11,8 @@ my $OBJECT_NAME = 'TestInterface'; sub shell_header { - print SHELL "TEST_APP=\`$DCOP 'TestApp-*'\`\n"; + print SHELL "TEST_APP=\"\${DCOP_TEST_PID:+TestApp-\$DCOP_TEST_PID\}\"\n" . + "TEST_APP=\"\${TEST_APP:-\$($DCOP 'TestApp-*')}\"\n"; } sub shell_footer { print SHELL "$DCOP $TEST_APP 'MainApplication-Interface' quit"; diff --git a/dcop/tests/run-tests.sh b/dcop/tests/run-tests.sh index 1645b0696..2dbc55062 100644 --- a/dcop/tests/run-tests.sh +++ b/dcop/tests/run-tests.sh @@ -10,10 +10,13 @@ DCOP_SERVER_PID=$! die() { kill $DCOP_SERVER_PID + [ -n $DCOP_TEST_PID ] && kill $DCOP_TEST_PID echo "$1" exit 1; } +trap 'die "The script interrupted by user"' 2 15 + echo '* Running batch mode' ./dcop_test --batch >batch.stdout || die "Failed to run dcop_test" @@ -21,10 +24,16 @@ echo -n '* Starting test app ' ./dcop_test >shell.stdout & DCOP_TEST_PID=$! +cnt=0 while ! ../client/dcop | grep -q "TestApp-$DCOP_TEST_PID"; do echo -n '.' - sleep 2 + cnt=$((cnt+1)) + if [ "$cnt" -gt 15 ] ; then + kill "$DCOP_TEST_PID" + die "dcop_test seems to hanged up" + fi kill -0 "$DCOP_TEST_PID" || die "dcop_test died unexpectadly" + sleep 1 done echo ' started'