kill ${p}
wait ${p} 2>&1
done
+ APPS_PID=
}
# Test a snapshot using a default name for the output destination.
kill ${p}
wait ${p} 2>&1
done
+ APPS_PID=
}
function snapshot_add_output ()
TRACE_PATH=$(mktemp -d)
-NUM_TESTS=18
+NUM_TESTS=16
source $TESTDIR/utils/utils.sh
# Run 5 times with a 1 second delay
$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
- start_lttng_tracing $SESSION_NAME
+ #FIXME: racy missing synchro
- wait_apps
+ start_lttng_tracing $SESSION_NAME
+ # Wait for the applications started in background
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
wait_apps
+ #FIXME: racy missing synchro
+
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
+
+ # Wait for the applications started in background
+ wait
}
plan_tests $NUM_TESTS
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
SESSION_NAME="per-session"
EVENT_NAME="tp:tptest"
-NUM_TESTS=17
+NUM_TESTS=16
source $TESTDIR/utils/utils.sh
# MUST set TESTDIR before calling those functions
-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
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
start_lttng_tracing $SESSION_NAME
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
+ wait
ok $? "Traced application stopped."
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
return $?
}
function test_after_apps()
{
local out
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
- ok $? "Application started in background."
-
- # BEFORE application is spawned
create_lttng_session $SESSION_NAME $TRACE_PATH
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} &
+ ok $? "Application started in background."
+
start_lttng_tracing $SESSION_NAME
- # 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
+ touch ${file_sync_before_last}
+
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
+ rm -f ${file_sync_after_first}
+ rm -f ${file_sync_before_last}
+
validate_trace $EVENT_NAME $TRACE_PATH
out=$?
start_lttng_tracing $SESSION_NAME
for i in `seq 1 5`; do
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
ok $? "Start application $i for tracing"
done
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
+ trace_match_only $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
return $?
}
test_before_multiple_apps() {
local out
local i
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
diag "Start multiple applications BEFORE tracing is started"
for i in `seq 1 5`; do
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & >/dev/null 2>&1
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first}_${i} ${file_sync_before_last}_${i} >/dev/null 2>&1 &
ok $? "Start application $i for tracing"
done
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
start_lttng_tracing $SESSION_NAME
+ for i in `seq 1 5`; do
+ touch ${file_sync_before_last}_${i}
+ done
+
diag "Waiting for applications to end"
wait
pass "Waiting done"
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
+ for i in `seq 1 5`; do
+ rm -f ${file_sync_after_first}_${i}
+ rm -f ${file_sync_before_last}_${i}
+ done
+
out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
if [ $out -eq 0 ]; then
fail "Trace validation"
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
start_lttng_tracing $SESSION_NAME
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
ok $? "Start application to trace"
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
return $?
}
test_before_app() {
local out
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
diag "Start application BEFORE tracing is started"
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
- ok $? "Start application to trace"
# BEFORE application is spawned
create_lttng_session $SESSION_NAME $TRACE_PATH
enable_channel_per_pid $SESSION_NAME "channel0"
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
+
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} &
+ ok $? "Start application to trace"
+
start_lttng_tracing $SESSION_NAME
- # At least hit one event
- sleep 2
+ touch ${file_sync_before_last}
+
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
+ rm -f ${file_sync_after_first}
+ rm -f ${file_sync_before_last}
+
out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
if [ $out -eq 0 ]; then
fail "Trace validation"
out=0
fi
- wait_apps
-
return $out
}
ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel4"
start_lttng_tracing $SESSION_NAME
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
ok $? "Start application to trace"
+ wait
stop_lttng_tracing $SESSION_NAME
- trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
+ trace_match_only $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
out=$?
destroy_lttng_session $SESSION_NAME
start_lttng_tracing $SESSION_NAME
for i in `seq 1 $NR_APP`; do
- ./$CURDIR/$BIN_NAME & >/dev/null 2>&1
+ ./$CURDIR/$BIN_NAME >/dev/null 2>&1 &
done
diag "Waiting for applications to end"
# Run 5 times with a 1 second delay
run_app
+ #FIXME: racy missing synchronization
+
start_lttng_tracing $SESSION_NAME
# Wait for the applications started in background
./$CURDIR/gen-nevents $NR_ITER &
ok $? "Start application to generate $NR_ITER events"
- # At least hit one event
- while [ -n "$(pidof gen-nevents)" ]; do
- sleep 0.1
- done
-
+ wait
pass "Wait for events to record"
for i in `seq 0 3`; do
APPS_PID="${APPS_PID} ${!}"
done
+#FIXME: racy missing synchronization
+
diag "Waiting for applications to be registered to sessiond"
reg_app_count=0
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
+#FIXME/TODO: add validation after fixing racy synchroniaation
+
rm -rf $TRACE_PATH
diag "Stopping all spawned applications"
kill ${p}
wait ${p} 2>/dev/null
done
+APPS_PID=
pass "Stopped all spawned applications"
stop_lttng_sessiond
BIN_NAME="gen-nevents"
NUM_TESTS=38
APP_TMP_FILE="/tmp/lttng_test_ust.42.file"
+APPS_PID=
source $TESTDIR/utils/utils.sh
{
# Start application with a temporary file.
$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $APP_TMP_FILE &
- ok $? "Start application to trace"
+ ret=$?
+ APPS_PID="${APPS_PID} ${!}"
+ ok $ret "Start application to trace"
}
function start_check_trace_app()
check_app_tmp_file
}
+
+function wait_trace_apps()
+{
+ for p in ${APPS_PID}; do
+ wait ${p} 2>/dev/null
+ done
+ APPS_PID=
+}
+
test_after_app_pid() {
local out
+ APPS_PID=
+
diag "Start application AFTER tracing is started"
create_lttng_session $SESSION_NAME $TRACE_PATH
# Make sure the application does not generate any more data,
# thus ensuring that we are not flushing a packet concurrently
# with validate_trace.
- killall -SIGSTOP -q $TESTAPP_NAME
+ for p in ${APPS_PID}; do
+ kill -s SIGSTOP ${p}
+ done
# Give time to the consumer to write inflight data.
sleep 2
validate_trace
out=$?
- killall -SIGKILL -q $TESTAPP_NAME
+ for p in ${APPS_PID}; do
+ kill -s SIGKILL ${p}
+ wait ${p} 2>/dev/null
+ done
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- wait
+ wait_trace_apps
return $out
}
local out
local tmp_file="/tmp/lttng_test_ust.42.file"
+ APPS_PID=
+
diag "Start application BEFORE tracing is started"
start_trace_app
# Make sure the application does not generate any more data,
# thus ensuring that we are not flushing a packet concurrently
# with validate_trace.
- killall -SIGSTOP -q $TESTAPP_NAME
+ for p in ${APPS_PID}; do
+ kill -s SIGSTOP ${p}
+ done
# Give time to the consumer to write inflight data.
sleep 2
validate_trace
out=$?
- killall -SIGKILL -q $TESTAPP_NAME
+ for p in ${APPS_PID}; do
+ kill -s SIGKILL ${p}
+ wait ${p} 2>/dev/null
+ done
+
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- wait
+ wait_trace_apps
return $out
}
test_after_app_uid() {
local out
+ APPS_PID=
+
diag "Start application AFTER tracing is started"
create_lttng_session $SESSION_NAME $TRACE_PATH
# Make sure the application does not generate any more data,
# thus ensuring that we are not flushing a packet concurrently
# with validate_trace.
- killall -SIGSTOP -q $TESTAPP_NAME
+ for p in ${APPS_PID}; do
+ kill -s SIGSTOP ${p}
+ done
+
# Give time to the consumer to write inflight data.
sleep 2
validate_trace
out=$?
- killall -SIGKILL -q $TESTAPP_NAME
+ for p in ${APPS_PID}; do
+ kill -s SIGKILL ${p}
+ wait ${p} 2>/dev/null
+ done
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- wait
+ wait_trace_apps
return $out
}
test_before_app_uid() {
local out
+ APPS_PID=
+
diag "Start application BEFORE tracing is started"
# Start application before tracing
# Make sure the application does not generate any more data,
# thus ensuring that we are not flushing a packet concurrently
# with validate_trace.
- killall -SIGSTOP -q $TESTAPP_NAME
+ for p in ${APPS_PID}; do
+ kill -s SIGSTOP ${p}
+ done
# Give time to the consumer to write inflight data.
sleep 2
validate_trace
out=$?
- killall -SIGKILL -q $TESTAPP_NAME
+ for p in ${APPS_PID}; do
+ kill -s SIGKILL ${p}
+ wait ${p} 2>/dev/null
+ done
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- wait
+ wait_trace_apps
return $out
}