aboutsummaryrefslogtreecommitdiff
path: root/src/contrib/service/scalarproduct/test_scalarproduct_negativezero.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/contrib/service/scalarproduct/test_scalarproduct_negativezero.sh')
-rwxr-xr-xsrc/contrib/service/scalarproduct/test_scalarproduct_negativezero.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/contrib/service/scalarproduct/test_scalarproduct_negativezero.sh b/src/contrib/service/scalarproduct/test_scalarproduct_negativezero.sh
new file mode 100755
index 000000000..6f80b2ea2
--- /dev/null
+++ b/src/contrib/service/scalarproduct/test_scalarproduct_negativezero.sh
@@ -0,0 +1,46 @@
1#!/bin/bash
2# compute a simple scalar product
3# payload for this test:
4INPUTALICE="-k CCC -e 'AB,10;RO,-1;FL,1;LOL,1;'"
5INPUTBOB="-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
8PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
9
10# where can we find the peers config files?
11CFGALICE="-c $PREFIX/0/config"
12CFGBOB="-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'
20GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 &
21PID=$!
22# sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe
23sleep 5
24
25which timeout >/dev/null 2>&1 && DO_TIMEOUT="timeout 15"
26
27# get bob's peer ID, necessary for alice
28PEERIDBOB=`${DO_TIMEOUT} gnunet-peerinfo -qs $CFGBOB`
29
30#GNUNET_LOG=';;;;DEBUG'
31${DO_TIMEOUT} gnunet-scalarproduct $CFGBOB $INPUTBOB &
32#GNUNET_LOG=';;;;DEBUG'
33RESULT=`${DO_TIMEOUT} gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB`
34
35# terminate the testbed
36kill $PID
37
38EXPECTED="00"
39if [ "$RESULT" = "$EXPECTED" ]
40then
41 echo "OK"
42 exit 0
43else
44 echo "Result $RESULT NOTOK"
45 exit 1
46fi