porting
[oweals/gnunet.git] / src / scalarproduct / test_scalarproduct_negative.sh
index 58a02998de2b15a5a969b996a1e629c1ab53056f..cbeb1b9fd1690963f2b130a6387c48ff14150f69 100755 (executable)
@@ -1,8 +1,8 @@
 #!/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"
+INPUTALICE="-k CCC -e 'AB,10;RO,-3;FL,-3;LOL,1;'"
+INPUTBOB="-k CCC -e 'BC,-20000;RO,1000;FL,100;LOL,24;'"
 
 # necessary to make the testing prefix deterministic, so we can access the config files
 PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
@@ -11,24 +11,29 @@ PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
 CFGALICE="-c $PREFIX/0/config"
 CFGBOB="-c $PREFIX/1/config"
 
+which timeout &> /dev/null && DO_TIMEOUT="timeout 15"
+
 # 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, 
+# 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 &
+#GNUNET_LOG='scalarproduct;;;;DEBUG'
+GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 &
 PID=$!
 # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe
 sleep 5
 
 # get bob's peer ID, necessary for alice
-PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB`
+PEERIDBOB=`${DO_TIMEOUT} gnunet-peerinfo -qs $CFGBOB`
 
-GNUNET_LOG=';;;;DEBUG' gnunet-scalarproduct $CFGBOB $INPUTBOB &
-RESULT=`GNUNET_LOG=';;;;DEBUG' gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB`
+#GNUNET_LOG=';;;;DEBUG'
+${DO_TIMEOUT} gnunet-scalarproduct $CFGBOB $INPUTBOB &
+#RESULT=`GNUNET_LOG=';;;;DEBUG'
+RESULT=`${DO_TIMEOUT} gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB`
 
 # terminate the testbed
-kill $PID 
+kill $PID
 
 EXPECTED="-0CCC"
 if [ "$RESULT" == "$EXPECTED" ]
@@ -36,6 +41,6 @@ then
        echo "OK"
         exit 0
 else
-       echo "Result $RESULT NOTOK"
+       echo "Result $RESULT, expected $EXPECTED NOTOK"
         exit 1
 fi