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