0154d99c7be976d42da5809f1de49162ecbe0193
[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
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: Starting ARM..."
23 if ! $armexe $DEBUG -s > $out ; then
24   echo "FAIL: error running $armexe"
25   echo "Command output was:"
26   cat $out
27   stop_arm
28   exit 1
29 fi
30 echo "PASS"
31 sleep 1
32
33 echo -n "TEST: Testing put..."
34 if ! $putexe -k testkey -d testdata > $out ; then
35   echo "FAIL: error running $putexe"
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 get..."
45 echo "Result 0, type 0:" > $checkout
46 echo "testdata" >> $checkout
47
48 if ! $getexe -k testkey -T 1 > $out ; then
49   echo "FAIL: error running $putexe"
50   echo "Command output was:"
51   cat $out
52   stop_arm
53   exit 1
54 fi
55 if ! diff -q $out $checkout ; then
56   echo "FAIL: $out and $checkout differ"
57   stop_arm
58   exit 1
59 fi
60 echo "PASS"
61
62 stop_arm