aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/test_gnunet_statistics.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/statistics/test_gnunet_statistics.sh')
-rwxr-xr-xsrc/statistics/test_gnunet_statistics.sh177
1 files changed, 177 insertions, 0 deletions
diff --git a/src/statistics/test_gnunet_statistics.sh b/src/statistics/test_gnunet_statistics.sh
new file mode 100755
index 000000000..43f629f36
--- /dev/null
+++ b/src/statistics/test_gnunet_statistics.sh
@@ -0,0 +1,177 @@
1#!/bin/bash
2
3rm -rf /tmp/test-gnunetd-statistics/
4exe="./gnunet-statistics -c test_statistics_api_data.conf"
5base=/tmp/gnunet-test-statistics
6#DEBUG="-L DEBUG"
7# -----------------------------------
8echo -n "Preparing: Starting service..."
9./gnunet-service-statistics $DEBUG -c test_statistics_api_data.conf &
10sleep 1
11echo "DONE"
12
13# ----------------------------------------------------------------------------------
14echo -n "TEST: Bad argument checking..."
15
16if $exe -x 2> /dev/null; then
17 echo "FAIL: error running $exe"
18 kill %%
19 exit 1
20fi
21echo "PASS"
22
23# ----------------------------------------------------------------------------------
24echo -n "TEST: Set value..."
25
26if ! $exe $DEBUG -n test -s subsystem 42 ; then
27 echo "FAIL: error running $exe"
28 kill %%
29 exit 1
30fi
31echo "PASS"
32
33# ----------------------------------------------------------------------------------
34echo -n "TEST: Set another value..."
35
36if ! $exe $DEBUG -n other -s osystem 43 ; then
37 echo "FAIL: error running $exe"
38 kill %%
39 exit 1
40fi
41echo "PASS"
42
43# ----------------------------------------------------------------------------------
44echo -n "TEST: viewing all stats..."
45
46if ! $exe $DEBUG > $base.out; then
47 echo "FAIL: error running $exe"
48 kill %%
49 exit 1
50fi
51LINES=`cat $base.out | wc -l`
52if test $LINES -ne 2; then
53 echo "FAIL: unexpected output"
54 kill %%
55 exit 1
56fi
57echo "PASS"
58
59# ----------------------------------------------------------------------------------
60echo -n "TEST: viewing stats by name..."
61
62if ! $exe $DEBUG -n other > $base.out; then
63 echo "FAIL: error running $exe"
64 kill %%
65 exit 1
66fi
67LINES=`cat $base.out | grep 43 | wc -l`
68if test $LINES -ne 1; then
69 echo "FAIL: unexpected output"
70 kill %%
71 exit 1
72fi
73echo "PASS"
74
75# ----------------------------------------------------------------------------------
76echo -n "TEST: viewing stats by subsystem..."
77
78if ! $exe $DEBUG -s subsystem > $base.out; then
79 echo "FAIL: error running $exe"
80 kill %%
81 exit 1
82fi
83LINES=`cat $base.out | grep 42 | wc -l`
84if test $LINES -ne 1; then
85 echo "FAIL: unexpected output"
86 kill %%
87 exit 1
88fi
89echo "PASS"
90
91
92# ----------------------------------------------------------------------------------
93echo -n "TEST: Set persistent value..."
94
95if ! $exe $DEBUG -n lasting -s subsystem 40 -p; then
96 echo "FAIL: error running $exe"
97 kill %%
98 exit 1
99fi
100echo "PASS"
101
102# -----------------------------------
103echo -n "Restarting service..."
104sleep 1
105if ! kill %%;
106then
107 echo "FAIL: could not kill service"
108 kill %%
109 exit 1
110fi
111sleep 1
112./gnunet-service-statistics $DEBUG -c test_statistics_api_data.conf &
113sleep 1
114
115
116# ----------------------------------------------------------------------------------
117echo -n "TEST: checking persistence..."
118
119if ! $exe $DEBUG > $base.out; then
120 echo "FAIL: error running $exe"
121 kill %%
122 exit 1
123fi
124LINES=`cat $base.out | grep 40 | wc -l`
125if test $LINES -ne 1; then
126 echo "FAIL: unexpected output"
127 kill %%
128 exit 1
129fi
130echo "PASS"
131
132
133
134# ----------------------------------------------------------------------------------
135echo -n "TEST: Removing persistence..."
136
137if ! $exe $DEBUG -n lasting -s subsystem 40; then
138 echo "FAIL: error running $exe"
139 kill %%
140 exit 1
141fi
142echo "PASS"
143
144
145# -----------------------------------
146echo -n "Restarting service..."
147sleep 1
148if ! kill %%;
149then
150 echo "FAIL: could not kill service"
151 kill %%
152 exit 1
153fi
154sleep 1
155./gnunet-service-statistics $DEBUG -c test_statistics_api_data.conf &
156sleep 1
157
158
159# ----------------------------------------------------------------------------------
160echo -n "TEST: checking removed persistence..."
161
162if ! $exe $DEBUG > $base.out; then
163 echo "FAIL: error running $exe"
164 kill %%
165 exit 1
166fi
167LINES=`cat $base.out | grep 40 | wc -l`
168if test $LINES -ne 0; then
169 echo "FAIL: unexpected output"
170 kill %%
171 exit 1
172fi
173echo "PASS"
174
175kill %%
176rm -f $base.out
177rm -rf /tmp/test-gnunetd-statistics/