forked from legatoproject/legato-af
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests
executable file
·330 lines (272 loc) · 6.12 KB
/
run-tests
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/bin/bash
SOURCEDIR=$PWD
BUILDDIR_BASE=$PWD/build
function StartServiceDirectory()
{
echo -n "Starting Service Directory..."
serviceDirectory &
SERVICE_DIRECTORY_PID=$!
sleep 0.5
echo " DONE."
}
function StopServiceDirectory()
{
echo -n "Stopping Service Directory..."
kill $SERVICE_DIRECTORY_PID > /dev/null 2>&1
echo " DONE."
}
function CheckServiceDirectory()
{
if ! kill -0 $SERVICE_DIRECTORY_PID > /dev/null 2>&1
then
echo "Service Directory is no longer running!"
exit 1
fi
}
function StartLogControlDaemon()
{
echo -n "Starting Log Control Daemon..."
logCtrlDaemon &
LOG_CTRL_DAEMON_PID=$!
sleep 0.5
echo " DONE."
}
function StopLogControlDaemon()
{
echo -n "Stopping Log Control Daemon..."
kill $LOG_CTRL_DAEMON_PID > /dev/null 2>&1
sleep 0.5
echo " DONE."
}
function CheckLogControlDaemon()
{
if ! kill -0 $LOG_CTRL_DAEMON_PID > /dev/null 2>&1
then
echo "Log Control Daemon is no longer running!"
StopServiceDirectory
exit 1
fi
}
function StartConfigTree()
{
echo -n "Starting Configuration Tree..."
configTree &
CONFIG_TREE_PID=$!
sleep 0.5
echo " DONE."
}
function StopConfigTree()
{
echo -n "Stopping Configuration Tree..."
kill $CONFIG_TREE_PID > /dev/null 2>&1
echo " DONE."
}
function CheckConfigTree()
{
if ! kill -0 $CONFIG_TREE_PID > /dev/null 2>&1
then
echo "Config Tree is no longer running!"
exit 1
fi
}
function StartDaemons()
{
StartServiceDirectory
StartLogControlDaemon
StartConfigTree
}
function StopDaemons()
{
StopLogControlDaemon
StopServiceDirectory
StopConfigTree
}
function CheckDaemons()
{
CheckLogControlDaemon
CheckServiceDirectory
CheckConfigTree
}
function CheckRet()
{
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo -e $COLOR_ERROR "Exit Code $RETVAL" $COLOR_RESET
StopDaemons
exit $RETVAL
fi
}
function CleanBuild()
{
make clean
}
function TargetIdentify()
{
echo "Identifying target ..."
TARGET_MODEL=$(ssh -o ConnectTimeout=5 root@$DEST_IP "bsinfo -l | grep \" - \$(bsinfo -s -t)\" | sed -e 's/BS//' -e 's/ - .*$//'" 2> /dev/null)
if [ -z "$TARGET_MODEL" ]; then
echo "Unable to determine remote target model"
exit 1
fi
TARGET_TYPE=$($SOURCEDIR/bin/gettargettype $TARGET_MODEL)
if [ -z "$TARGET_TYPE" ]; then
echo "Unable to determine remote target type"
exit 1
fi
echo "Testing Legato on $DEST_IP (type = $TARGET_TYPE)"
}
function TargetUpdateLegato()
{
echo "Updating Legato"
# if startup scripts are updated target will need to reboot.
instsys build/$TARGET_TYPE/system.$TARGET_TYPE.update $DEST_IP
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo -e $COLOR_ERROR "Exit Code $RETVAL" $COLOR_RESET
StopDaemons
exit $RETVAL
fi
# Wait for target to bring up the new system.
sleep 60
}
function TargetUnitTest()
{
if [ "$DEST_IP" == "" ]; then
echo "Target IP address is not available. Unit testing on target will be skipped."
return
fi
TargetUpdateLegato
cd $BUILDDIR_BASE/$TARGET_TYPE
CheckRet
# Test
$SOURCEDIR/apps/test/targetUnitTests $DEST_IP $TARGET_TYPE
CheckRet
cd $SOURCEDIR
CheckRet
}
function HostUnitTest()
{
cd $BUILDDIR_BASE/localhost
CheckRet
export PATH=$PWD/framework/bin:$PWD/tests/bin:$PATH
# Stop any other instances of the legato framework daemons that may already be running.
# NOTE: Killing the Service Directory should be sufficient to cause everything else to die too.
serviceDirProcIDs=`pgrep serviceDir`
if [ $? -eq 0 ]
then
for procID in $serviceDirProcIDs
do
echo "*** Killing Service Directory process with PID $procID"
kill $procID
done
fi
StartDaemons
CheckDaemons
# Test
ctest -D ExperimentalTest --no-compress-output -VV
CheckRet
CheckDaemons
StopDaemons
cd $SOURCEDIR
CheckRet
}
function Build()
{
TARGET=$1
BUILDDIR="$BUILDDIR_BASE/$TARGET"
echo "Building for $TARGET"
# Check Toolchain path
# NOTE: Even if the toolchain path is not set, the Makefile should be able to recover.
if [[ $TARGET != "localhost" ]]; then
TOOLCHAIN_ENV="${TARGET^^}_TOOLCHAIN_DIR"
if [ -z "${!TOOLCHAIN_ENV}" ]; then
echo "$TOOLCHAIN_ENV not set"
else
echo "$TOOLCHAIN_ENV=${!TOOLCHAIN_ENV}"
fi
fi
# Build
make tests_$TARGET
CheckRet
source $SOURCEDIR/bin/configlegatoenv
}
function BuildTools()
{
echo "Building Tools"
make tools
CheckRet
}
function BuildClang()
{
if ! which clang; then
echo "Unable to find clang"
exit 1
fi
echo " Clang version:"
clang -v 2>&1 |head -1
# Normal build, with clang
export USE_CLANG=1
Build "localhost" false false
unset USE_CLANG
CleanBuild
}
function Job_HostUnitTest()
{
if [ -n "$SKIP_HOST_TESTING" ]; then
echo "Skipping host unit tests."
return
fi
Build "localhost" false false
HostUnitTest
}
function Job_TargetUnitTest()
{
if [ -n "$SKIP_TARGET_TESTING" ]; then
echo "Skipping on-target unit tests."
return
fi
TargetIdentify
Build $TARGET_TYPE false false
TargetUnitTest
}
function Manual_DeveloperPrePushTrial()
{
echo "Cleaning ..."
CleanBuild
echo "Building ..."
Build "localhost" false true
echo "Building for virtual target..."
Build "virt" false false
echo "Testing ..."
HostUnitTest
echo "Tests complete."
}
echo -e "== Task: '$1' ==\n"
if [ -e "$SOURCEDIR/bin/configlegatoenv" ]; then
source $SOURCEDIR/bin/configlegatoenv
fi
case "$1" in
host-ut)
Job_HostUnitTest
;;
run-host-ut)
HostUnitTest
;;
target-ut)
Job_TargetUnitTest
;;
run-target-ut)
TargetUnitTest
;;
dev-trial)
Manual_DeveloperPrePushTrial
;;
quick-test)
Build "localhost" false 1 true
HostUnitTest
;;
*)
echo "Invalid argument: '$1'"
exit 1
;;
esac