Debian Codegraph @

tests/regression/tools/regen-statedump/test_ust

raw symbols SCIP
1 #!/bin/bash
2 #
3 # SPDX-FileCopyrightText: 2016 Julien Desfossez <[email protected]>
4 # SPDX-FileCopyrightText: 2025 Michael Jeanson <[email protected]>
5 #
6 # SPDX-License-Identifier: LGPL-2.1-only
7
8 TEST_DESC="Regenerate the statedump - User-space tracing"
9
10 CURDIR=$(dirname "$0")/
11 TESTDIR=$CURDIR/../../..
12
13 NR_ITER=10
14 NR_USEC_WAIT=0
15
16 TESTAPP_PATH="$TESTDIR/utils/testapp"
17 TESTAPP_NAME="gen-ust-events"
18 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME"
19 TESTAPP_TIMEOUT_SEC=10
20
21 NUM_TESTS=13
22
23 # shellcheck source-path=SCRIPTDIR/../../..
24 source "$TESTDIR/utils/utils.sh"
25
26 if [ ! -x "$TESTAPP_BIN" ]; then
27 BAIL_OUT "No UST events binary detected."
28 fi
29
30 function test_regenerate_statedump_ust ()
31 {
32 local session_name="regen-statedump-ust"
33 local event_name="lttng_ust_statedump:start,lttng_ust_statedump:end"
34
35 local ret
36 local testapp_pid
37 local trace_path
38 local file_testapp_output
39 local file_sync_after_first
40 local file_sync_before_last
41 local file_sync_before_exit_touch
42
43 trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
44
45 file_testapp_output=$(mktemp -u -t "tmp.${FUNCNAME[0]}_testapp_output.XXXXXX")
46 file_sync_after_first=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
47 file_sync_before_last=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
48 file_sync_before_exit_touch=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_exit_touch.XXXXXX")
49
50 diag "Test UST local with statedump regeneration"
51
52 create_lttng_session_ok $session_name "$trace_path"
53 enable_ust_lttng_event_ok $session_name $event_name
54
55 "$TESTAPP_BIN" -i $NR_ITER -w $NR_USEC_WAIT \
56 --sync-after-first-event "${file_sync_after_first}" \
57 --sync-before-last-event "${file_sync_before_last}" \
58 --sync-before-exit-touch "${file_sync_before_exit_touch}" >"${file_testapp_output}" 2>&1 &
59 testapp_pid=$!
60 diag "Launched testapp '$TESTAPP_NAME' (pid: $testapp_pid) to generate $NR_ITER events"
61
62 start_lttng_tracing_ok $session_name
63
64 # Wait for the testapp first event
65 app_alive_wait_for_sync "$TESTAPP_NAME" "$testapp_pid" "$TESTAPP_TIMEOUT_SEC" "$file_testapp_output" "$file_sync_after_first"
66
67 regenerate_statedump_ok $session_name
68
69 # Tell the testapp to continue
70 touch "${file_sync_before_last}"
71
72 app_exit_wait_for_sync "$TESTAPP_NAME" "$testapp_pid" "$TESTAPP_TIMEOUT_SEC" "$file_testapp_output" "$file_sync_before_exit_touch"
73
74 stop_lttng_tracing_ok $session_name
75 destroy_lttng_session_ok $session_name
76
77 validate_trace_count $event_name "$trace_path" 4
78
79 rm -rf "$trace_path"
80 rm -f "$file_testapp_output"
81 rm -f "$file_sync_after_first"
82 rm -f "$file_sync_before_last"
83 rm -f "$file_sync_before_exit_touch"
84 }
85
86 plan_tests $NUM_TESTS
87
88 print_test_banner "$TEST_DESC"
89 bail_out_if_no_babeltrace
90
91 start_lttng_sessiond
92
93 test_regenerate_statedump_ust
94
95 stop_lttng_sessiond