0ac7e94c03c0251b6f4bf17b53d8ed30b009f63e
[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     stop_arm
17     exit 1
18   fi
19 }
20
21 cp test_dht_api_peer1.conf $tempcfg
22
23 echo -n "TEST: Starting ARM..."
24 if ! $armexe $DEBUG -s > $out ; then
25   echo "FAIL: error running $armexe"
26   echo "Command output was:"
27   cat $out
28   stop_arm
29   exit 1
30 fi
31 echo "PASS"
32 sleep 1
33
34 echo -n "TEST: Testing put..."
35 if ! $putexe -k testkey -d testdata > $out ; then
36   echo "FAIL: error running $putexe"
37   echo "Command output was:"
38   cat $out
39   stop_arm
40   exit 1
41 fi
42 echo "PASS"
43 sleep 1
44
45 echo -n "TEST: Testing get..."
46 echo "Result 0, type 0:" > $checkout
47 echo "testdata" >> $checkout
48
49 if ! $getexe -k testkey -T 1 > $out ; then
50   echo "FAIL: error running $putexe"
51   echo "Command output was:"
52   cat $out
53   stop_arm
54   exit 1
55 fi
56 if ! diff -q $out $checkout ; then
57   echo "FAIL: $out and $checkout differ"
58   stop_arm
59   exit 1
60 fi
61 echo "PASS"
62
63 stop_arm