Tests: Fix: Use '.logfile' instead of '.log' for test app output
[lttng-tools.git] / tests / regression / ust / namespaces / test_ns_contexts
1 #!/bin/bash
2 #
3 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
4 #
5 # SPDX-License-Identifier: LGPL-2.1-only
6
7 TEST_DESC="UST - Namespace contexts"
8
9 CURDIR=$(dirname "$0")/
10 TESTDIR=$CURDIR/../../..
11
12 TESTAPP_PATH="$TESTDIR/utils/testapp"
13 TESTAPP_NAME="gen-ust-events"
14 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
15 NUM_EVENT=1000
16 EVENT_NAME="tp:tptest"
17
18 TESTS_PER_NS=13
19
20 NUM_TESTS=$((TESTS_PER_NS * 8))
21
22 source "$TESTDIR/utils/utils.sh"
23
24 # MUST set TESTDIR before calling those functions
25 function run_app()
26 {
27 $TESTAPP_BIN -i $NUM_EVENT
28 ok $? "Application done"
29 }
30
31 function test_ns()
32 {
33 local ns=$1
34
35 local session_name="${ns}_ns"
36 local chan_name="${ns}_ns"
37 local context_name="${ns}_ns"
38 local trace_path
39 local ns_inode
40
41 # Check if the kernel has support for this ns type
42 if [ ! -f "/proc/$$/ns/$ns" ]; then
43 skip 0 "System has no $ns namespace support" $TESTS_PER_NS
44 return
45 fi
46
47 trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
48
49 # Get the current ns inode number
50 ns_inode=$(stat -c '%i' -L "/proc/$$/ns/$ns")
51 ok $? "Get current $ns namespace inode: $ns_inode"
52
53 start_lttng_sessiond
54
55 create_lttng_session_ok "$session_name" "$trace_path"
56 enable_ust_lttng_channel_ok "$session_name" "$chan_name"
57 add_context_ust_ok "$session_name" "$chan_name" "$context_name"
58 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$chan_name"
59 start_lttng_tracing_ok "$session_name"
60
61 run_app
62
63 # stop and destroy
64 stop_lttng_tracing_ok "$session_name"
65 destroy_lttng_session_ok "$session_name"
66 stop_lttng_sessiond
67
68 # Check that the events contain the right namespace inode number
69 validate_trace_count "${ns}_ns = $ns_inode" "$trace_path" $NUM_EVENT
70
71 rm -rf "$trace_path"
72 }
73
74
75 plan_tests $NUM_TESTS
76
77 print_test_banner "$TEST_DESC"
78
79 bail_out_if_no_babeltrace
80
81 system_has_ns=0
82 if [ -d "/proc/$$/ns" ]; then
83 system_has_ns=1
84 fi
85
86 skip $system_has_ns "System does not support namespaces" $NUM_TESTS && exit 0
87
88 test_ns cgroup
89 test_ns ipc
90 test_ns mnt
91 test_ns net
92 test_ns pid
93 test_ns time
94 test_ns user
95 test_ns uts
This page took 0.037226 seconds and 5 git commands to generate.