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