summaryrefslogtreecommitdiff
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)
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 @@
+#!/bin/bash
+# compute a simple scalar product
+# payload for this test:
+INPUTALICE="-k CCC -e -3,-3,1"
+INPUTBOB="-k CCC -e 1000,100,24"
+
+# necessary to make the testing prefix deterministic, so we can access the config files
+PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
+
+# where can we find the peers config files?
+CFGALICE="-c $PREFIX/0/config"
+CFGBOB="-c $PREFIX/1/config"
+
+# launch two peers in line topology non-interactively
+#
+# interactive mode would terminate the test immediately
+# because the rest of the script is already in stdin,
+# thus redirecting stdin does not suffice)
+GNUNET_LOG='scalarproduct;;;;DEBUG' GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 2>service.log &
+PID=$!
+sleep 5
+
+# get bob's peer ID, necessary for alice
+PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB`
+
+GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGBOB $INPUTBOB 2>bob.log &
+RESULT=`GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB 2>alice.log`
+
+cat alice.log bob.log service.log >> test_scalarproduct.log
+rm -f alice.log bob.log service.log
+ISSUES=$((`grep scalarproduct test_scalarproduct.log | grep -c ERROR` + `grep scalarproduct test_scalarproduct.log | grep -c WARNING`))
+
+# terminate the testbed
+kill $PID
+
+EXPECTED="-0CCC"
+if [ "$ISSUES" -eq "0" ]
+then
+ if [ "$RESULT" == "$EXPECTED" ]
+ then
+ echo "OK"
+ rm -f test_scalarproduct.log
+ exit 0
+ fi
+else
+ echo "Result $RESULT NOTOK, see $PWD/test_scalarproduct.log for details"
+ exit 1
+fi
+