Check the return value of update_checksum().
[pwmd.git] / tests / common.sh
blob761736ffb9d891f85292a09f28f3c32380d64502
1 on_exit() {
2 if [ $PID ]; then
3 kill $PID
4 fi
6 if [ $USE_AGENT ]; then
7 local agent_pid=`echo GETINFO pid | gpg-connect-agent -S "$WDIR"/S.gpg-agent | sed -ne '1p' | cut -b 2-`
8 if [ $? -eq 0 ]; then
9 kill $agent_pid
11 unset agent_pid
14 rm -f config
17 wait_for_socket() {
18 local pid="$1"
19 local socket="$2"
21 until [ -e $socket ]; do
22 echo "waiting for socket '$socket' ..."
23 if [ $pid != 0 ]; then
24 kill -0 $PID || break;
26 sleep 1
27 done
29 unset pid
30 unset socket
33 launch_pwmd () {
34 $PWMD --homedir $WDIR -n $@ > /dev/null &
35 PID=$!
36 wait_for_socket $PID socket
39 test_success() {
40 echo "All tests in $0 succeeded."
43 begin_test() {
44 echo ""
45 echo "Starting test $0 ..."
46 echo ""
49 set -e
51 PWMD="../src/pwmd"
52 WDIR="`/bin/pwd`"
53 PWMC_ARGS="--url $WDIR/socket --no-status"
54 PID=
55 trap on_exit EXIT
57 if [ $USE_AGENT ]; then
58 eval `gpg-agent --homedir $WDIR --sh --daemon`
59 wait_for_socket 0 "S.gpg-agent"