7586d78bbc9fa67235087cb1f1cac1729ab821da
[oweals/gnunet.git] / src / arm / test_gnunet_arm.sh
1 #!/bin/bash
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=/tmp/test-gnunetd-arm.log
7 #DEBUG="-L DEBUG"
8
9 # ----------------------------------------------------------------------------------
10 echo -n "TEST: Bad argument checking... "
11
12 if $exe -x 2> /dev/null; then
13   echo "FAIL: error running $exe"
14   exit 1
15 fi
16 echo "PASS"
17
18 # ----------------------------------------------------------------------------------
19 echo -n "TEST: Start ARM... "
20
21 if ! $exe $DEBUG -s > $out ; then
22   echo "FAIL: error running $exe"
23   echo "Command output was:"
24   cat $out
25   exit 1
26 fi
27 LINES=`ps ax | grep gnunet-service-arm | grep -v grep | wc -l`
28 if test $LINES -eq 0; then
29   echo "FAIL: found $LINES gnunet-service-arm processes"
30   echo "Command output was:"
31   cat $out
32   exit 1
33 fi
34 echo "PASS"
35
36 # ----------------------------------------------------------------------------------
37 echo -n "TEST: Start another service... "
38
39 if ! $exe $DEBUG -i resolver > $out ; then
40   echo "FAIL: error running $exe"
41   echo "Command output was:"
42   cat $out
43   kill %%
44   exit 1
45 fi
46 sleep 1
47 LINES=`ps ax | grep gnunet-service-resolver | grep -v grep | wc -l`
48 if test $LINES -ne 1; then
49   echo "FAIL: unexpected output (got $LINES lines, wanted 1)"
50   echo "Command output was:"
51   cat $out
52   $exe -e > /dev/null
53   exit 1
54 fi
55 echo "PASS"
56
57 # ----------------------------------------------------------------------------------
58 echo -n "TEST: Test -t on running service... "
59
60 if ! $exe $DEBUG -t resolver > $base.out; then
61     echo "FAIL: error running $exe"
62     exit 1
63 fi
64 LINES=`cat $base.out | grep resolver | grep not | wc -l`
65 if test $LINES -ne 0; then
66   echo "FAIL: unexpected output:"
67   cat $base.out
68   $exe -e
69   exit 1
70 fi
71 LINES=`cat $base.out | grep resolver | grep -v not | wc -l`
72 if test $LINES -ne 1; then
73   echo "FAIL: unexpected output"
74   cat $base.out
75   $exe -e
76   exit 1
77 fi
78 echo "PASS"
79
80 # ----------------------------------------------------------------------------------
81 echo -n "TEST: Stop a service... "
82
83 if ! $exe $DEBUG -k resolver > $out; then
84   echo "FAIL: error running $exe"
85   $exe -e
86   exit 1
87 fi
88 sleep 1
89 LINES=`ps ax | grep gnunet-service-resolver | grep -v grep | wc -l`
90 if test $LINES -ne 0; then
91   echo "FAIL: unexpected output"
92   echo "Command output was:"
93   cat $out
94   $exe -e > /dev/null
95   exit 1
96 fi
97 echo "PASS"
98
99 # ----------------------------------------------------------------------------------
100 echo -n "TEST: Test -t on stopped service... "
101
102 if ! $exe $DEBUG -t resolver > $base.out; then
103   echo "FAIL: error running $exe"
104   cat $base.out
105   $exe -e > /dev/null
106   exit 1
107 fi
108 LINES=`cat $base.out | grep resolver | grep not | wc -l`
109 if test $LINES -ne 1; then
110   echo "FAIL: unexpected output"
111   cat $base.out 
112   $exe -e > /dev/null
113   exit 1
114 fi
115 echo "PASS"
116
117 # ----------------------------------------------------------------------------------
118 echo -n "TEST: Stop ARM... "
119
120 if ! $exe $DEBUG -e > $out; then
121   echo "FAIL: error running $exe"
122   exit 1
123 fi
124 sleep 1
125 LINES=`ps ax | grep gnunet-service-arm | grep -v grep | wc -l`
126 if test $LINES -ne 0; then
127   echo "FAIL: unexpected output, still have $LINES gnunet-service-arm processes"
128   echo "Command output was:"
129   cat $out  
130   exit 1
131 fi
132 echo "PASS"
133
134 rm -rf /tmp/test-gnunetd-arm/
135 rm -f $base.out $out
136