diff options
Diffstat (limited to 'src/service/dht/test_dht_tools.sh')
-rwxr-xr-x | src/service/dht/test_dht_tools.sh | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/service/dht/test_dht_tools.sh b/src/service/dht/test_dht_tools.sh new file mode 100755 index 000000000..462866f87 --- /dev/null +++ b/src/service/dht/test_dht_tools.sh | |||
@@ -0,0 +1,65 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | |||
4 | GNUNET_TMP="$(gnunet-config -f -s PATHS -o GNUNET_TMP)" | ||
5 | out=`mktemp $GNUNET_TMP/test-gnunet-dht-logXXXXXXXX` | ||
6 | tempcfg=`mktemp $GNUNET_TMP/test-dht-tools.XXXXXXXX` | ||
7 | checkout="check.out" | ||
8 | armexe="gnunet-arm -c $tempcfg " | ||
9 | putexe="gnunet-dht-put -c $tempcfg " | ||
10 | getexe="gnunet-dht-get -c $tempcfg " | ||
11 | peerinfo="gnunet-peerinfo -c $tempcfg -sq" | ||
12 | stop_arm() | ||
13 | { | ||
14 | if ! $armexe $DEBUG -e -d > $out ; then | ||
15 | echo "FAIL: error running $armexe" | ||
16 | echo "Command output was:" | ||
17 | cat $out | ||
18 | rm -f $out $tempcfg | ||
19 | exit 1 | ||
20 | fi | ||
21 | rm -f $out $tempcfg | ||
22 | } | ||
23 | |||
24 | cp test_dht_tools.conf $tempcfg | ||
25 | |||
26 | echo -n "TEST: Starting ARM..." | ||
27 | if ! $armexe $DEBUG -s > $out ; then | ||
28 | echo "FAIL: error running $armexe" | ||
29 | echo "Command output was:" | ||
30 | cat $out | ||
31 | stop_arm | ||
32 | exit 1 | ||
33 | fi | ||
34 | echo "PASS" | ||
35 | |||
36 | echo -n "TEST: Testing put..." | ||
37 | if ! $putexe -k testkey -d testdata -t 8 > $out ; then | ||
38 | echo "FAIL: error running $putexe" | ||
39 | echo "Command output was:" | ||
40 | cat $out | ||
41 | stop_arm | ||
42 | exit 1 | ||
43 | fi | ||
44 | echo "PASS" | ||
45 | |||
46 | echo -n "TEST: Testing get..." | ||
47 | echo "Result 0, type 8:" > $checkout | ||
48 | echo "testdata" >> $checkout | ||
49 | |||
50 | if ! $getexe -k testkey -T 100ms -t 8 > $out ; then | ||
51 | echo "FAIL: error running $putexe" | ||
52 | echo "Command output was:" | ||
53 | cat $out | ||
54 | stop_arm | ||
55 | exit 1 | ||
56 | fi | ||
57 | |||
58 | if ! diff --strip-trailing-cr -q $out $checkout ; then | ||
59 | echo "FAIL: $out and $checkout differ:" | ||
60 | diff --strip-trailing-cr $out $checkout | ||
61 | stop_arm | ||
62 | exit 1 | ||
63 | fi | ||
64 | echo "PASS" | ||
65 | stop_arm | ||