TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
SESSION_NAME="per-session"
EVENT_NAME="tp:tptest"
-NUM_TESTS=16
+NUM_TESTS=17
source $TESTDIR/utils/utils.sh
# MUST set TESTDIR before calling those functions
-test_before_apps() {
+function wait_app()
+{
+ while [ -n "$(pidof $TESTAPP_NAME)" ]; do
+ sleep 0.5
+ done
+ pass "Application $TESTAPP_NAME ended."
+}
+
+function test_before_apps()
+{
# BEFORE application is spawned
create_lttng_session $SESSION_NAME $TRACE_PATH
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
start_lttng_tracing $SESSION_NAME
$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
- ok $? "Start application to trace"
+ ok $? "Traced application stopped."
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
return $?
}
-test_after_apps() {
+function test_after_apps()
+{
local out
$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
- ok $? "Start application to trace"
+ ok $? "Application started in background."
# BEFORE application is spawned
create_lttng_session $SESSION_NAME $TRACE_PATH
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
start_lttng_tracing $SESSION_NAME
- # At least hit one event
- sleep 2
+ # Since the start is done after the application is started, there is a
+ # bootstrap time needed between the session daemon and the UST tracer.
+ # Waiting for the application to end tells us when to stop everything and
+ # validate that at least one event is seen.
+ wait_app
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
- if [ $out -eq 0 ]; then
- fail "Trace validation"
- diag "No event(s) found. We are supposed to have at least one."
- out=1
- else
- pass "Trace validation"
- diag "Found $out event(s). Coherent."
- out=0
- fi
+ validate_trace $EVENT_NAME $TRACE_PATH
+ out=$?
return $out
}
start_lttng_sessiond
-diag "Start application BEFORE tracing was started"
+diag "Start tracing BEFORE application is started"
TRACE_PATH=$(mktemp -d)
rm -rf $TRACE_PATH
-diag "Start application AFTER tracing was started"
+diag "Start tracing AFTER application is started"
TRACE_PATH=$(mktemp -d)