--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2019 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# This is a common test for kernel and ust. DOMAIN must be set.
+
+
+TEST_DESC="Clear - ${DOMAIN} tracing"
+
+CURDIR=$(dirname "$0")/
+TESTDIR=$CURDIR/../../..
+SESSION_NAME=""
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_NAME="gen-ust-events"
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
+TESTPOINT=$(readlink -f "${CURDIR}/.libs/librelayd_state.so")
+
+NUM_CPUS=$(nproc)
+PAGE_SIZE=$(getconf PAGE_SIZE)
+
+
+source "$TESTDIR/utils/utils.sh"
+
+if [ "x$DOMAIN" == "x" ]; then
+ BAIL_OUT "This script must be called with DOMAIN set."
+fi
+
+function clean_path ()
+{
+ local trace_path=$1
+ rm -rf "${trace_path:?}"/*
+}
+
+function generate_events ()
+{
+ local cpu=$1
+ local nb=$2
+ if [ "$DOMAIN" == "kernel" ]; then
+ taskset -c "$cpu" echo -n "$nb" > /proc/lttng-test-filter-event
+ else
+ taskset -c "$cpu" "$TESTAPP_BIN" -i "$nb"
+ fi
+}
+
+function is_viewer_alive ()
+{
+ local viewer_pid=$1
+ jobs -p | grep "$viewer_pid" > /dev/null
+ return $?
+}
+
+function sync_attach_viewer ()
+{
+ local viewer_pid=$1
+ local state_path=$2
+ local sync_msg="Viewer attached"
+
+ while ! grep -q "$sync_msg" "$state_path"; do
+ if ! is_viewer_alive "$viewer_pid"; then
+ break
+ fi
+ diag "Waiting for viewer to attach"
+ sleep 0.5
+ done
+}
+
+function saturate_tracefile_rotation ()
+{
+ local session_name="$1"
+ local channel_name="$2"
+ local tracefile_count="$3"
+
+ local path="$TRACE_PATH"
+ local num_cpus="$NUM_CPUS"
+ local events_per_call=1000
+ local saturation_count=$((( tracefile_count * num_cpus )))
+ local file_pattern="${channel_name}_*"
+
+ # The number of event generation necessary to fill a single tracefile.
+ # We will use this to ensure that the tracefile rotation wrapped around.
+ local minimum_iteration_rotate=-1
+
+ local current_tracefile_count=0
+ counter=0
+ while [ "$current_tracefile_count" -lt "$saturation_count" ]; do
+ for i in $(seq 0 $(((num_cpus - 1)))); do
+ generate_events "$i" "$events_per_call"
+ done
+ # We need to stop & start to ensure that all data touch disk.
+ # This is useful in streaming mode where we do not have
+ # confirmation that data is present on disk otherwise.
+ stop_lttng_tracing_notap "$session_name"
+ start_lttng_tracing_notap "$session_name"
+ current_tracefile_count=$(find "$path" -name "$file_pattern" -type f \( ! -iname "*.idx" \) | wc -l)
+ if [ "$minimum_iteration_rotate" -eq "-1" ] && \
+ [ "$current_tracefile_count" -ge $(((2 * num_cpus))) ]; then
+ minimum_iteration_rotate="$counter"
+ fi
+ (( counter= counter + 1 ))
+ diag "Saturating tracefile rotation: $counter"
+ done
+
+ # Ensure that we wrap around.
+ for j in $(seq 0 "$minimum_iteration_rotate"); do
+ for i in $(seq 0 $(((num_cpus - 1)))); do
+ generate_events "$i" "$events_per_call"
+ done
+ diag "Saturating tracefile rotation wrap around: $j"
+ done
+ stop_lttng_tracing_notap "$session_name"
+ start_lttng_tracing_notap "$session_name"
+
+}
+
+# The session must be configured and started before calling this session.
+# The clear command will be issued before the stop command.
+function do_uid ()
+{
+ local session_name=$1
+ local trace_path=$2
+ local event_name=$3
+ local nb_iters=$4
+ local nb_events_per_iter=$5
+
+ # Generate nb_events_per_iter events that will be flushed to disk on
+ # stop, we want to validate that tracing works. They will also validate
+ # that cleaning of file on disks works.
+ generate_events 0 "$nb_events_per_iter"
+ stop_lttng_tracing_ok "$session_name"
+ validate_trace_count "$event_name" "$trace_path" "$nb_events_per_iter"
+
+ local i=0
+ while [[ "$i" -lt "$nb_iters" ]]; do
+ start_lttng_tracing_ok "$session_name"
+ # Generate $nb_events_per_iter events that will sit in the
+ # buffer. In live mode we cannot control the flushing still we
+ # expect the trace to be empty on the relayd. In case of live we
+ # expect all event to be present on the viewer side.
+ generate_events 0 "$nb_events_per_iter"
+
+ # Clear the session while active, this take care of both the
+ # buffers and data on disks. Expect an empty trace.
+ lttng_clear_session_ok "$session_name"
+ stop_lttng_tracing_ok "$session_name"
+ validate_trace_empty "$trace_path"
+ ((i = i + 1))
+ done
+
+ # Validate that tracing still works.
+ start_lttng_tracing_ok "$session_name"
+ generate_events 0 "$nb_events_per_iter"
+ stop_lttng_tracing_ok "$session_name"
+ validate_trace_count "$event_name" "$trace_path" "$nb_events_per_iter"
+
+ # Validate that clear while stopped works.
+ lttng_clear_session_ok "$session_name"
+ validate_trace_empty "$trace_path"
+}
+
+function test_streaming ()
+{
+ diag "Test ${DOMAIN} streaming clear"
+ create_lttng_session_uri "$SESSION_NAME" net://localhost
+ enable_"$DOMAIN"_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME"
+ start_lttng_tracing_ok "$SESSION_NAME"
+ do_uid "$SESSION_NAME" "$TRACE_PATH" "$EVENT_NAME" 100 10
+ destroy_lttng_session_ok "$SESSION_NAME"
+}
+
+# We cannot user babeltrace to validate live reception or buffer clearing when
+# the session is active due to the timing of the live timer that could influence
+# the number of event the viewer sees or not.
+function test_streaming_live_with_viewer ()
+{
+ local babeltrace_stdout
+ local babeltrace_stderr
+ local nb_iter=100
+ local nb_event_per_iter=1000
+ local events_expected=$(((2 + nb_iter) * nb_event_per_iter))
+ local url="net://127.0.0.1/host/${HOSTNAME}/${SESSION_NAME}"
+ local ret
+ local events_seen
+
+ babeltrace_stdout=$(mktemp)
+ babeltrace_stderr=$(mktemp)
+
+ diag "Test ${DOMAIN} streaming live clear hook viewer before clear"
+ create_lttng_session_uri "$SESSION_NAME" net://localhost "--live"
+ enable_"$DOMAIN"_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME"
+ start_lttng_tracing_ok "$SESSION_NAME"
+ # We use a testpoint inside lttng-relayd as a sync point to validate
+ # that the viewer is attached. We are looking for a string inside
+ # RELAYD_STATE_PATH. We need to bailout if the string is not found and
+ # babeltrace exited. Trash the stdout of babeltrace since we cannot
+ # infer anything from it.
+ $BABELTRACE_BIN -i lttng-live "$url" 1> /dev/null 2> "$babeltrace_stderr" &
+ babeltrace_pid=$!
+
+ sync_attach_viewer "$babeltrace_pid" "$RELAYD_STATE_PATH"
+
+ do_uid "$SESSION_NAME" "$TRACE_PATH" \
+ "$EVENT_NAME" \
+ "$nb_iter" \
+ "$nb_event_per_iter"
+
+ # Validate that the viewer is still alive
+ is_viewer_alive "$babeltrace_pid"
+ ok $? "Viewer is still alive"
+
+ # The viewer should detach itself on session destroy
+ destroy_lttng_session_ok "$SESSION_NAME"
+
+ wait "$babeltrace_pid"
+ ret=$?
+ ok $ret "Babeltrace exited with no error"
+ if [ "$ret" -ne "0" ]; then
+ diag "$(cat "$babeltrace_stderr")"
+ fi
+
+ rm -f "$babeltrace_stderr"
+}
+
+function test_streaming_live_attach_viewer_after_clear ()
+{
+ local babeltrace_stdout
+ local babeltrace_stderr
+ local ret
+ local events_seen
+ local nb_iter=10
+ local nb_event_per_iter=100
+ local events_expected=$nb_event_per_iter
+ local url="net://127.0.0.1/host/${HOSTNAME}/${SESSION_NAME}"
+
+ babeltrace_stdout=$(mktemp)
+ babeltrace_stderr=$(mktemp)
+
+ diag "Test ${DOMAIN} streaming live hook viewer after clear"
+ create_lttng_session_uri "$SESSION_NAME" net://localhost "--live"
+ enable_"$DOMAIN"_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME"
+ start_lttng_tracing_ok "$SESSION_NAME"
+ do_uid "$SESSION_NAME" "$TRACE_PATH" \
+ "$EVENT_NAME" \
+ "$nb_iter" \
+ "$nb_event_per_iter"
+
+ "$BABELTRACE_BIN" -i lttng-live "$url" 1> "$babeltrace_stdout" 2> "$babeltrace_stderr" &
+ babeltrace_pid=$!
+ sync_attach_viewer "$babeltrace_pid" "$RELAYD_STATE_PATH"
+
+ start_lttng_tracing_ok "$SESSION_NAME"
+
+ # We only expect these last events.
+ generate_events 0 "$nb_event_per_iter"
+
+ stop_lttng_tracing_ok "$session_name"
+ destroy_lttng_session_ok "$SESSION_NAME"
+
+ wait "$babeltrace_pid"
+ ret=$?
+ ok $ret "Babeltrace exited with no error"
+ if [ "$ret" -ne "0" ]; then
+ diag "$(cat "$babeltrace_stderr")"
+ fi
+
+ # TODO: sometime the viewer does not see 100 events... not sure why yet.
+ # Does not seems related to clear.
+ #events_seen=$(cat "$babeltrace_stdout" | wc -l)
+ #test $events_seen -eq $events_expected
+ #ok $? "Viewer saw the expected number of event: ${events_seen}/${events_expected}"
+
+ rm -f "$babeltrace_stdout"
+ rm -f "$babeltrace_stderr"
+}
+
+function test_local ()
+{
+ diag "Test ${DOMAIN} local"
+ create_lttng_session_ok "$SESSION_NAME" "$TRACE_PATH"
+ enable_"$DOMAIN"_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME"
+ start_lttng_tracing_ok "$SESSION_NAME"
+ do_uid "$SESSION_NAME" "$TRACE_PATH" "$EVENT_NAME" 100 10
+ destroy_lttng_session_ok "$SESSION_NAME"
+}
+
+function do_snapshot ()
+{
+ local session_name=$1
+ local trace_path=$2
+
+ enable_"$DOMAIN"_lttng_event_ok "$session_name" "$EVENT_NAME"
+ start_lttng_tracing_ok "$session_name"
+
+ # Generate 10 events that will sit in the buffers.
+ generate_events 0 10
+
+ # Take a first snapshot and validate that the events are present.
+ lttng_snapshot_record "$session_name"
+ stop_lttng_tracing_ok "$session_name"
+ validate_trace_count "$EVENT_NAME" "$trace_path" 10
+
+ # Clean the output path
+ clean_path "$trace_path"
+ start_lttng_tracing_ok "$session_name"
+
+ lttng_clear_session_ok "$session_name"
+
+ # Make sure the subsequent snapshot is empty and valid.
+ lttng_snapshot_record "$session_name"
+ stop_lttng_tracing_ok "$session_name"
+ validate_trace_empty "$trace_path"
+
+ # Clean the output path
+ clean_path "$trace_path"
+ start_lttng_tracing_ok "$session_name"
+
+ # Make sure that everything still works, generate events and take a
+ # snapshot.
+ generate_events 0 10
+ lttng_snapshot_record "$session_name"
+ stop_lttng_tracing_ok "$session_name"
+ validate_trace_count "$EVENT_NAME" "$trace_path" 10
+}
+
+function test_streaming_snapshot ()
+{
+ diag "Test $DOMAIN streaming snapshot clear"
+
+ create_lttng_session_uri "$SESSION_NAME" net://localhost "--snapshot"
+ do_snapshot "$SESSION_NAME" "$TRACE_PATH"
+ destroy_lttng_session_ok "$SESSION_NAME"
+}
+
+function test_local_snapshot ()
+{
+ diag "Test $DOMAIN local snapshot clear"
+
+ create_lttng_session_ok "$SESSION_NAME" "$TRACE_PATH" "--snapshot"
+ do_snapshot "$SESSION_NAME" "$TRACE_PATH"
+ destroy_lttng_session_ok "$SESSION_NAME"
+}
+
+function test_ust_local_snapshot_per_pid ()
+{
+ local file_sync_before_last
+ local file_sync_before_last_touch
+ local file_sync_before_exit
+ local file_sync_before_exit_touch
+ local channel_name="channel0"
+
+ file_sync_before_last=$(mktemp -u)
+ file_sync_before_last_touch=$(mktemp -u)
+ file_sync_before_exit=$(mktemp -u)
+ file_sync_before_exit_touch=$(mktemp -u)
+
+ diag "Test ust local snapshot clear per pid "
+
+ create_lttng_session_ok "$SESSION_NAME" "$TRACE_PATH" "--snapshot"
+ enable_ust_lttng_channel_ok "$SESSION_NAME" "$channel_name" "--buffers-pid"
+ enable_ust_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME" "$channel_name"
+ start_lttng_tracing_ok "$SESSION_NAME"
+
+ # Generate 10 events that will sit in the buffers.
+ "$TESTAPP_BIN" -i 10 -w 0 \
+ --sync-before-last-event "$file_sync_before_last" \
+ --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 &
+
+ # Continue only when there is only the last event remaining.
+ while [ ! -f "$file_sync_before_last_touch" ]; do
+ sleep 0.5
+ done
+
+ # Take a first snapshot and validate that the events are present.
+ lttng_snapshot_record "$SESSION_NAME"
+ stop_lttng_tracing_ok "$SESSION_NAME"
+ validate_trace_count "$EVENT_NAME" "$TRACE_PATH" 9
+
+ # Clean the output path
+ clean_path "$TRACE_PATH"
+ start_lttng_tracing_ok "$SESSION_NAME"
+
+ lttng_clear_session_ok "$SESSION_NAME"
+
+ # Make sure the subsequent snapshot is empty and valid.
+ lttng_snapshot_record "$SESSION_NAME"
+ stop_lttng_tracing_ok "$SESSION_NAME"
+ validate_trace_empty "$TRACE_PATH"
+
+ # Validate that tracing still works and subsequent snapshots are valid.
+ # Clean the output path.
+ clean_path "$TRACE_PATH"
+ start_lttng_tracing_ok "$SESSION_NAME"
+
+ # Continue over the last event.
+ touch "$file_sync_before_last"
+
+ # 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
+ done
+
+ # Make sure the snapshot contains the last event.
+ lttng_snapshot_record "$SESSION_NAME"
+ stop_lttng_tracing_ok "$SESSION_NAME"
+ validate_trace_count "$EVENT_NAME" "$TRACE_PATH" 1
+
+ # Release the application.
+ touch "$file_sync_before_exit"
+ wait
+ destroy_lttng_session_ok "$SESSION_NAME"
+
+ rm -f "$file_sync_before_last"
+ rm -f "$file_sync_before_last_touch"
+ rm -f "$file_sync_before_exit"
+ rm -f "$file_sync_before_exit_touch"
+}
+
+function test_relayd_dissalow_clear ()
+{
+ diag "Test lttng-relayd disallow clear"
+ start_lttng_relayd "-o $TRACE_PATH --disallow-clear"
+ start_lttng_sessiond
+
+ create_lttng_session_uri "$SESSION_NAME" net://localhost "--live"
+ enable_"$DOMAIN"_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME"
+ start_lttng_tracing_ok "$SESSION_NAME"
+
+ generate_events 0 1
+
+ lttng_clear_session_fail "$SESSION_NAME"
+
+ destroy_lttng_session_ok "$SESSION_NAME"
+
+ stop_lttng_sessiond
+ stop_lttng_relayd
+}
+
+function test_per_pid ()
+{
+ local channel_name=chan
+ diag "Test clear on per-pid session"
+ create_lttng_session_ok "$SESSION_NAME" "$TRACE_PATH"
+ enable_"$DOMAIN"_lttng_channel_ok "$SESSION_NAME" $channel_name --buffers-pid
+ enable_"$DOMAIN"_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME" $channel_name
+ start_lttng_tracing_ok "$SESSION_NAME"
+
+ # Per pid is not supported in this version. Clear must fail.
+ lttng_clear_session_fail "$SESSION_NAME"
+
+ destroy_lttng_session_ok "$SESSION_NAME"
+}
+
+function test_local_tracefile_rotation ()
+{
+ local channel_name="over9000"
+ local tracefile_count=6
+ local tracefile_size=$(((3 * PAGE_SIZE)))
+ local iteration=5
+
+ diag "Test ${DOMAIN} local with tracefile rotation"
+ create_lttng_session_ok "$SESSION_NAME" "$TRACE_PATH"
+ enable_"$DOMAIN"_lttng_channel_ok "$SESSION_NAME" $channel_name \
+ "--tracefile-count $tracefile_count --tracefile-size $tracefile_size --overwrite"
+ enable_"$DOMAIN"_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME" $channel_name
+ start_lttng_tracing_ok "$SESSION_NAME"
+
+ # Saturate the tracefile.
+ for i in $(seq 0 $iteration); do
+ saturate_tracefile_rotation "$SESSION_NAME" "$channel_name" "$tracefile_count"
+ lttng_clear_session_ok "$session_name"
+ stop_lttng_tracing_ok "$session_name"
+ validate_trace_empty "$TRACE_PATH"
+ lttng_clear_session_ok "$session_name"
+ start_lttng_tracing_ok "$session_name"
+ done
+
+ destroy_lttng_session_ok "$SESSION_NAME"
+}
+
+function test_streaming_tracefile_rotation ()
+{
+ local channel_name="over9000"
+ local tracefile_count=6
+ local tracefile_size=$(((3 * PAGE_SIZE)))
+ local iteration=5
+
+ diag "Test ${DOMAIN} streamin with tracefile rotation"
+ create_lttng_session_uri "$SESSION_NAME" net://localhost
+ enable_"$DOMAIN"_lttng_channel_ok "$SESSION_NAME" "$channel_name" \
+ "--tracefile-count $tracefile_count --tracefile-size $tracefile_size --overwrite"
+ enable_"$DOMAIN"_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME" "$channel_name"
+ start_lttng_tracing_ok "$SESSION_NAME"
+
+ # Saturate the tracefile.
+ for i in $(seq 0 $iteration); do
+ saturate_tracefile_rotation "$SESSION_NAME" "$channel_name" "$tracefile_count"
+ lttng_clear_session_ok "$session_name"
+ stop_lttng_tracing_ok "$session_name"
+ validate_trace_empty "$TRACE_PATH"
+ lttng_clear_session_ok "$session_name"
+ start_lttng_tracing_ok "$session_name"
+ done
+
+ destroy_lttng_session_ok "$SESSION_NAME"
+}
+
+function test_streaming_live_tracefile_rotation_with_viewer ()
+{
+ local babeltrace_stderr
+ local channel_name="over9000"
+ local tracefile_count=6
+ local tracefile_size=$(((3 * PAGE_SIZE)))
+ local iteration=2
+ local babeltrace_pid
+ local url="net://127.0.0.1/host/${HOSTNAME}/${SESSION_NAME}"
+
+ babeltrace_stderr=$(mktemp)
+
+
+ diag "Test ${DOMAIN} streaming live with tracefile rotation viewer attached"
+ create_lttng_session_uri "$SESSION_NAME" net://localhost "--live"
+ enable_"$DOMAIN"_lttng_channel_ok "$SESSION_NAME" "$channel_name" \
+ "--tracefile-count $tracefile_count --tracefile-size $tracefile_size --overwrite"
+ enable_"$DOMAIN"_lttng_event_ok "$SESSION_NAME" "$EVENT_NAME" "$channel_name"
+ start_lttng_tracing_ok "$SESSION_NAME"
+
+ $BABELTRACE_BIN -i lttng-live "$url" 1> /dev/null 2> "$babeltrace_stderr" &
+ babeltrace_pid=$!
+
+ sync_attach_viewer "$babeltrace_pid" "$RELAYD_STATE_PATH"
+
+ # Saturate the tracefile.
+ for i in $(seq 0 $iteration); do
+ saturate_tracefile_rotation "$SESSION_NAME" "$channel_name" "$tracefile_count"
+ lttng_clear_session_ok "$session_name"
+ stop_lttng_tracing_ok "$session_name"
+ validate_trace_empty "$TRACE_PATH"
+ lttng_clear_session_ok "$session_name"
+ start_lttng_tracing_ok "$session_name"
+ done
+
+ # Validate that the viewer is still alive.
+ is_viewer_alive "$babeltrace_pid"
+ ok $? "Viewer is still alive"
+
+ # The viewer should detach on destroy.
+ destroy_lttng_session_ok "$SESSION_NAME"
+
+ wait "$babeltrace_pid"
+ ret=$?
+ ok "$ret" "Babeltrace exited with no error"
+ if [ "$ret" -ne "0" ]; then
+ diag "$(cat "$babeltrace_stderr")"
+ fi
+
+ rm -f "$babeltrace_stderr"
+}
+
+if [ "$DOMAIN" == "ust" ]; then
+ NUM_TESTS=1438
+elif [ "$DOMAIN" == "kernel" ]; then
+ NUM_TESTS=1429
+else
+ BAIL_OUT "Invalid domain: $DOMAIN"
+fi
+
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+tests=(
+ test_local
+ test_local_snapshot
+ test_local_tracefile_rotation
+ test_streaming
+ test_streaming_snapshot
+ test_streaming_tracefile_rotation
+ test_streaming_live_with_viewer
+ test_streaming_live_attach_viewer_after_clear
+ test_streaming_live_tracefile_rotation_with_viewer
+)
+
+if [ "$DOMAIN" == "ust" ]; then
+ if [ ! -x "$TESTAPP_BIN" ]; then
+ BAIL_OUT "No UST events binary detected."
+ fi
+ test+=(
+ test_ust_local_snapshot_per_pid
+ test_per_pid
+ )
+ EVENT_NAME="tp:tptest"
+else
+ # Kernel domain
+ if [ "$(id -u)" -ne "0" ]; then
+ skip 0 "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS && exit 0
+ fi
+ validate_lttng_modules_present
+ EVENT_NAME="lttng_test_filter_event"
+fi
+
+
+TRACE_PATH=$(mktemp -d)
+RELAYD_STATE_PATH=$(mktemp)
+TESTPOINT_ARGS="RELAYD_STATE_PATH=${RELAYD_STATE_PATH} LTTNG_TESTPOINT_ENABLE=1"
+LTTNG_RELAYD_ENV_VARS="$TESTPOINT_ARGS LD_PRELOAD=$TESTPOINT"
+
+start_lttng_relayd "-o $TRACE_PATH"
+start_lttng_sessiond
+
+if [ "$DOMAIN" == "kernel" ]; then
+ modprobe lttng-test
+fi
+
+
+for fct_test in "${tests[@]}";
+do
+ SESSION_NAME=$(randstring 16 0)
+ ${fct_test}
+ clean_path "$TRACE_PATH"
+ # Truncate the RELAYD_STATE_PATH file
+ : > "$RELAYD_STATE_PATH"
+done
+
+if [ "$DOMAIN" == "kernel" ]; then
+ rmmod lttng-test
+fi
+
+stop_lttng_sessiond
+stop_lttng_relayd
+
+if [ "$DOMAIN" == "ust" ]; then
+ # This test control how lttng-relayd is started. Do it after everything else.
+ test_relayd_dissalow_clear
+fi
+
+rm -f "$RELAYD_STATE_PATH"