# Start trace application and return once one event has been hit.
function start_test_app()
{
- local tmp_file="/tmp/lttng_test_ust.42.file"
+ local tmp_file=$(mktemp -u)
# Start application with a temporary file.
$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $tmp_file &
function start_test_app()
{
- local tmp_file="/tmp/lttng_test_ust.42.file"
+ local tmp_file=$(mktemp -u)
# Start application with a temporary file.
$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $tmp_file &
function test_ust_before_start ()
{
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
+
diag "Test UST streaming BEFORE tracing starts"
lttng_create_session_uri
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
# Run 5 times with a 1 second delay
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
-
- #FIXME: racy missing synchro
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
start_lttng_tracing $SESSION_NAME
+
+ touch ${file_sync_before_last}
+
# Wait for the applications started in background
wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
+ rm -f ${file_sync_after_first}
+ rm -f ${file_sync_before_last}
}
function test_ust_after_start ()
{
+ local file_sync_after_first=$(mktemp -u)
+
diag "Test UST streaming AFTER tracing starts"
lttng_create_session_uri
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
start_lttng_tracing $SESSION_NAME
# Run 5 times with a 1 second delay
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} >/dev/null 2>&1
- #FIXME: racy missing synchro
+ while [ ! -f "${file_sync_after_first}" ]; do
+ sleep 0.5
+ done
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
# Wait for the applications started in background
wait
+ rm -f ${file_sync_after_first}
}
plan_tests $NUM_TESTS
function test_after_apps()
{
local out
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
create_lttng_session $SESSION_NAME $TRACE_PATH
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} &
ok $? "Application started in background."
- #FIXME: racy missing synchronization
-
start_lttng_tracing $SESSION_NAME
+ 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=$?
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
- #FIXME: racy missing synchronization
-
# 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"
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"
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"
enable_channel_per_pid $SESSION_NAME "channel0"
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} &
ok $? "Start application to trace"
- #FIXME: racy missing synchronization
-
start_lttng_tracing $SESSION_NAME
+ 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"
local finest_tp=$1
local fire_second_tp=$2
+ #FIXME: app should have synchro.
java -cp $JAVA_CP -Djava.library.path="/usr/local/lib:/usr/lib" $TESTAPP_NAME $NR_ITER $NR_MSEC_WAIT $finest_tp $fire_second_tp >/dev/null 2>&1
}
function test_jul_before_start ()
{
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
+
diag "Test JUL application BEFORE tracing starts"
create_lttng_session $SESSION_NAME $TRACE_PATH
enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
# Run 5 times with a 1 second delay
run_app_background
- #FIXME: racy missing synchronization
-
start_lttng_tracing $SESSION_NAME
+ touch ${file_sync_before_last}
+
# Wait for the applications started in background
wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
+ rm -f ${file_sync_after_first}
+ rm -f ${file_sync_before_last}
+
# Validate test. Expecting all events.
trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
if [ $? -ne 0 ]; then
local debug_tp=$1
local fire_second_tp=$2
+ # FIXME: test app should have synchro.
java -cp $JAVA_CP -Djava.library.path="/usr/local/lib:/usr/lib" $TESTAPP_NAME $NR_ITER $NR_MSEC_WAIT $debug_tp $fire_second_tp >/dev/null 2>&1
}
function test_log4j_before_start ()
{
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
+
diag "Test LOG4J application BEFORE tracing starts"
create_lttng_session $SESSION_NAME $TRACE_PATH
enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
# Run 5 times with a 1 second delay
run_app_background
- #FIXME: racy missing synchronization
-
start_lttng_tracing $SESSION_NAME
+ touch ${file_sync_before_last}
+
# Wait for the applications started in background
wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
+ rm -f ${file_sync_after_first}
+ rm -f ${file_sync_before_last}
+
# Validate test. Expecting all events.
trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
if [ $? -ne 0 ]; then
# Start tests. Each is an infinite tracing loop.
+file_sync_after_first=$(mktemp -u)
+file_sync_before_last=$(mktemp -u)
+
diag "Starting $NUM_PROCESS test applications"
for i in `seq 1 $NUM_PROCESS`
do
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} >/dev/null 2>&1 &
APPS_PID="${APPS_PID} ${!}"
done
-#FIXME: racy missing synchronization
-
diag "Waiting for applications to be registered to sessiond"
reg_app_count=0
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
start_lttng_tracing $SESSION_NAME
+touch ${file_sync_before_last}
+
# We don't validate whether the applications have traced here, rather
# just that they registered to sessiond (above).
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
-#FIXME/TODO: add validation after fixing racy synchroniaation
+#TODO: add trace validation.
rm -rf $TRACE_PATH
APPS_PID=
pass "Stopped all spawned applications"
+rm -f ${file_sync_after_first}
+rm -f ${file_sync_before_last}
+
stop_lttng_sessiond
EVENT_NAME="tp:tptest"
BIN_NAME="gen-nevents"
NUM_TESTS=38
-APP_TMP_FILE="/tmp/lttng_test_ust.42.file"
+APP_TMP_FILE=$(mktemp -u)
APPS_PID=
source $TESTDIR/utils/utils.sh