diff options
Diffstat (limited to 'src/contrib/service/scalarproduct/test_scalarproduct_negative.sh')
-rwxr-xr-x | src/contrib/service/scalarproduct/test_scalarproduct_negative.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/contrib/service/scalarproduct/test_scalarproduct_negative.sh b/src/contrib/service/scalarproduct/test_scalarproduct_negative.sh new file mode 100755 index 000000000..459406836 --- /dev/null +++ b/src/contrib/service/scalarproduct/test_scalarproduct_negative.sh | |||
@@ -0,0 +1,49 @@ | |||
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 | |||
7 | # necessary to make the testing prefix deterministic, so we can access the config files | ||
8 | unset XDG_DATA_HOME | ||
9 | unset XDG_CONFIG_HOME | ||
10 | |||
11 | PREFIX=/tmp/test-scalarproduct`date +%H%M%S` | ||
12 | |||
13 | # where can we find the peers config files? | ||
14 | CFGALICE="-c $PREFIX/0/config" | ||
15 | CFGBOB="-c $PREFIX/1/config" | ||
16 | |||
17 | which timeout >/dev/null 2>&1 && DO_TIMEOUT="timeout 15" | ||
18 | |||
19 | # launch two peers in line topology non-interactively | ||
20 | # | ||
21 | # interactive mode would terminate the test immediately | ||
22 | # because the rest of the script is already in stdin, | ||
23 | # thus redirecting stdin does not suffice) | ||
24 | #GNUNET_LOG='scalarproduct;;;;DEBUG' | ||
25 | GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 & | ||
26 | PID=$! | ||
27 | # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe | ||
28 | sleep 5 | ||
29 | |||
30 | # get bob's peer ID, necessary for alice | ||
31 | PEERIDBOB=`${DO_TIMEOUT} gnunet-peerinfo -qs $CFGBOB` | ||
32 | |||
33 | #GNUNET_LOG=';;;;DEBUG' | ||
34 | ${DO_TIMEOUT} gnunet-scalarproduct $CFGBOB $INPUTBOB & | ||
35 | #RESULT=`GNUNET_LOG=';;;;DEBUG' | ||
36 | RESULT=`${DO_TIMEOUT} gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB` | ||
37 | |||
38 | # terminate the testbed | ||
39 | kill $PID | ||
40 | |||
41 | EXPECTED="-0CCC" | ||
42 | if [ "$RESULT" = "$EXPECTED" ] | ||
43 | then | ||
44 | echo "OK" | ||
45 | exit 0 | ||
46 | else | ||
47 | echo "Result $RESULT, expected $EXPECTED NOTOK" | ||
48 | exit 1 | ||
49 | fi | ||