Mark lttng-modules-2.7 regen metadata as xfail
[deliverable/lttng-ivc.git] / lttng_ivc / tests / modules_abi_vs_tools / test_modules_abi_vs_tools.py
CommitLineData
efdd48db
JR
1# Copyright (c) 2017 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
2#
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice shall be included in all
11# copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
20
01c2cc05 21import pytest
ab63b97e
JR
22import os
23import glob
24import subprocess
01c2cc05
JR
25
26import lttng_ivc.utils.ProjectFactory as ProjectFactory
27import lttng_ivc.utils.runtime as Run
28import lttng_ivc.settings as Settings
ab63b97e
JR
29from lttng_ivc.utils.skip import must_be_root
30from lttng_ivc.utils.utils import sessiond_spawn
31from lttng_ivc.utils.utils import line_count
d0d95343 32from lttng_ivc.utils.utils import file_contains
01c2cc05
JR
33
34"""
35
ab63b97e
JR
36NOTE: Kernel version is left to the Lttng-modules object on building. We assume
37that a failing lttng-modules build is caused only by version validation. This
38project is not dedicated to finding build problem but inter version problem.
39
40NOTE: The command for regenerate metadata changed between 2.8 and 2.9 from
41"metadata regenerate" to "regenerate metadata" breaking the cli ....bad
42jdesfossez :P
01c2cc05
JR
43
44TODO:Packet sequence number. 5b3cf4f924befda843a7736daf84f8ecae5e86a4
45 LTTNG_RING_BUFFER_GET_SEQ_NUM
46TODO:Stream instance id. 5594698f9c8ad13e0964c67946d1867df7757dae
47 LTTNG_RING_BUFFER_INSTANCE_ID
48
49
50FC: Fully Compatible
51BC: Feature of the smallest version number will works.
52
53+-------------------------------------------------------+
54| LTTng Modules ABI vs LTTng Tools compatibility matrix |
55+-------------------------------------------------------+
56| Modules / Tools | 2.7 | 2.8 | 2.9 | 2.10 |
57+------------------+------+------+------+---------------+
58| 2.7 | FC | BC | BC | BC |
59| 2.8 | BC | FC | BC | BC |
60| 2.9 | BC | BC | FC | BC |
61| 2.10 | BC | BC | BC | FC |
62+------------------+------+------+------+---------------+
63
64"""
65
66"""
67First tuple member: lttng-ust label
68Second tuple member: lttng-tool label
69Third tuple member: expected scenario
70"""
ab63b97e
JR
71test_matrix_base_tracing = [
72 ("lttng-modules-2.7", "lttng-tools-2.7"),
73 ("lttng-modules-2.7", "lttng-tools-2.8"),
74 ("lttng-modules-2.7", "lttng-tools-2.9"),
75 ("lttng-modules-2.7", "lttng-tools-2.10"),
76 ("lttng-modules-2.8", "lttng-tools-2.7"),
77 ("lttng-modules-2.8", "lttng-tools-2.8"),
78 ("lttng-modules-2.8", "lttng-tools-2.9"),
79 ("lttng-modules-2.8", "lttng-tools-2.10"),
80 ("lttng-modules-2.9", "lttng-tools-2.7"),
81 ("lttng-modules-2.9", "lttng-tools-2.8"),
82 ("lttng-modules-2.9", "lttng-tools-2.9"),
83 ("lttng-modules-2.9", "lttng-tools-2.10"),
84 ("lttng-modules-2.10", "lttng-tools-2.7"),
85 ("lttng-modules-2.10", "lttng-tools-2.8"),
86 ("lttng-modules-2.10", "lttng-tools-2.9"),
87 ("lttng-modules-2.10", "lttng-tools-2.10"),
88]
01c2cc05
JR
89
90test_matrix_regen_metadata = [
ab63b97e 91 ("lttng-modules-2.7", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
328eecd4
JR
92 ("lttng-modules-2.7", "lttng-tools-2.8", "metadata regenerate", "Unsupported by modules"),
93 ("lttng-modules-2.7", "lttng-tools-2.9", "regenerate metadata", "Unsupported by modules"),
94 ("lttng-modules-2.7", "lttng-tools-2.10", "regenerate metadata", "Unsupported by modules"),
ab63b97e
JR
95 ("lttng-modules-2.8", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
96 ("lttng-modules-2.8", "lttng-tools-2.8", "metadata regenerate", "Supported"),
97 ("lttng-modules-2.8", "lttng-tools-2.9", "regenerate metadata", "Supported"),
98 ("lttng-modules-2.8", "lttng-tools-2.10", "regenerate metadata", "Supported"),
99 ("lttng-modules-2.9", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
100 ("lttng-modules-2.9", "lttng-tools-2.8", "metadata regenerate", "Supported"),
101 ("lttng-modules-2.9", "lttng-tools-2.9", "regenerate metadata", "Supported"),
102 ("lttng-modules-2.9", "lttng-tools-2.10", "regenerate metadata", "Supported"),
103 ("lttng-modules-2.10", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
104 ("lttng-modules-2.10", "lttng-tools-2.8", "metadata regenerate", "Supported"),
105 ("lttng-modules-2.10", "lttng-tools-2.9", "regenerate metadata", "Supported"),
106 ("lttng-modules-2.10", "lttng-tools-2.10","regenerate metadata", "Supported"),
01c2cc05
JR
107]
108
109test_matrix_statedump = [
110 ("lttng-modules-2.7", "lttng-tools-2.7", "Unsupported by tools"),
111 ("lttng-modules-2.7", "lttng-tools-2.8", "Unsupported by tools"),
328eecd4
JR
112 ("lttng-modules-2.7", "lttng-tools-2.9", "Unsupported by modules"),
113 ("lttng-modules-2.7", "lttng-tools-2.10", "Unsupported by modules"),
01c2cc05
JR
114 ("lttng-modules-2.8", "lttng-tools-2.7", "Unsupported by tools"),
115 ("lttng-modules-2.8", "lttng-tools-2.8", "Unsupported by tools"),
116 ("lttng-modules-2.8", "lttng-tools-2.9", "Unsupported by modules"),
117 ("lttng-modules-2.8", "lttng-tools-2.10", "Unsupported by modules"),
118 ("lttng-modules-2.9", "lttng-tools-2.7", "Unsupported by tools"),
119 ("lttng-modules-2.9", "lttng-tools-2.8", "Unsupported by tools"),
120 ("lttng-modules-2.9", "lttng-tools-2.9", "Supported"),
121 ("lttng-modules-2.9", "lttng-tools-2.10", "Supported"),
122 ("lttng-modules-2.10", "lttng-tools-2.7", "Unsupported by tools"),
123 ("lttng-modules-2.10", "lttng-tools-2.8", "Unsupported by tools"),
124 ("lttng-modules-2.10", "lttng-tools-2.9", "Supported"),
125 ("lttng-modules-2.10", "lttng-tools-2.10", "Supported"),
126]
127
ab63b97e
JR
128test_matrix_starglobing_enabler = [
129 ("lttng-modules-2.7", "lttng-tools-2.7", "Unsupported by tools"),
130 ("lttng-modules-2.7", "lttng-tools-2.8", "Unsupported by tools"),
131 ("lttng-modules-2.7", "lttng-tools-2.9", "Unsupported by tools"),
132 ("lttng-modules-2.7", "lttng-tools-2.10", "Unsupported by modules"),
133 ("lttng-modules-2.8", "lttng-tools-2.7", "Unsupported by tools"),
134 ("lttng-modules-2.8", "lttng-tools-2.8", "Unsupported by tools"),
135 ("lttng-modules-2.8", "lttng-tools-2.9", "Unsupported by tools"),
136 ("lttng-modules-2.8", "lttng-tools-2.10", "Unsupported by modules"),
137 ("lttng-modules-2.9", "lttng-tools-2.7", "Unsupported by tools"),
138 ("lttng-modules-2.9", "lttng-tools-2.8", "Unsupported by tools"),
139 ("lttng-modules-2.9", "lttng-tools-2.9", "Unsupported by tools"),
140 ("lttng-modules-2.9", "lttng-tools-2.10", "Unsupported by modules"),
141 ("lttng-modules-2.10", "lttng-tools-2.7", "Unsupported by tools"),
142 ("lttng-modules-2.10", "lttng-tools-2.8", "Unsupported by tools"),
143 ("lttng-modules-2.10", "lttng-tools-2.9", "Unsupported by tools"),
01c2cc05
JR
144 ("lttng-modules-2.10", "lttng-tools-2.10", "Supported"),
145]
146
147
ab63b97e
JR
148def get_metadata_file_path(base_trace_path):
149 metadata = os.path.join(base_trace_path, 'kernel', 'metadata')
150 return metadata
151
152
153runtime_matrix_base_tracing = []
01c2cc05
JR
154runtime_matrix_regen_metadata = []
155runtime_matrix_statedump = []
ab63b97e 156runtime_matrix_starglobing_enabler = []
01c2cc05
JR
157
158if not Settings.test_only:
ab63b97e 159 runtime_matrix_base_tracing = test_matrix_base_tracing
01c2cc05
JR
160 runtime_matrix_regen_metadata = test_matrix_regen_metadata
161 runtime_matrix_statedump = test_matrix_statedump
ab63b97e 162 runtime_matrix_starglobing_enabler = test_matrix_starglobing_enabler
01c2cc05 163else:
ab63b97e
JR
164 for tup in test_matrix_base_tracing:
165 if (tup[0] in Settings.test_only or tup[1] in
166 Settings.test_only):
167 runtime_matrix_base_tracing.append(tup)
01c2cc05
JR
168 for tup in test_matrix_regen_metadata:
169 if (tup[0] in Settings.test_only or tup[1] in
170 Settings.test_only):
171 runtime_matrix_regen_metadata.append(tup)
172 for tup in test_matrix_statedump:
173 if (tup[0] in Settings.test_only or tup[1] in
174 Settings.test_only):
175 runtime_matrix_statedump.append(tup)
ab63b97e 176 for tup in test_matrix_starglobing_enabler:
01c2cc05
JR
177 if (tup[0] in Settings.test_only or tup[1] in
178 Settings.test_only):
ab63b97e 179 runtime_matrix_starglobing_enabler.append(tup)
01c2cc05
JR
180
181
ab63b97e
JR
182@must_be_root
183@pytest.mark.parametrize("modules_label,tools_label", runtime_matrix_base_tracing)
184def test_modules_base_tracing(tmpdir, modules_label, tools_label):
01c2cc05 185 modules = ProjectFactory.get_precook(modules_label)
ab63b97e
JR
186 if modules.skip:
187 pytest.skip("{} cannot be built on this kernel".format(modules.label))
01c2cc05 188 tools = ProjectFactory.get_precook(tools_label)
ab63b97e
JR
189 babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace)
190
191 nb_events = 100
192
193 with Run.get_runtime(str(tmpdir)) as runtime:
194 runtime.add_project(modules)
195 runtime.add_project(tools)
196 runtime.add_project(babeltrace)
197
198 trace_path = os.path.join(runtime.lttng_home, 'trace')
199 babeltrace_cmd = 'babeltrace {}'.format(trace_path)
01c2cc05 200
ab63b97e
JR
201 sessiond = sessiond_spawn(runtime)
202 runtime.load_test_module()
01c2cc05 203
ab63b97e
JR
204 runtime.run("lttng create trace -o {}".format(trace_path))
205 runtime.run("lttng enable-event -k lttng_test_filter_event")
206 runtime.run("lttng start")
207 with open(Settings.lttng_test_procfile, 'w') as procfile:
208 procfile.write("{}".format(nb_events))
209
210 runtime.run("lttng stop")
211 runtime.run("lttng destroy -a")
212
213 sessiond = runtime.subprocess_terminate(sessiond)
214 if sessiond.returncode != 0:
5676c7e7 215 pytest.fail("Return value of sessiond is not zero")
ab63b97e
JR
216 return
217
218 cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
219 assert(line_count(cp_out) == nb_events)
220
221
222@must_be_root
223@pytest.mark.parametrize("modules_label,tools_label,command,scenario", runtime_matrix_regen_metadata)
224def test_modules_regen_metadata(tmpdir, modules_label, tools_label, command, scenario):
01c2cc05 225 modules = ProjectFactory.get_precook(modules_label)
ab63b97e
JR
226 if modules.skip:
227 pytest.skip("{} cannot be built on this kernel".format(modules.label))
01c2cc05 228 tools = ProjectFactory.get_precook(tools_label)
ab63b97e
JR
229 babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace)
230
231 nb_events = 10
232
233 with Run.get_runtime(str(tmpdir)) as runtime:
234 runtime.add_project(modules)
235 runtime.add_project(tools)
236 runtime.add_project(babeltrace)
237
238 trace_path = os.path.join(runtime.lttng_home, 'trace')
239 babeltrace_cmd = 'babeltrace {}'.format(trace_path)
240
241 sessiond = sessiond_spawn(runtime)
242 runtime.load_test_module()
01c2cc05 243
ab63b97e
JR
244 runtime.run("lttng create trace -o {}".format(trace_path))
245 runtime.run("lttng enable-event -k lttng_test_filter_event")
246 runtime.run("lttng start")
247 with open(Settings.lttng_test_procfile, 'w') as procfile:
248 procfile.write("{}".format(nb_events))
01c2cc05 249
ab63b97e
JR
250 runtime.run("lttng stop")
251
252 # Validate that we have all event base on the current metadata
253 cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
d0d95343 254 assert line_count(cp_out) == nb_events
ab63b97e
JR
255
256 # Empty the metadata file
257 open(get_metadata_file_path(trace_path), 'w').close()
258
259 # Babeltrace should never be able to parse the trace
260 with pytest.raises(subprocess.CalledProcessError):
261 runtime.run(babeltrace_cmd)
262
263 runtime.run("lttng start")
264
265 # TODO: rework this a bit to differentiate each errors and rework how
266 # the condition are meet
267 if scenario == "Unsupported by tools" or scenario == "Unsupported by modules":
d0d95343
JR
268 if modules_label == "lttng-modules-2.7":
269 pytest.xfail("failing configuration (but should work)")
270 # Error from lttng-modules-2.7 is not reported correctly by
271 # sessiond. But it is reported on the sessiond side.
272 # For now, run the command, validate that the error exist on
273 # sessiond side and mark as xfail.
274 runtime.run("lttng {}".format(command))
ab63b97e
JR
275 with pytest.raises(subprocess.CalledProcessError):
276 runtime.run("lttng {}".format(command))
277
278 # Make sure everything looks good on this side
d0d95343 279 stderr_path = runtime.get_subprocess_stderr_path(sessiond)
ab63b97e 280 sessiond = runtime.subprocess_terminate(sessiond)
d0d95343
JR
281 if scenario == "Unsupported by modules":
282 error_msg = "Error: Failed to regenerate the kernel metadata"
283 assert file_contains(stderr_path, [error_msg]), "Error message missing"
284 if modules_label == "lttng-modules-2.7":
285 pytest.xfail("Lttng-tools does not bubble up error from unsupported metadata regeneration")
286
ab63b97e
JR
287 return
288
289 runtime.run("lttng {}".format(command))
290 runtime.run("lttng stop")
291 runtime.run("lttng destroy -a")
292
293 sessiond = runtime.subprocess_terminate(sessiond)
294 if sessiond.returncode != 0:
5676c7e7 295 pytest.fail("Return value of sessiond is not zero")
ab63b97e
JR
296
297 cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
d0d95343 298 assert line_count(cp_out) == nb_events
ab63b97e
JR
299
300
301@must_be_root
302@pytest.mark.parametrize("modules_label,tools_label,scenario", runtime_matrix_statedump)
303def test_modules_statedump(tmpdir, modules_label, tools_label, scenario):
01c2cc05 304 modules = ProjectFactory.get_precook(modules_label)
ab63b97e
JR
305 if modules.skip:
306 pytest.skip("{} cannot be built on this kernel".format(modules.label))
01c2cc05 307 tools = ProjectFactory.get_precook(tools_label)
ab63b97e
JR
308 babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace)
309
310 nb_events = 100
311 if scenario == "Unsupported by tools" or scenario == "Unsupported by modules":
312 expected_event = 2
313 else:
314 expected_event = 4
315
316 with Run.get_runtime(str(tmpdir)) as runtime:
317 runtime.add_project(modules)
318 runtime.add_project(tools)
319 runtime.add_project(babeltrace)
320
321 trace_path = os.path.join(runtime.lttng_home, 'trace')
322 babeltrace_cmd = 'babeltrace {}'.format(trace_path)
323
324 sessiond = sessiond_spawn(runtime)
325 runtime.load_test_module()
326
327 runtime.run("lttng create trace -o {}".format(trace_path))
328 runtime.run("lttng enable-event -k lttng_statedump_start,lttng_statedump_end")
329 runtime.run("lttng start")
330
331 # Generate some event
332 with open(Settings.lttng_test_procfile, 'w') as procfile:
333 procfile.write("{}".format(nb_events))
334
335 if scenario == "Unsupported by tools" or scenario == "Unsupported by modules":
336 with pytest.raises(subprocess.CalledProcessError):
337 runtime.run("lttng regenerate statedump")
338 else:
339 runtime.run("lttng regenerate statedump")
340
341 runtime.run("lttng stop")
342 runtime.run("lttng destroy -a")
343
344 sessiond = runtime.subprocess_terminate(sessiond)
345 if sessiond.returncode != 0:
5676c7e7 346 pytest.fail("Return value of sessiond is not zero")
ab63b97e
JR
347
348 cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
349 assert(line_count(cp_out) == expected_event)
350
351
352@must_be_root
353@pytest.mark.parametrize("modules_label,tools_label, scenario", runtime_matrix_starglobing_enabler)
354def test_modules_starglobing_enabler(tmpdir, modules_label, tools_label, scenario):
355 modules = ProjectFactory.get_precook(modules_label)
356 if modules.skip:
357 pytest.skip("{} cannot be built on this kernel".format(modules.label))
358 tools = ProjectFactory.get_precook(tools_label)
359 babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace)
360
361 nb_events = 100
362
363 if scenario == "Unsupported by modules":
364 expected_events = 0
365 else:
366 expected_events = nb_events
367
368 with Run.get_runtime(str(tmpdir)) as runtime:
369 runtime.add_project(modules)
370 runtime.add_project(tools)
371 runtime.add_project(babeltrace)
372
373 trace_path = os.path.join(runtime.lttng_home, 'trace')
374 babeltrace_cmd = 'babeltrace {}'.format(trace_path)
375
376 sessiond = sessiond_spawn(runtime)
377 runtime.load_test_module()
378
379 runtime.run("lttng create trace -o {}".format(trace_path))
380
381 if scenario == "Unsupported by tools":
382 with pytest.raises(subprocess.CalledProcessError):
383 runtime.run("lttng enable-event -k 'lttng_test_*_even*'")
384 sessiond = runtime.subprocess_terminate(sessiond)
385 if sessiond.returncode != 0:
5676c7e7 386 pytest.fail("Return value of sessiond is not zero")
ab63b97e
JR
387 return
388
389 runtime.run("lttng enable-event -k 'lttng_test_*_even*'")
390 runtime.run("lttng start")
391
392 # Generate some event
393 with open(Settings.lttng_test_procfile, 'w') as procfile:
394 procfile.write("{}".format(nb_events))
395
396 runtime.run("lttng stop")
397 runtime.run("lttng destroy -a")
398
399 sessiond = runtime.subprocess_terminate(sessiond)
400 if sessiond.returncode != 0:
5676c7e7 401 pytest.fail("Return value of sessiond is not zero")
ab63b97e
JR
402
403 cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
404 assert(line_count(cp_out) == expected_events)
This page took 0.044217 seconds and 5 git commands to generate.