TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
NUM_TESTS=2071
-
+DELAYUS=500000
+LIVEVIEWER_TIMEOUT=10 # Timeout in seconds
PAGE_SIZE=$(getconf PAGE_SIZE)
-TRACE_PATH=$(mktemp --tmpdir -d tmp.test_clear_ust_trace_path.XXXXXX)
+TRACE_PATH=$(mktemp -d -t tmp.test_clear_ust_trace_path.XXXXXX)
-source $TESTDIR/utils/utils.sh
+# shellcheck source=../utils/utils.sh
+source "$TESTDIR/utils/utils.sh"
if [ ! -x "$TESTAPP_BIN" ]; then
BAIL_OUT "No UST events binary detected."
fi
fi
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function test_ust_streaming_no_event ()
validate_directory_empty "$local_path"
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function test_ust_streaming_rotate_clear ()
fi
validate_trace_count $EVENT_NAME $local_path $expect_count
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function test_ust_streaming_clear_rotate ()
fi
validate_trace_count $EVENT_NAME $local_path $expect_count
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function test_ust_streaming_live ()
diag "Test ust streaming live clear"
diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
- create_lttng_session_uri $SESSION_NAME net://localhost "--live"
+ create_lttng_session_uri $SESSION_NAME net://localhost "--live=${DELAYUS}"
enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
start_lttng_tracing_ok $SESSION_NAME
validate_directory_empty $local_path
fi
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
#no clear
local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
local remote_trace_path="${HOSTNAME}/${SESSION_NAME}"
local channel_name="chan"
- local bt_output_path=$(mktemp --tmpdir -u tmp.test_${FUNCNAME[0]}_bt_output_path.XXXXXX)
- local file_sync_before_exit=$(mktemp --tmpdir -u tmp.test_${FUNCNAME[0]}_sync_before_exit.XXXXXX)
+ local bt_output_path=$(mktemp -u -t tmp.test_${FUNCNAME[0]}_bt_output_path.XXXXXX)
+ local file_sync_before_exit=$(mktemp -u -t tmp.test_${FUNCNAME[0]}_sync_before_exit.XXXXXX)
diag "Test ust basic streaming live with viewer"
diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
- create_lttng_session_uri $SESSION_NAME net://localhost "--live"
+ create_lttng_session_uri $SESSION_NAME net://localhost "--live=${DELAYUS}"
enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
start_lttng_tracing_ok $SESSION_NAME
wait_live_trace_ready net://localhost
# Connect a live viewer
- $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path &
+ _run_babeltrace_cmd -i lttng-live net://localhost/host/$remote_trace_path --params=session-not-found-action=end 1> $bt_output_path &
local viewer_pid=$!
+ local viewer_iter=0
wait_live_viewer_connect net://localhost
local evcount=0
while [ $evcount -ne 10 ]; do
evcount=$(cat $bt_output_path | wc -l)
- sleep 0.5
+ sleep 0.1
+ viewer_iter=$((viewer_iter + 1))
+ if [ "${viewer_iter}" -gt $((LIVEVIEWER_TIMEOUT * 10)) ] ; then
+ break;
+ fi
done
- pass "Live viewer read $evcount events, expect 10"
+ is "${evcount}" 10 "Live viewer read $evcount events, expect 10"
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
touch $file_sync_before_exit
diag "Waiting for application to exit"
wait $app_pid
local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
local remote_trace_path="${HOSTNAME}/${SESSION_NAME}"
local channel_name="chan"
- local bt_output_path=$(mktemp --tmpdir -u tmp.test_${FUNCNAME[0]}_bt_output_path.XXXXXX)
+ local bt_output_path=$(mktemp -u -t tmp.test_${FUNCNAME[0]}_bt_output_path.XXXXXX)
diag "Test ust streaming live clear with viewer"
diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
- create_lttng_session_uri $SESSION_NAME net://localhost "--live"
+ create_lttng_session_uri $SESSION_NAME net://localhost "--live=${DELAYUS}"
enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
start_lttng_tracing_ok $SESSION_NAME
wait_live_trace_ready net://localhost
# Connect a live viewer
- $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path &
+ _run_babeltrace_cmd -i lttng-live net://localhost/host/$remote_trace_path --params=session-not-found-action=end 1> $bt_output_path &
local viewer_pid=$!
wait_live_viewer_connect net://localhost
do_clear_session $SESSION_NAME $tracing_active $clear_twice 0 0
stop_lttng_tracing_ok $SESSION_NAME
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
diag "Wait for viewer to exit"
wait $viewer_pid
ok $? "Babeltrace succeeds"
local remote_trace_path="${HOSTNAME}/${SESSION_NAME}"
local channel_name="chan"
- local bt_output_path=$(mktemp --tmpdir -t "tmp.${FUNCNAME[0]}_bt_output.XXXXXX")
- local bt_error_path=$(mktemp --tmpdir -t "tmp.${FUNCNAME[0]}_bt_error.XXXXXX")
- local file_sync_before_exit=$(mktemp --tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
+ local bt_output_path=$(mktemp -t "tmp.${FUNCNAME[0]}_bt_output.XXXXXX")
+ local file_sync_before_exit=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
diag "Test ust streaming live clear with viewer with new metadata after clear"
diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
- create_lttng_session_uri "$SESSION_NAME" net://localhost "--live"
+ create_lttng_session_uri "$SESSION_NAME" net://localhost "--live=${DELAYUS}"
enable_ust_lttng_channel_ok "$SESSION_NAME" $channel_name "--buffers-$buffer_type"
# The vpid context is added to filter events based on the vpid of the
wait_live_trace_ready net://localhost
# Connect a live viewer
- $BABELTRACE_BIN -i lttng-live "net://localhost/host/$remote_trace_path" 1> "$bt_output_path" 2> "$bt_error_path" &
+ _run_babeltrace_cmd -i lttng-live "net://localhost/host/$remote_trace_path" --params=session-not-found-action=end 1> "$bt_output_path" &
local viewer_pid=$!
+ local viewer_iter=0
wait_live_viewer_connect net://localhost
local evcount=0
while [ $evcount -ne 10 ]; do
evcount=$(wc -l < "$bt_output_path")
- sleep 0.5
+ sleep 0.1
+ viewer_iter=$((viewer_iter + 1))
+ if [ "${viewer_iter}" -gt $((LIVEVIEWER_TIMEOUT * 10)) ] ; then
+ break
+ fi
done
- pass "Live viewer read $evcount events, expect 10"
+ is "${evcount}" 10 "Live viewer read $evcount events, expect 10"
do_clear_session "$SESSION_NAME" "$tracing_active" "$clear_twice" 0 0
diag "Wait until viewer sees all 12 expected events"
local evcount=0
+ local viewer_iter=0
while [ $evcount -ne 12 ]; do
evcount=$(wc -l < "$bt_output_path")
- sleep 0.5
+ sleep 0.1
+ viewer_iter=$((viewer_iter + 1))
+ if [ "${viewer_iter}" -gt $((LIVEVIEWER_TIMEOUT * 10)) ]; then
+ break
+ fi
done
- pass "Live viewer read $evcount events, expect 12"
+ is "${evcount}" 12 "Live viewer read $evcount events, expect 12"
stop_lttng_tracing_ok "$SESSION_NAME"
- destroy_lttng_session_ok "$SESSION_NAME"
+ destroy_lttng_session_ok "$SESSION_NAME" --no-wait
touch "$file_sync_before_exit"
diag "Waiting for application to exit"
pass "Wait for viewer to exit"
clean_path "$bt_output_path"
- clean_path "$bt_error_path"
rm -f "$file_sync_before_exit"
}
fi
fi
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function test_ust_local_no_event ()
validate_directory_empty "$TRACE_PATH"
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function test_ust_local_rotate_clear ()
fi
validate_trace_count $EVENT_NAME $TRACE_PATH $expect_count
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function test_ust_local_clear_rotate ()
fi
validate_trace_count $EVENT_NAME $TRACE_PATH $expect_count
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function do_ust_snapshot ()
create_lttng_session_uri $SESSION_NAME net://localhost "--snapshot"
do_ust_snapshot $SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function test_ust_local_snapshot ()
create_lttng_session_ok $SESSION_NAME $TRACE_PATH "--snapshot"
do_ust_snapshot $SESSION_NAME $TRACE_PATH $tracing_active $clear_twice $buffer_type
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
# snapshot for per-pid is tested independently of the "buffer type" parameter
# 3, 4 unused.
local buffer_type=$5
local channel_name="channel0"
- local file_sync_before_last=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
- local file_sync_before_last_touch=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_last_touch.XXXXXX")
- local file_sync_before_exit=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
- local file_sync_before_exit_touch=$(mktemp --tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_before_exit_touch.XXXXXX")
+ local file_sync_before_last=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
+ local file_sync_before_last_touch=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_last_touch.XXXXXX")
+ local file_sync_before_exit=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX")
+ local file_sync_before_exit_touch=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_exit_touch.XXXXXX")
diag "Test ust local snapshot clear per pid"
diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type"
--sync-before-last-event-touch ${file_sync_before_last_touch} \
--sync-before-exit ${file_sync_before_exit} \
--sync-before-exit-touch ${file_sync_before_exit_touch} >/dev/null 2>&1 &
+ local app_pid="${!}"
# Continue only when there is only the last event remaining.
while [ ! -f "${file_sync_before_last_touch}" ]; do
- sleep 0.5
+ sleep 0.1
done
# Take a first snapshot and validate that the events are present.
# Wait for the before exit sync point. This ensure that we went over the
# last tracepoint.
while [ ! -f "${file_sync_before_exit_touch}" ]; do
- sleep 0.5
+ sleep 0.1
done
# Make sure the snapshot contains the last event.
# Release the application.
touch ${file_sync_before_exit}
- wait
- destroy_lttng_session_ok $SESSION_NAME
+ wait "${app_pid}"
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
rm -f ${file_sync_before_last}
rm -f ${file_sync_before_last_touch}
validate_trace_count $EVENT_NAME $local_path 20
fi
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
# With 1 byte per event (as strict minimum), generating 200000 events
--tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
start_lttng_tracing_ok $SESSION_NAME
- taskset -c 0 $TESTAPP_BIN -i 200000
+ taskset -c "$(get_any_available_cpu)" $TESTAPP_BIN -i 200000
do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
stop_lttng_tracing_ok $SESSION_NAME
fi
start_lttng_tracing_ok $SESSION_NAME
- taskset -c 0 $TESTAPP_BIN -i 400000
+ taskset -c "$(get_any_available_cpu)" $TESTAPP_BIN -i 400000
stop_lttng_tracing_ok
if [[ $rotate_before -eq 1 ]]; then
validate_trace_count_range_incl_min_excl_max $EVENT_NAME $local_path 1 200000
fi
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
}
function test_ust_disallow_clear ()
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
start_lttng_tracing_ok $SESSION_NAME
lttng_clear_session_fail $SESSION_NAME
- destroy_lttng_session_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME --no-wait
stop_lttng_sessiond
stop_lttng_relayd
print_test_banner "$TEST_DESC"
+bail_out_if_no_babeltrace
+
streaming_tests=(test_ust_streaming
test_ust_streaming_rotate_clear
test_ust_streaming_clear_rotate
stop_lttng_relayd
test_ust_disallow_clear
+
+rm -rf "$TRACE_PATH"