Extract spawn sessiond to utils function
[deliverable/lttng-ivc.git] / lttng_ivc / tests / ust_app_vs_ust_tools / test_ust_app_vs_ust_tools.py
CommitLineData
e93e3f39
JR
1import pytest
2import os
3import shutil
4import signal
5import subprocess
6
7import lttng_ivc.utils.ProjectFactory as ProjectFactory
8import lttng_ivc.utils.utils as utils
9import lttng_ivc.utils.runtime as Run
10import lttng_ivc.settings as Settings
11
12"""
13
14FC: Fully Compatible
15BC: Feature of the smallest version number will works.
16TU: Tracing unavailable
17
18+------------------------------------------------------------------------------+
19| LTTng UST control protocol compatibility matrix |
20| (between applications and tools linked on LTTng UST and liblttng-ust-ctl) |
21+--------------------------+------------+------------+------------+------------+
22| LTTng UST / LTTng Tools | 2.7 (6.0) | 2.8 (6.1) | 2.9 (7.1) | 2.10 (7.2) |
23+--------------------------+------------+------------+------------+------------+
24| 2.7 (6.0) | FC | BC | TU | TU |
25| 2.8 (6.1) | BC | FC | TU | TU |
26| 2.9 (7.1) | TU | TU | FC | BC |
27| 2.10 (7.2) | TU | TU | BC | FC |
28+--------------------------+------------+------------+------------+------------+
29
30Version number of this API is defined in include/lttng/ust-abi.h of lttng-ust project
31
32"""
33
34"""
35First tuple member: lttng-ust label
36Second tuple member: lttng-tool label
37Third tuple member: expected scenario
38"""
39
40test_matrix_tracing_available = [
41 ("lttng-ust-2.7", "lttng-tools-2.7", True),
42 ("lttng-ust-2.7", "lttng-tools-2.8", True),
43 ("lttng-ust-2.7", "lttng-tools-2.9", False),
44 ("lttng-ust-2.7", "lttng-tools-2.10", False),
45 ("lttng-ust-2.8", "lttng-tools-2.7", True),
46 ("lttng-ust-2.8", "lttng-tools-2.8", True),
47 ("lttng-ust-2.8", "lttng-tools-2.9", False),
48 ("lttng-ust-2.8", "lttng-tools-2.10", False),
49 ("lttng-ust-2.9", "lttng-tools-2.7", False),
50 ("lttng-ust-2.9", "lttng-tools-2.8", False),
51 ("lttng-ust-2.9", "lttng-tools-2.9", True),
52 ("lttng-ust-2.9", "lttng-tools-2.10", True),
53 ("lttng-ust-2.10", "lttng-tools-2.7", False),
54 ("lttng-ust-2.10", "lttng-tools-2.8", False),
55 ("lttng-ust-2.10", "lttng-tools-2.9", True),
56 ("lttng-ust-2.10", "lttng-tools-2.10", True),
57]
58
59# Only consider test case for which tracing is valid
60test_matrix_other = [
61 ("lttng-ust-2.7", "lttng-tools-2.7", ""),
62 ("lttng-ust-2.7", "lttng-tools-2.8", ""),
63 ("lttng-ust-2.7", "lttng-tools-2.9", ""),
64 ("lttng-ust-2.7", "lttng-tools-2.10", ""),
65 ("lttng-ust-2.8", "lttng-tools-2.7", ""),
66 ("lttng-ust-2.8", "lttng-tools-2.8", ""),
67 ("lttng-ust-2.8", "lttng-tools-2.9", ""),
68 ("lttng-ust-2.8", "lttng-tools-2.10", ""),
69 ("lttng-ust-2.9", "lttng-tools-2.7", ""),
70 ("lttng-ust-2.9", "lttng-tools-2.8", ""),
71 ("lttng-ust-2.9", "lttng-tools-2.9", ""),
72 ("lttng-ust-2.9", "lttng-tools-2.10", ""),
73 ("lttng-ust-2.10", "lttng-tools-2.7", ""),
74 ("lttng-ust-2.10", "lttng-tools-2.8", ""),
75 ("lttng-ust-2.10", "lttng-tools-2.9", ""),
76 ("lttng-ust-2.10", "lttng-tools-2.10", ""),
77]
78
79runtime_matrix_tracing_available = []
80
81if not Settings.test_only:
82 runtime_matrix_tracing_available = test_matrix_tracing_available
83else:
84 for tup in test_matrix_tracing_available:
85 if (tup[0] in Settings.test_only or tup[1] in
86 Settings.test_only):
87 runtime_matrix_tracing_available.append(tup)
88
89
90def lttng_sessiond_ready():
91 print("lttng sessiond is ready ! FFS")
92
93@pytest.mark.parametrize("ust_label,tools_label, should_trace", runtime_matrix_tracing_available)
94def test_ust_app_tracing_available(tmpdir, ust_label, tools_label, should_trace):
95
96 nb_events = 100
97
98 # Prepare environment
99 ust = ProjectFactory.get_precook(ust_label)
100 tools = ProjectFactory.get_precook(tools_label)
101 babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace)
102
103 tools_runtime_path = os.path.join(str(tmpdir), "tools")
104 ust_runtime_path = os.path.join(str(tmpdir), "ust")
105 app_path = os.path.join(str(tmpdir), "app")
106
107 with Run.get_runtime(ust_runtime_path) as runtime_app, Run.get_runtime(tools_runtime_path) as runtime_tools:
108 runtime_tools.add_project(tools)
109 runtime_tools.add_project(babeltrace)
110
111 runtime_app.add_project(ust)
112 runtime_app.lttng_home = runtime_tools.lttng_home
113
114 trace_path = os.path.join(runtime_tools.lttng_home, 'trace')
115
116 # Make application using the ust runtime
117 shutil.copytree(Settings.apps_gen_events_folder, app_path)
118 runtime_app.run("make V=1", cwd=app_path)
119
120 # Start lttng-sessiond
a028c28a 121 utils.sessiond_spawn(runtime_tools)
e93e3f39
JR
122
123 # Create session using mi to get path and session name
124 runtime_tools.run('lttng create trace --output={}'.format(trace_path))
125
126 # TODO: test with event present in listing
127
128 runtime_tools.run('lttng enable-event -u tp:tptest')
129 runtime_tools.run('lttng start')
130
131 # Run application
132 cmd = './app {}'.format(nb_events)
133 runtime_app.run(cmd, cwd=app_path)
134
135 # Stop tracing
136 runtime_tools.run('lttng destroy -a')
137
138 try:
139 # Read trace with babeltrace and check for event count via number of line
140 cmd = 'babeltrace {}'.format(trace_path)
141 cp_process, cp_out, cp_err = runtime_tools.run(cmd)
142 assert(utils.line_count(cp_out) == nb_events)
143 except subprocess.CalledProcessError as e:
144 # Check if we expected a problem here
145 if should_trace:
146 # Something happened
147 raise e
This page took 0.029521 seconds and 5 git commands to generate.