3 rm -rf /tmp/test-gnunetd-statistics/
4 exe="./gnunet-statistics -c test_statistics_api_data.conf"
5 base=/tmp/gnunet-test-statistics
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 > $base.out; then
51 echo "FAIL: error running $exe"
55 LINES=`cat $base.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 > $base.out; then
67 echo "FAIL: error running $exe"
71 LINES=`cat $base.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 > $base.out; then
83 echo "FAIL: error running $exe"
87 LINES=`cat $base.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"
106 # -----------------------------------
107 echo -n "Restarting service..."
108 $arm -k statistics > /dev/null
110 $arm -i statistics > /dev/null
114 # ----------------------------------------------------------------------------------
115 echo -n "TEST: checking persistence..."
117 if ! $exe $DEBUG > $base.out; then
118 echo "FAIL: error running $exe"
122 LINES=`cat $base.out | grep 40 | wc -l`
123 if test $LINES -ne 1; then
124 echo "FAIL: unexpected output"
132 # ----------------------------------------------------------------------------------
133 echo -n "TEST: Removing persistence..."
135 if ! $exe $DEBUG -n lasting -s subsystem 40; then
136 echo "FAIL: error running $exe"
143 # -----------------------------------
144 echo -n "Restarting service..."
145 $arm -k statistics > /dev/null
147 $arm -i statistics > /dev/null
151 # ----------------------------------------------------------------------------------
152 echo -n "TEST: checking removed persistence..."
154 if ! $exe $DEBUG > $base.out; then
155 echo "FAIL: error running $exe"
159 LINES=`cat $base.out | grep 40 | wc -l`
160 if test $LINES -ne 0; then
161 echo "FAIL: unexpected output"
167 # -----------------------------------
168 echo -n "Stopping service..."
173 rm -rf /tmp/test-gnunetd-statistics/