Add ust_tracepoint_ABI-API_vs_ust
[deliverable/lttng-ivc.git] / lttng_ivc / tests / ust_tracepoint_ABI-API_vs_ust / test_ust_tracepoint_ABI_API_vs_ust.py
1 import pytest
2 import os
3 import shutil
4 import signal
5 import subprocess
6
7 import lttng_ivc.utils.ProjectFactory as ProjectFactory
8 import lttng_ivc.utils.utils as utils
9 import lttng_ivc.utils.runtime as Run
10 import lttng_ivc.settings as Settings
11
12 """
13
14 FC: Fully Compatible
15 BC: Feature of the smallest version number will works.
16
17 +-----------------------------------------+-----+------+------+-------+
18 | LTTng UST tracepoint instrumentation API/ABI: |
19 | Application vs LTTng UST library |
20 +-----------------------------------------+-----+------+------+-------+
21 | Application Instrumentation / LTTng UST | 2.7 | 2.8 | 2.9 | 2.10 |
22 +-----------------------------------------+-----+------+------+-------+
23 | 2.7 | FC | BC | BC | BC |
24 | 2.8 | BC | FC | BC | BC |
25 | 2.9 | BC | BC | FC | BC |
26 | 2.10 | BC | BC | BC | FC |
27 +-----------------------------------------+-----+------+------+-------+
28
29 Using tracepoint.h as a reference for change between version.
30
31 Compile application with under test version (Application instrumentation) tracepoints but do not link with provider.
32 Build provider with reference version (ust)
33 Launch application with provider using ld_preload.
34 Validate that events are registered.
35
36 """
37
38 """
39 First tuple member: application lttng-ust version
40 Second tuple member: reference (lttng-ust,lttng-tools) version
41 Third tuple member: expected scenario
42 """
43
44 """
45 We use lttng-tools instead of lttng-ust as second tuple since each
46 lttng-tools is locked with the corresponding lttng-ust we want to test given
47 that we use pre_cooked one.
48 """
49
50 fail_provider = "fail_on_provider"
51 fail_app = "fail_on_app"
52 success = "success"
53
54 test_matrix_enum = [
55 ("lttng-ust-2.7", "lttng-tools-2.7", fail_provider),
56 ("lttng-ust-2.7", "lttng-tools-2.8", fail_app),
57 ("lttng-ust-2.7", "lttng-tools-2.9", fail_app),
58 ("lttng-ust-2.7", "lttng-tools-2.10", fail_app),
59 ("lttng-ust-2.8", "lttng-tools-2.7", fail_provider),
60 ("lttng-ust-2.8", "lttng-tools-2.8", success),
61 ("lttng-ust-2.8", "lttng-tools-2.9", success),
62 ("lttng-ust-2.8", "lttng-tools-2.10", success),
63 ("lttng-ust-2.9", "lttng-tools-2.7", fail_provider),
64 ("lttng-ust-2.9", "lttng-tools-2.8", success),
65 ("lttng-ust-2.9", "lttng-tools-2.9", success),
66 ("lttng-ust-2.9", "lttng-tools-2.10", success),
67 ("lttng-ust-2.10", "lttng-tools-2.7", fail_provider),
68 ("lttng-ust-2.10", "lttng-tools-2.8", success),
69 ("lttng-ust-2.10", "lttng-tools-2.9", success),
70 ("lttng-ust-2.10", "lttng-tools-2.10", success),
71 ]
72
73 test_matrix_base = [
74 ("lttng-ust-2.7", "lttng-tools-2.7", success),
75 ("lttng-ust-2.7", "lttng-tools-2.8", success),
76 ("lttng-ust-2.7", "lttng-tools-2.9", success),
77 ("lttng-ust-2.7", "lttng-tools-2.10", success),
78 ("lttng-ust-2.8", "lttng-tools-2.7", success),
79 ("lttng-ust-2.8", "lttng-tools-2.8", success),
80 ("lttng-ust-2.8", "lttng-tools-2.9", success),
81 ("lttng-ust-2.8", "lttng-tools-2.10", success),
82 ("lttng-ust-2.9", "lttng-tools-2.7", success),
83 ("lttng-ust-2.9", "lttng-tools-2.8", success),
84 ("lttng-ust-2.9", "lttng-tools-2.9", success),
85 ("lttng-ust-2.9", "lttng-tools-2.10", success),
86 ("lttng-ust-2.10", "lttng-tools-2.7", success),
87 ("lttng-ust-2.10", "lttng-tools-2.8", success),
88 ("lttng-ust-2.10", "lttng-tools-2.9", success),
89 ("lttng-ust-2.10", "lttng-tools-2.10", success),
90 ]
91
92 runtime_matrix_enum = []
93 runtime_matrix_base = []
94
95 if not Settings.test_only:
96 runtime_matrix_enum = test_matrix_enum
97 runtime_matrix_base = test_matrix_base
98 else:
99 for tup in test_matrix_enum:
100 if (tup[0] in Settings.test_only or tup[1] in
101 Settings.test_only):
102 runtime_matrix_enum.append(tup)
103 for tup in test_matrix_base:
104 if (tup[0] in Settings.test_only or tup[1] in
105 Settings.test_only):
106 runtime_matrix_base.append(tup)
107
108 @pytest.mark.parametrize("ust_label,tools_label,scenario", runtime_matrix_enum)
109 def test_ust_tracepoint_abi_api_vs_ust_enum(tmpdir, ust_label, tools_label, scenario):
110
111 nb_loop = 100
112 nb_expected_events = 200
113
114 # Prepare environment
115 ust = ProjectFactory.get_precook(ust_label)
116 tools = ProjectFactory.get_precook(tools_label)
117 babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace)
118
119 tools_runtime_path = os.path.join(str(tmpdir), "tools")
120 ust_runtime_path = os.path.join(str(tmpdir), "ust")
121 app_path = os.path.join(str(tmpdir), "app")
122
123 with Run.get_runtime(ust_runtime_path) as runtime_app, Run.get_runtime(tools_runtime_path) as runtime_tools:
124 runtime_tools.add_project(tools)
125 runtime_tools.add_project(babeltrace)
126
127 runtime_app.add_project(ust)
128 runtime_app.lttng_home = runtime_tools.lttng_home
129
130 trace_path = os.path.join(runtime_tools.lttng_home, 'trace')
131
132 # Make application using the ust runtime
133 shutil.copytree(Settings.apps_preload_provider_folder, app_path)
134
135 # Use the testing env to make the probe
136 if scenario == fail_provider:
137 with pytest.raises(subprocess.CalledProcessError):
138 runtime_tools.run("make provider-enum", cwd=app_path)
139 return
140 else:
141 runtime_tools.run("make provider-enum", cwd=app_path)
142
143 # Use the ust env to test tracepoint instrumentation
144 if scenario == fail_app:
145 with pytest.raises(subprocess.CalledProcessError):
146 runtime_app.run("make app-enum", cwd=app_path)
147 return
148 else:
149 runtime_app.run("make app-enum", cwd=app_path)
150
151 # Start lttng-sessiond
152 sessiond = utils.sessiond_spawn(runtime_tools)
153
154 # Create session using mi to get path and session name
155 runtime_tools.run('lttng create trace --output={}'.format(trace_path))
156
157 runtime_tools.run('lttng enable-event -u tp:tptest,tp:tpenum')
158 runtime_tools.run('lttng start')
159
160 # Run application
161 cmd = './app-enum {}'.format(nb_loop)
162 runtime_tools.run(cmd, cwd=app_path, ld_preload="./libtp-enum.so")
163
164 # Stop tracing
165 runtime_tools.run('lttng destroy -a')
166 runtime_tools.subprocess_terminate(sessiond)
167
168
169 # Read trace with babeltrace and check for event count via number of line
170 cmd = 'babeltrace {}'.format(trace_path)
171 cp_process, cp_out, cp_err = runtime_tools.run(cmd)
172 assert(utils.line_count(cp_out) == nb_expected_events)
173
174 @pytest.mark.parametrize("ust_label,tools_label,scenario", runtime_matrix_base)
175 def test_ust_tracepoint_abi_api_vs_ust_base(tmpdir, ust_label, tools_label, scenario):
176
177 nb_loop = 100
178 nb_expected_events = 200
179
180 # Prepare environment
181 ust = ProjectFactory.get_precook(ust_label)
182 tools = ProjectFactory.get_precook(tools_label)
183 babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace)
184
185 tools_runtime_path = os.path.join(str(tmpdir), "tools")
186 ust_runtime_path = os.path.join(str(tmpdir), "ust")
187 app_path = os.path.join(str(tmpdir), "app")
188
189 with Run.get_runtime(ust_runtime_path) as runtime_app, Run.get_runtime(tools_runtime_path) as runtime_tools:
190 runtime_tools.add_project(tools)
191 runtime_tools.add_project(babeltrace)
192
193 runtime_app.add_project(ust)
194 runtime_app.lttng_home = runtime_tools.lttng_home
195
196 trace_path = os.path.join(runtime_tools.lttng_home, 'trace')
197
198 # Make application using the ust runtime
199 shutil.copytree(Settings.apps_preload_provider_folder, app_path)
200
201 # Use the testing env to make the probe
202 runtime_tools.run("make provider", cwd=app_path)
203
204 # Use the ust env to test tracepoint instrumentation
205 runtime_app.run("make app", cwd=app_path)
206
207 # Start lttng-sessiond
208 sessiond = utils.sessiond_spawn(runtime_tools)
209
210 # Create session using mi to get path and session name
211 runtime_tools.run('lttng create trace --output={}'.format(trace_path))
212
213 runtime_tools.run('lttng enable-event -u tp:tptest,tp:tpenum')
214 runtime_tools.run('lttng start')
215
216 # Run application
217 cmd = './app {}'.format(nb_loop)
218 runtime_tools.run(cmd, cwd=app_path, ld_preload="./libtp.so")
219
220 # Stop tracing
221 runtime_tools.run('lttng destroy -a')
222 runtime_tools.subprocess_terminate(sessiond)
223
224
225 # Read trace with babeltrace and check for event count via number of line
226 cmd = 'babeltrace {}'.format(trace_path)
227 cp_process, cp_out, cp_err = runtime_tools.run(cmd)
228 assert(utils.line_count(cp_out) == nb_expected_events)
This page took 0.036101 seconds and 6 git commands to generate.