add timeouts to test
[oweals/gnunet.git] / src / scalarproduct / test_scalarproduct_negativezero.sh
1 #!/bin/bash
2 # compute a simple scalar product
3 # payload for this test:
4 INPUTALICE="-k CCC -e 'AB,10;RO,-1;FL,1;LOL,1;'"
5 INPUTBOB="-k CCC -e 'BC,20;RO,1;FL,1;LOL,0;'"
6
7 # necessary to make the testing prefix deterministic, so we can access the config files
8 PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
9
10 # where can we find the peers config files?
11 CFGALICE="-c $PREFIX/0/config"
12 CFGBOB="-c $PREFIX/1/config"
13
14 # launch two peers in line topology non-interactively
15 #
16 # interactive mode would terminate the test immediately
17 # because the rest of the script is already in stdin,
18 # thus redirecting stdin does not suffice)
19 # GNUNET_LOG='scalarproduct;;;;DEBUG'
20 GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 &
21 PID=$!
22 # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe
23 sleep 5
24
25 # get bob's peer ID, necessary for alice
26 PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB`
27
28 #GNUNET_LOG=';;;;DEBUG'
29 gnunet-scalarproduct $CFGBOB $INPUTBOB &
30 #GNUNET_LOG=';;;;DEBUG'
31 RESULT=`gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB`
32
33 # terminate the testbed
34 kill $PID
35
36 EXPECTED="00"
37 if [ "$RESULT" == "$EXPECTED" ]
38 then
39         echo "OK"
40         exit 0
41 else
42         echo "Result $RESULT NOTOK"
43         exit 1
44 fi