fix
[oweals/gnunet.git] / src / arm / test_gnunet_arm.sh
1 #!/bin/sh
2
3 rm -rf /tmp/test-gnunetd-arm/
4 exe="./gnunet-arm -c test_arm_api_data.conf"
5 base=/tmp/gnunet-test-arm
6 out=`mktemp /tmp/test-gnunetd-arm-logXXXXXXXX`
7 #DEBUG="-L DEBUG"
8
9
10 # ----------------------------------------------------------------------------------
11 echo -n "TEST: Bad argument checking... "
12
13 if $exe -x 2> /dev/null; then
14   echo "FAIL: error running $exe"
15   exit 1
16 fi
17 echo "PASS"
18
19 # ----------------------------------------------------------------------------------
20 echo -n "TEST: Start ARM..."
21
22 if ! $exe $DEBUG -s > $out ; then
23   echo "FAIL: error running $exe"
24   echo "Command output was:"
25   cat $out
26   exit 1
27 fi
28 echo "PASS"
29 sleep 1
30
31 # ----------------------------------------------------------------------------------
32 echo -n "TEST: Start another service... "
33
34 if ! $exe $DEBUG -i resolver > $out ; then
35   echo "FAIL: error running $exe"
36   echo "Command output was:"
37   cat $out
38   kill %%
39   exit 1
40 fi
41 sleep 1
42 echo "PASS"
43
44 # ----------------------------------------------------------------------------------
45 echo -n "TEST: Test -t on running service... "
46 if ! $exe $DEBUG -t resolver > $base.out; then
47     echo "FAIL: error running $exe"
48     exit 1
49 fi
50 LINES=`cat $base.out | grep resolver | grep not | wc -l`
51 if test $LINES -ne 0; then
52   echo "FAIL: unexpected output:"
53   cat $base.out
54   $exe -e
55   exit 1
56 fi
57 LINES=`cat $base.out | grep resolver | grep -v not | wc -l`
58 if test $LINES -ne 1; then
59   echo "FAIL: unexpected output"
60   cat $base.out
61   $exe -e
62   exit 1
63 fi
64 echo "PASS"
65
66 # ----------------------------------------------------------------------------------
67 echo -n "TEST: Stop a service... "
68
69 if ! $exe $DEBUG -k resolver > $out; then
70   echo "FAIL: error running $exe"
71   $exe -e
72   exit 1
73 fi
74 sleep 1
75 echo "PASS"
76
77 # ----------------------------------------------------------------------------------
78 echo -n "TEST: Test -t on stopped service... "
79 if ! $exe $DEBUG -t resolver > $base.out; then
80   echo "FAIL: error running $exe"
81   cat $base.out
82   $exe -e > /dev/null
83   exit 1
84 fi
85 LINES=`cat $base.out | grep resolver | grep not | wc -l`
86 if test $LINES -ne 1; then
87   echo "FAIL: unexpected output"
88   cat $base.out 
89   $exe -e > /dev/null
90   exit 1
91 fi
92 echo "PASS"
93
94 # ----------------------------------------------------------------------------------
95 echo -n "TEST: Stop ARM... "
96
97 if ! $exe $DEBUG -e > $out; then
98   echo "FAIL: error running $exe"
99   exit 1
100 fi
101 sleep 1
102 echo "PASS"
103
104 rm -rf /tmp/test-gnunetd-arm/
105 rm -f $base.out "$out"
106