dcop/tests: run dcop tests in a safer manner

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit f2d8e88f09)
v3.5.13-sru
Alexander Golubev 8 years ago committed by Slávek Banko
parent 8e0f94f7d9
commit 30c0e86109

@ -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 ##########################

@ -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";

@ -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'

Loading…
Cancel
Save