3 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 TEST_DESC
="UST - Namespace contexts"
9 CURDIR
=$
(dirname "$0")/
10 TESTDIR
=$CURDIR/..
/..
/..
12 TESTAPP_PATH
="$TESTDIR/utils/testapp"
13 TESTAPP_NAME
="gen-ust-events"
14 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
16 EVENT_NAME
="tp:tptest"
20 NUM_TESTS
=$
((TESTS_PER_NS
* 7))
22 source "$TESTDIR/utils/utils.sh"
24 # MUST set TESTDIR before calling those functions
27 $TESTAPP_BIN -i $NUM_EVENT
28 ok $?
"Application done"
35 local session_name
="${ns}_ns"
36 local chan_name
="${ns}_ns"
37 local context_name
="${ns}_ns"
42 # Check if the kernel has support for this ns type
43 if [ ! -f "/proc/$$/ns/$ns" ]; then
44 skip
0 "System has no $ns namespace support" $TESTS_PER_NS
48 # Get the current ns inode number
49 ns_inode
=$
(stat
-c '%i' -L "/proc/$$/ns/$ns")
50 ok $?
"Get current $ns namespace inode: $ns_inode"
52 trace_path
=$
(mktemp
-d)
56 create_lttng_session_ok
"$session_name" "$trace_path"
57 enable_ust_lttng_channel_ok
"$session_name" "$chan_name"
58 add_context_ust_ok
"$session_name" "$chan_name" "$context_name"
59 enable_ust_lttng_event_ok
"$session_name" "$EVENT_NAME" "$chan_name"
60 start_lttng_tracing_ok
"$session_name"
65 stop_lttng_tracing_ok
"$session_name"
66 destroy_lttng_session_ok
"$session_name"
69 # Check that the events contain the right namespace inode number
70 validate_trace_count
"${ns}_ns = $ns_inode" "$trace_path" $NUM_EVENT
78 print_test_banner
"$TEST_DESC"
81 if [ -d "/proc/$$/ns" ]; then
85 skip
$system_has_ns "System does not support namespaces" $NUM_TESTS && exit 0