test_scalarproduct.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # compute a simple scalar product
  3. # payload for this test:
  4. INPUTALICE="-k CCC -e 'AB,10;RO,3;FL,3;LOL,-1;'"
  5. INPUTBOB="-k CCC -e 'BC,-20000;RO,1000;FL,100;LOL,24;'"
  6. # necessary to make the testing prefix deterministic, so we can access the config files
  7. PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
  8. # where can we find the peers config files?
  9. CFGALICE="-c $PREFIX/0/config"
  10. CFGBOB="-c $PREFIX/1/config"
  11. # launch two peers in line topology non-interactively
  12. #
  13. # interactive mode would terminate the test immediately
  14. # because the rest of the script is already in stdin,
  15. # thus redirecting stdin does not suffice)
  16. #GNUNET_LOG='scalarproduct;;;;DEBUG'
  17. GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 &
  18. PID=$!
  19. # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe
  20. sleep 5
  21. # get bob's peer ID, necessary for alice
  22. PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB`
  23. #GNUNET_LOG=';;;;DEBUG'
  24. gnunet-scalarproduct $CFGBOB $INPUTBOB &
  25. GNUNET_LOG=';;;;DEBUG'
  26. RESULT=`gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB`
  27. # terminate the testbed
  28. kill $PID
  29. EXPECTED="0CCC"
  30. if [ "$RESULT" == "$EXPECTED" ]
  31. then
  32. echo "OK"
  33. exit 0
  34. else
  35. echo "Result $RESULT NOTOK"
  36. exit 1
  37. fi