-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·235 lines (214 loc) · 5.68 KB
/
run
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
function fail {
echo "$1"
exit 1
}
function start_services {
echo "Booting services ($SERVICES)..."
if [ "$SERVICES" = "atheme" ]; then
cp -av serverconfig/atheme/atheme.conf ~/atheme/etc/ || fail "Failed to copy atheme.conf"
cp -av serverconfig/atheme/services.db ~/atheme/etc/ || fail "Failed to copy services.db"
cd ~/atheme || exit 1
bin/atheme-services || fail "atheme failed to start"
cd -
fi
if [ "$SERVICES" = "anope" ]; then
cp -av serverconfig/anope/services.conf ~/anope/conf/ || fail "Failed to copy services.conf"
cp -av serverconfig/anope/anope.db ~/anope/data/ || fail "Failed to copy anope.db"
cd ~/anope || exit 1
bin/services || fail "anope failed to start"
cd -
fi
if [ "$SERVICES" = "none" ]; then
echo "Skipping services tests (not recommended)"
fi
}
function kill_server {
echo -n "Killing any old server instances"
PROCS="valgrind|valgrind.bin|memcheck|memcheck-amd64-linux|memcheck-x86-linux|ircd|unrealircd|val|atheme-services|services|anope"
KILLTIMEOUT="15"
T=0
# Ask to shutdown gracefully
pkill -15 -U "$UID" "$PROCS" 1>/dev/null 2>&1
while [ "$T" -lt "$KILLTIMEOUT" ];
do
# Killed by now?
if ! pgrep -U "$UID" "$PROCS" >/dev/null; then
break
fi
T=$(expr $T + 1)
echo -n "."
sleep 1
done
echo
pkill -9 -U "$UID" "$PROCS"
}
if [ "$MAXPARALLEL" = "" ]; then
MAXPARALLEL="25"
fi
TIMEOUT="160"
KEEPDBS="0"
FAST="0"
INCLUDEFILE=""
export PYTHONPATH="`pwd`:$PYTHONPATH"
export PYTHONIOENCODING=utf-8
export TIMEOUT
export ASAN_OPTIONS=abort_on_error=1:disable_coredump=0:unmap_shadow_on_exit=1
if [ "$MAKE" = "" ]; then
if gmake --version 1>/dev/null 2>&1; then
MAKE="gmake"
else
MAKE="make"
fi
fi
rm -rf logs
mkdir logs
mkdir logs/success
mkdir logs/failure
if [ "$1" != "-services" ]; then
echo "ERROR: You need to specify with which services we should test, this needs to be the first parameter passed to ./run:"
echo "./run -services [anope|atheme|none] [...other options for us...]"
exit 1
else
shift
if [ "$1" = "anope" ]; then
SERVICES="anope"
elif [ "$1" = "atheme" ]; then
SERVICES="atheme"
elif [ "$1" = "none" ]; then
SERVICES="none"
else
echo "Unrecognized services ($1). Specify one of: anope, atheme, none"
exit 1
fi
shift
fi
if [ "$1" = "-include" ]; then
shift
INCLUDEFILE="$1"
shift
fi
if [ "$1" = "-single" ]; then
MAXPARALLEL=1
shift
fi
if [ "$1" = "-fast" ]; then
FAST=1
TIMEOUT=30
shift
fi
if [ "$1" = "-keepdbs" ]; then
KEEPDBS=1
shift
fi
if [ "$1" = "-boot" -o "$1" = "" ]; then
shift
# Compile any modules that are needed (fakereputation etc)
cp -av serverconfig/unrealircd/modules/*.c ~/unrealircd/source/src/modules/third/ || exit 1
cd ~/unrealircd/source || exit 1
$MAKE install
cd -
# Boot the ircd
kill_server
echo "Booting IRC server..."
cp -av serverconfig/unrealircd/* ~/unrealircd/conf/ || fail "Failed to copy serverconfig/unrealircd"
cd ~/unrealircd/ || exit 1
if [ "$KEEPDBS" -eq 0 ]; then
mkdir data/old 2>/dev/null
mv data/*.db data/old/ 2>/dev/null
rm -rf data/history.old 2>/dev/null
mv data/history data/history.old 2>/dev/null
fi
if [ "$INCLUDEFILE" != "" ]; then
# Add include to irc1.conf (only)
echo 'include "'$INCLUDEFILE'";' >>conf/irc1.conf
fi
for name in irc2 irc1 irc3
do
bin/unrealircd -f $name.conf || fail "UnrealIRCd failed to start ($name)"
sleep 1
kill -1 `cat data/unrealircd.pid`
done
cd -
start_services
# Give services a chance to link in
sleep 2
timeout --kill-after=5 --signal=INT 10 tests/_pre_test || fail "Linking servers failed"
echo
fi
if [ "$1" = "" ]; then
# Run (almost) all tests:
echo "Running tests in parallel..."
if [ "$SERVICES" = "none" ]; then
find tests -type f|grep -vF '~'|grep -vF _pre_test|grep -vF services/|grep -vF /db/|grep -vF /serial/|xargs -L1 -P$MAXPARALLEL irctestframework/wrapper
else
find tests -type f|grep -vF '~'|grep -vF _pre_test|grep -vF /db/|grep -vF /serial/|xargs -L1 -P$MAXPARALLEL irctestframework/wrapper
fi
wait
if [ "$FAST" = 0 ]; then
# Now do the tests that can only be run in series...
echo "Running remaining tests in series..."
find tests/serial/ -type f|grep -vF '~'|grep -v README|xargs -L1 -P1 irctestframework/wrapper
fi
else
# Run specific tests:
echo "Running specific tests by user request..."
for f in $*
do
# Skip backup files and such (blah~)
if (echo "$f"|egrep -q '~$'); then
continue
fi
if [ "$f" = "tests/db/writing/history" -o "$f" = "tests/db/reading/history" ]; then
if ! (echo "$INCLUDEFILE"|grep -q 'crypt'); then
echo "WARNING: Skipping $f -- not using encryption so can't test this"
continue
fi
fi
irctestframework/wrapper $f
done
fi
cd logs/success
echo
echo "==================================================================================================="
echo ">>> SUCCESFUL TESTS"
for f in *.log
do
name="`echo $f|sed 's/__/\//g'|sed 's/\.log//g'`"
if [ "$f" == "*.log" ]; then
continue
fi
echo -e "\u2714 $name"
done
cd - 1>/dev/null 2>&1
echo "==================================================================================================="
failed=0
cd logs/failure
for f in *.log
do
name="`echo $f|sed 's/__/\//g'|sed 's/\.log//g'`"
if [ "$f" == "*.log" ]; then
continue
fi
echo
echo "==================================================================================================="
echo ">>> FAILED TEST: $name"
cat $f
echo "==================================================================================================="
echo
failed=1
done
if [ "$failed" = 1 ]; then
echo
echo "======[ SUMMARY ]======"
for f in *.log
do
name="`echo $f|sed 's/__/\//g'|sed 's/\.log//g'`"
if [ "$f" == "*.log" ]; then
continue
fi
echo "TEST FAILED: $name"
done
fi
cd - 1>/dev/null 2>&1
exit $failed