continue to fix extract result
[oweals/gnunet.git] / src / dht / test_dht_tools.sh
1 #!/bin/sh
2
3 out=`mktemp /tmp/test-gnunet-dht-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     rm -f $out $tempcfg
17     exit 1
18   fi
19   rm -f $out $tempcfg
20 }
21
22 cp test_dht_api_peer1.conf $tempcfg
23
24 echo -n "TEST: Generating hostkey..."
25 if ! $peerinfo > $out ; then
26   echo "FAIL: error running $peerinfo"
27   echo "Command output was:"
28   cat $out 
29   exit 1
30 fi
31 echo "PASS"
32
33 echo -n "TEST: Starting ARM..."
34 if ! $armexe $DEBUG -s > $out ; then
35   echo "FAIL: error running $armexe"
36   echo "Command output was:"
37   cat $out
38   stop_arm
39   exit 1
40 fi
41 echo "PASS"
42 sleep 1
43
44 echo -n "TEST: Testing put..."
45 if ! $putexe -k testkey -d testdata -t 8 > $out ; then
46   echo "FAIL: error running $putexe"
47   echo "Command output was:"
48   cat $out
49   stop_arm
50   exit 1
51 fi
52 echo "PASS"
53 sleep 1
54
55 echo -n "TEST: Testing get..."
56 echo "Result 0, type 8:" > $checkout
57 echo "testdata" >> $checkout
58
59 if ! $getexe -k testkey -T 5 -t 8 > $out ; then
60   echo "FAIL: error running $putexe"
61   echo "Command output was:"
62   cat $out
63   stop_arm
64   exit 1
65 fi
66
67 if ! diff --strip-trailing-cr -q $out $checkout ; then
68   echo "FAIL: $out and $checkout differ"
69   stop_arm
70   exit 1
71 fi
72 echo "PASS"
73 stop_arm