fix for failure of dht testcase due to long wait for hostkey generation. testcase...
[oweals/gnunet.git] / src / dht / test_dht_tools.sh
1 #!/bin/sh
2
3 out=`mktemp /tmp/test-gnunet-arm-logXXXXXXXX`
4 tempcfg=`mktemp /tmp/test_dht_api_peer1.XXXXXXXX`
5 checkout="check.out"
6 armexe="gnunet-arm -c $tempcfg "
7 putexe="gnunet-dht-put -c $tempcfg "
8 getexe="gnunet-dht-get -c $tempcfg "
9 peerinfo="gnunet-peerinfo -c $tempcfg -sq"
10 stop_arm()
11 {
12   if ! $armexe $DEBUG -e -d > $out ; then
13     echo "FAIL: error running $armexe"
14     echo "Command output was:"
15     cat $out
16     exit 1
17   fi
18 }
19
20 cp test_dht_api_peer1.conf $tempcfg
21
22 echo -n "TEST: Generating hostkey..."
23 if ! $peerinfo > $out ; then
24   echo "FAIL: error running $peerinfo"
25   echo "Command output was:"
26   cat $out 
27   exit 1
28 fi
29
30 echo -n "TEST: Starting ARM..."
31 if ! $armexe $DEBUG -s > $out ; then
32   echo "FAIL: error running $armexe"
33   echo "Command output was:"
34   cat $out
35   stop_arm
36   exit 1
37 fi
38 echo "PASS"
39 sleep 1
40
41 echo -n "TEST: Testing put..."
42 if ! $putexe -k testkey -d testdata > $out ; then
43   echo "FAIL: error running $putexe"
44   echo "Command output was:"
45   cat $out
46   stop_arm
47   exit 1
48 fi
49 echo "PASS"
50 sleep 1
51
52 echo -n "TEST: Testing get..."
53 echo "Result 0, type 0:" > $checkout
54 echo "testdata" >> $checkout
55
56 if ! $getexe -k testkey -T 1 > $out ; then
57   echo "FAIL: error running $putexe"
58   echo "Command output was:"
59   cat $out
60   stop_arm
61   exit 1
62 fi
63 if ! diff -q $out $checkout ; then
64   echo "FAIL: $out and $checkout differ"
65   stop_arm
66   exit 1
67 fi
68 echo "PASS"
69
70 stop_arm