@@ -79,6 +79,9 @@ if [[ ! -x ./dist/tracee ]]; then
79
79
error_exit " could not find tracee executable"
80
80
fi
81
81
82
+ logfile=$SCRIPT_TMP_DIR /tracee-log-$$
83
+ outputfile=$SCRIPT_TMP_DIR /output-$$
84
+
82
85
anyerror=" "
83
86
84
87
# Run tests, one by one
@@ -138,18 +141,18 @@ for TEST in $TESTS; do
138
141
139
142
# Run tracee
140
143
141
- rm -f $SCRIPT_TMP_DIR /build- $$
142
- rm -f $SCRIPT_TMP_DIR /tracee-log- $$
144
+ rm -f $outputfile
145
+ rm -f $logfile
143
146
144
147
tracee_command=" ./dist/tracee \
145
148
--install-path $TRACEE_TMP_DIR \
146
149
--cache cache-type=mem \
147
150
--cache mem-cache-size=512 \
148
151
--proctree source=both \
149
152
--output option:sort-events \
150
- --output json:$SCRIPT_TMP_DIR /build-$$ \
151
153
--output option:parse-arguments \
152
- --log file:$SCRIPT_TMP_DIR /tracee-log-$$ \
154
+ --output json:$outputfile \
155
+ --log file:$logfile \
153
156
--signatures-dir " $SIG_DIR " \
154
157
--dnscache enable \
155
158
--grpc-listen-addr unix:/tmp/tracee.sock \
@@ -201,7 +204,7 @@ for TEST in $TESTS; do
201
204
info
202
205
info " $TEST : FAILED. ERRORS:"
203
206
info
204
- cat $SCRIPT_TMP_DIR /tracee-log- $$
207
+ cat $logfile
205
208
206
209
anyerror=" ${anyerror} $TEST ,"
207
210
continue
@@ -232,12 +235,18 @@ for TEST in $TESTS; do
232
235
233
236
# The cleanup happens at EXIT
234
237
235
- logfile=$SCRIPT_TMP_DIR /tracee-log-$$
238
+ # Make sure we exit tracee before checking output and log files
239
+
240
+ pid_tracee=$( pidof tracee | cut -d' ' -f1)
241
+ kill -SIGINT " $pid_tracee "
242
+ sleep $TRACEE_SHUTDOWN_TIMEOUT
243
+ kill -SIGKILL " $pid_tracee " > /dev/null 2>&1
244
+ sleep 3
236
245
237
246
# Check if the test has failed or not
238
247
239
248
found=0
240
- cat $SCRIPT_TMP_DIR /build- $$ | jq .eventName | grep -q " $TEST " && found=1
249
+ cat $outputfile | jq .eventName | grep -q " $TEST " && found=1
241
250
errors=$( cat $logfile | wc -l 2> /dev/null)
242
251
243
252
if [[ $TEST == " BPF_ATTACH" ]]; then
@@ -249,25 +258,33 @@ for TEST in $TESTS; do
249
258
info " $TEST : SUCCESS"
250
259
else
251
260
anyerror=" ${anyerror} $TEST ,"
261
+
252
262
info " $TEST : FAILED, stderr from tracee:"
253
- cat $SCRIPT_TMP_DIR /tracee-log-$$
263
+ cat $logfile
264
+
254
265
info " $TEST : FAILED, events from tracee:"
255
- cat $SCRIPT_TMP_DIR /build-$$
266
+ cat $outputfile
267
+
268
+ info " Tracee command:"
269
+ echo " $tracee_command " | tr -s ' '
270
+
271
+ info " Tracee process is running?"
272
+ traceepids=$( pgrep tracee)
273
+ if [[ -n $traceepids ]]; then
274
+ info " YES, Tracee is still running (should not be, fix me!), pids: $traceepids "
275
+ info " Aborting tests"
276
+ break
277
+ else
278
+ info " NO, Tracee is not running"
279
+ fi
256
280
info
257
281
fi
258
282
info
259
283
260
- rm -f $SCRIPT_TMP_DIR /build-$$
261
- rm -f $SCRIPT_TMP_DIR /tracee-log-$$
262
-
263
- # Make sure we exit tracee to start it again
264
-
265
- pid_tracee=$( pidof tracee | cut -d' ' -f1)
266
- kill -SIGINT " $pid_tracee "
267
- sleep $TRACEE_SHUTDOWN_TIMEOUT
268
- kill -SIGKILL " $pid_tracee " > /dev/null 2>&1
269
- sleep 3
284
+ # Cleanup
270
285
286
+ rm -f $outputfile
287
+ rm -f $logfile
271
288
# Cleanup leftovers
272
289
rm -rf $TRACEE_TMP_DIR
273
290
done
0 commit comments