aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct/test_scalarproduct.sh
blob: 5f335db3c0d4b82f8ba8a006040178ecc6f9e021 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# compute a simple scalar product
# payload for this test:
INPUTALICE="-k AAAA -e 3,3,-1"
INPUTBOB="-k AAAA -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=$!

echo $PID
read
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`
RESULT=`printf "%X\n" "0x$RESULT"`

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="CCC"
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