- debug
[oweals/gnunet.git] / src / scalarproduct / test_scalarproduct.sh
index ee828e4aae4b457a342f4ebb5e5052d647bc0a5b..29f78ef9bd8a8dca53f28eba3511c6847820fa99 100755 (executable)
@@ -1,27 +1,33 @@
 #!/bin/bash
+# compute a simple scalar product
 
 #necessary to make the testing prefix deterministic, so we can access the config files
-GNUNET_TESTING_PREFIX=/tmp/test-scalarproduct1337
-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"
+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"