3 rm -rf /tmp/test-gnunetd-statistics/
4 exe="./gnunet-statistics -c test_statistics_api_data.conf"
5 out=`mktemp /tmp/test-gnunet-statistics-logXXXXXXXX`
6 arm="gnunet-arm -c test_statistics_api_data.conf $DEBUG"
8 # -----------------------------------
9 echo -n "Preparing: Starting service..."
13 $arm -i statistics > /dev/null
17 # ----------------------------------------------------------------------------------
18 echo -n "TEST: Bad argument checking..."
20 if $exe -x 2> /dev/null; then
21 echo "FAIL: error running $exe"
27 # ----------------------------------------------------------------------------------
28 echo -n "TEST: Set value..."
30 if ! $exe $DEBUG -n test -s subsystem 42 ; then
31 echo "FAIL: error running $exe"
37 # ----------------------------------------------------------------------------------
38 echo -n "TEST: Set another value..."
40 if ! $exe $DEBUG -n other -s osystem 43 ; then
41 echo "FAIL: error running $exe"
47 # ----------------------------------------------------------------------------------
48 echo -n "TEST: viewing all stats..."
50 if ! $exe $DEBUG > $out; then
51 echo "FAIL: error running $exe"
55 LINES=`cat $out | wc -l`
56 if test $LINES -ne 2; then
57 echo "FAIL: unexpected output"
63 # ----------------------------------------------------------------------------------
64 echo -n "TEST: viewing stats by name..."
66 if ! $exe $DEBUG -n other > $out; then
67 echo "FAIL: error running $exe"
71 LINES=`cat $out | grep 43 | wc -l`
72 if test $LINES -ne 1; then
73 echo "FAIL: unexpected output"
79 # ----------------------------------------------------------------------------------
80 echo -n "TEST: viewing stats by subsystem..."
82 if ! $exe $DEBUG -s subsystem > $out; then
83 echo "FAIL: error running $exe"
87 LINES=`cat $out | grep 42 | wc -l`
88 if test $LINES -ne 1; then
89 echo "FAIL: unexpected output"
96 # ----------------------------------------------------------------------------------
97 echo -n "TEST: Set persistent value..."
99 if ! $exe $DEBUG -n lasting -s subsystem 40 -p; then
100 echo "FAIL: error running $exe"
104 if ! $exe $DEBUG > $out; then
105 echo "FAIL: error running $exe"
109 LINES=`cat $out | grep 40 | wc -l`
110 if test $LINES -ne 1; then
111 echo "FAIL: unexpected output"
118 # -----------------------------------
119 echo -n "Restarting service..."
120 $arm -k statistics > /dev/null
122 $arm -i statistics > /dev/null
126 # ----------------------------------------------------------------------------------
127 echo -n "TEST: checking persistence..."
129 if ! $exe $DEBUG > $out; then
130 echo "FAIL: error running $exe"
134 LINES=`cat $out | grep 40 | wc -l`
135 if test $LINES -ne 1; then
136 echo "FAIL: unexpected output"
145 # ----------------------------------------------------------------------------------
146 echo -n "TEST: Removing persistence..."
148 if ! $exe $DEBUG -n lasting -s subsystem 40; then
149 echo "FAIL: error running $exe"
153 if ! $exe $DEBUG > $out; then
154 echo "FAIL: error running $exe"
158 LINES=`cat $out | grep \! | wc -l`
159 if test $LINES -ne 0; then
160 echo "FAIL: unexpected output"
168 # -----------------------------------
169 echo -n "Restarting service..."
170 $arm -k statistics > /dev/null
172 $arm -i statistics > /dev/null
176 # ----------------------------------------------------------------------------------
177 echo -n "TEST: checking removed persistence..."
179 if ! $exe $DEBUG > $out; then
180 echo "FAIL: error running $exe"
184 LINES=`cat $out | grep 40 | wc -l`
185 if test $LINES -ne 0; then
186 echo "FAIL: unexpected output"
193 # -----------------------------------
194 echo -n "Stopping service..."
199 rm -rf /tmp/test-gnunetd-statistics/