comparison tests/test-utils.sh @ 101:e6cdee24d6c3

Improve exit handling when we have a server background process. Arrange the exit to kill off the most recently started background process, if we have at least one such.
author mas01cr
date Thu, 04 Oct 2007 10:17:33 +0000
parents 6066d75a6d39
children 94502600a049
comparison
equal deleted inserted replaced
100:3720f5a78f6e 101:e6cdee24d6c3
1 # no shebang line: this file should be sourced by run-test.sh files 1 # no shebang line: this file should be sourced by run-test.sh files
2
3 set -E
2 4
3 trap "exit 1" ERR 5 trap "exit 1" ERR
4 6
5 if [ -z ${AUDIODB} ]; then 7 if [ -z ${AUDIODB} ]; then
6 AUDIODB=../../audioDB 8 AUDIODB=../../audioDB
51 # Web services utilities 53 # Web services utilities
52 start_server() { 54 start_server() {
53 $1 -s $2 & 55 $1 -s $2 &
54 # HACK: deal with race on process creation 56 # HACK: deal with race on process creation
55 sleep 1 57 sleep 1
58 trap 'kill $!; exit 1' ERR
56 } 59 }
57 60
58 stop_server() { 61 stop_server() {
59 grep ${AUDIODB} /proc/$1/cmdline > /dev/null 62 grep ${AUDIODB} /proc/$1/cmdline > /dev/null
60 kill $1 63 kill $1