#!/bin/bash
+# compute a simple scalar product
-CFGA="-c ./test_scalarproduct_alice.conf"
-CFGB="-c ./test_scalarproduct_bob.conf"
- #can't use ` directly
-SESSIONDATA="-k AAAA -e 10,10,10"
-EXPECTED="2C0"
+#necessary to make the testing prefix deterministic, so we can access the config files
+PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
-gnunet-arm -s $CFGA
-sleep 2
-gnunet-arm -s $CFGB
-sleep 2
+#where can we find the peers config files?
+CFGALICE="-c $PREFIX/0/config"
+CFGBOB="-c $PREFIX/1/config"
-IDB=`gnunet-peerinfo -s $CFGB | awk -F "\x60" '{print $2}' | awk -F "'" '{print $1}'`
+#log at which loglevel?
+LOG="-L ERROR"
-gnunet-scalarproduct $CFGB $SESSIONDATA
+#launch two peers in line topology
+GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler $LOG -c test_scalarproduct.conf -p 2 2>gnunet_error.log &
+sleep 5
-RESULT=`gnunet-scalarproduct $CFGA $SESSIONDATA -p $IDB`
+#get bob's peer ID, necessary for alice
+PEERIDBOB=`gnunet-peerinfo -qs $CFGB`
-gnunet-arm -e $CFGA &
-gnunet-arm -e $CFGB &
+#payload for this test on both sides
+INPUTALICE="-k AAAA -e 10,10,10"
+INPUTBOB="-k AAAA -e 10,10,10"
+echo "gnunet-scalarproduct $LOG $CFGBOB $INPUTBOB &"
+echo "gnunet-scalarproduct $LOG $CFGALICE $INPUTALICE -p $PEERIDBOB -L ERROR"
+gnunet-scalarproduct $LOG $CFGBOB $INPUTBOB 2>bob_error.log &
+RESULT=`gnunet-scalarproduct $LOG $CFGALICE $INPUTALICE -p $PEERIDBOB 2>alice_error.log`
+
+EXPECTED="12C"
if [ "$RESULT" == "$EXPECTED" ]
then
echo "OK"