File: test_multi_session

package info (click to toggle)
ltt-control 2.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,744 kB
  • sloc: cpp: 207,706; sh: 28,837; python: 18,952; ansic: 11,636; makefile: 3,362; java: 109; xml: 46
file content (93 lines) | stat: -rwxr-xr-x 2,815 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
#
# SPDX-FileCopyrightText: 2012 David Goulet <dgoulet@efficios.com>
# SPDX-FileCopyrightText: 2025 Michael Jeanson <mjeanson@efficios.com>
#
# SPDX-License-Identifier: LGPL-2.1-only

TEST_DESC="UST tracer - Multi-session"

CURDIR=$(dirname "$0")/
TESTDIR=$CURDIR/../../..

NR_ITER=100
NR_SESSION=4
SESSION_NAME="multi-session"
NUM_TESTS=28

TESTAPP_PATH="$TESTDIR/utils/testapp"
TESTAPP_NAME="gen-ust-nevents"
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME"
TESTAPP_TIMEOUT_SEC=10

EVENT_NAME="tp:tptest"

# shellcheck source-path=SCRIPTDIR/../../..
source "$TESTDIR/utils/utils.sh"


# MUST set TESTDIR before calling those functions

test_multi_session() {
	local testapp_pid
	local trace_path
	local file_testapp_output
	local file_sync_after_first
	local file_sync_before_last
	local file_sync_before_exit_touch

	# Prepare temp filenames but don't create them on disk
	trace_path=$(mktemp -d -t tmp.test_multi_session_ust.XXXXXX)
	file_testapp_output=$(mktemp -u -t "tmp.${FUNCNAME[0]}_testapp_output.XXXXXX")
	file_sync_after_first=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
	file_sync_before_last=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
	file_sync_before_exit_touch=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_exit_touch.XXXXXX")

	diag "Test UST with multiple sessions"

	# BEFORE application is spawned
	for i in $(seq 1 $NR_SESSION); do
		create_lttng_session_ok "$SESSION_NAME-$i" "$trace_path/$i"
		enable_ust_lttng_event_ok "$SESSION_NAME-$i" "$EVENT_NAME$i"
		start_lttng_tracing_ok "$SESSION_NAME-$i"
	done

	"$TESTAPP_BIN" -i $NR_ITER -w 0 \
		--sync-after-first-event "${file_sync_after_first}" \
		--sync-before-last-event "${file_sync_before_last}" \
		--sync-before-exit-touch "${file_sync_before_exit_touch}" >"${file_testapp_output}" 2>&1 &
	testapp_pid=$!
	diag "Launched testapp '$TESTAPP_NAME' (pid: $testapp_pid) to generate $NR_ITER events"

	# Wait for the testapp first event
	app_alive_wait_for_sync "$TESTAPP_NAME" "$testapp_pid" "$TESTAPP_TIMEOUT_SEC" "$file_testapp_output" "$file_sync_after_first"

	# Tell the testapp to continue
	touch "${file_sync_before_last}"

	# Wait for the testapp to signal completion by creating a file
	app_exit_wait_for_sync "$TESTAPP_NAME" "$testapp_pid" "$TESTAPP_TIMEOUT_SEC" "$file_testapp_output" "$file_sync_before_exit_touch"

	for i in $(seq 1 $NR_SESSION); do
		stop_lttng_tracing_ok "$SESSION_NAME-$i"
		destroy_lttng_session_ok "$SESSION_NAME-$i"

		trace_match_only "$EVENT_NAME$i" "$NR_ITER" "$trace_path/$i"
	done

	rm -rf "$trace_path"
	rm -f "$file_testapp_output"
	rm -f "$file_sync_after_first"
	rm -f "$file_sync_before_last"
	rm -f "$file_sync_before_exit_touch"
}

plan_tests $NUM_TESTS

print_test_banner "$TEST_DESC"

start_lttng_sessiond

test_multi_session

stop_lttng_sessiond