finished SP-testcase
[oweals/gnunet.git] / src / scalarproduct / test_scalarproduct.sh
1 #!/bin/bash
2 # compute a simple scalar product
3 # payload for this test:
4 INPUTALICE="-k AAAA -e 10,10,10"
5 INPUTBOB="-k AAAA -e 10,10,10"
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 # log at which loglevel?
14 LOGLEVEL=DEBUG
15
16 echo start
17 # launch two peers in line topology non-interactively
18 #
19 # interactive mode would terminate the test immediately 
20 # because the rest of the script is already in stdin, 
21 # thus redirecting stdin does not suffice)
22 GNUNET_LOG="scalarproduct;;;;$LOGLEVEL" GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 2>service.log &
23 sleep 2
24 echo tesbed up
25
26 # get bob's peer ID, necessary for alice
27 PEERIDBOB=`gnunet-peerinfo -qs $CFGB`
28 echo peerinfo receivd
29
30 GNUNET_LOG="scalarproduct;;;;$LOGLEVEL" gnunet-scalarproduct $CFGBOB $INPUTBOB 2>bob.log &
31 echo bob started
32 GNUNET_LOG="scalarproduct;;;;$LOGLEVEL" gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB 2>alice.log
33 echo alice returned
34
35 # termiante the testbed
36 kill $( pgrep -P $$ | tr '\n' ' ' )
37 echo killed testbed
38
39 EXPECTED="12C"
40 if [ "$RESULT" == "$EXPECTED" ]
41 then
42   echo "OK"
43   exit 0
44 else
45   echo "Result $RESULT NOTOK"
46   exit 1
47 fi
48