aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct/test_scalarproduct_negative.sh
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-10-18 15:13:59 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-10-18 15:13:59 +0000
commit96ccef162f276c2f40b09ceca59c982bbaa3709e (patch)
treea10a4fe26bfd70a9cc08359b68195a5f5d729c0c /src/scalarproduct/test_scalarproduct_negative.sh
parent8fe29d55719cb024f2e162f1f5289ded8cf91e53 (diff)
downloadgnunet-96ccef162f276c2f40b09ceca59c982bbaa3709e.tar.gz
gnunet-96ccef162f276c2f40b09ceca59c982bbaa3709e.zip
added testcase for negative scalarproducts
added testcase for negative-zero scalarproducts
Diffstat (limited to 'src/scalarproduct/test_scalarproduct_negative.sh')
-rwxr-xr-xsrc/scalarproduct/test_scalarproduct_negative.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/scalarproduct/test_scalarproduct_negative.sh b/src/scalarproduct/test_scalarproduct_negative.sh
new file mode 100755
index 000000000..27fd345cc
--- /dev/null
+++ b/src/scalarproduct/test_scalarproduct_negative.sh
@@ -0,0 +1,49 @@
1#!/bin/bash
2# compute a simple scalar product
3# payload for this test:
4INPUTALICE="-k CCC -e -3,-3,1"
5INPUTBOB="-k CCC -e 1000,100,24"
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)
19GNUNET_LOG='scalarproduct;;;;DEBUG' GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 2>service.log &
20PID=$!
21sleep 5
22
23# get bob's peer ID, necessary for alice
24PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB`
25
26GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGBOB $INPUTBOB 2>bob.log &
27RESULT=`GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB 2>alice.log`
28
29cat alice.log bob.log service.log >> test_scalarproduct.log
30rm -f alice.log bob.log service.log
31ISSUES=$((`grep scalarproduct test_scalarproduct.log | grep -c ERROR` + `grep scalarproduct test_scalarproduct.log | grep -c WARNING`))
32
33# terminate the testbed
34kill $PID
35
36EXPECTED="-0CCC"
37if [ "$ISSUES" -eq "0" ]
38then
39 if [ "$RESULT" == "$EXPECTED" ]
40 then
41 echo "OK"
42 rm -f test_scalarproduct.log
43 exit 0
44 fi
45else
46 echo "Result $RESULT NOTOK, see $PWD/test_scalarproduct.log for details"
47 exit 1
48fi
49