Remove premature xfail marker
[deliverable/lttng-ivc.git] / lttng_ivc / tests / modules_abi_vs_tools / test_modules_abi_vs_tools.py
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
21 import pytest
22 import os
23 import glob
24 import subprocess
25
26 import lttng_ivc.utils.ProjectFactory as ProjectFactory
27 import lttng_ivc.utils.runtime as Run
28 import lttng_ivc.settings as Settings
29 from lttng_ivc.utils.skip import must_be_root
30 from lttng_ivc.utils.utils import sessiond_spawn
31 from lttng_ivc.utils.utils import line_count
32 from lttng_ivc.utils.utils import file_contains
33
34 """
35
36 NOTE: Kernel version is left to the Lttng-modules object on building. We assume
37 that a failing lttng-modules build is caused only by version validation. This
38 project is not dedicated to finding build problem but inter version problem.
39
40 NOTE: The command for regenerate metadata changed between 2.8 and 2.9 from
41 "metadata regenerate" to "regenerate metadata" breaking the cli ....bad
42 jdesfossez :P
43
44 TODO:Packet sequence number. 5b3cf4f924befda843a7736daf84f8ecae5e86a4
45 LTTNG_RING_BUFFER_GET_SEQ_NUM
46 TODO:Stream instance id. 5594698f9c8ad13e0964c67946d1867df7757dae
47 LTTNG_RING_BUFFER_INSTANCE_ID
48
49
50 FC: Fully Compatible
51 BC: 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 """
67 First tuple member: lttng-ust label
68 Second tuple member: lttng-tool label
69 Third tuple member: expected scenario
70 """
71 test_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 ]
89
90 test_matrix_regen_metadata = [
91 ("lttng-modules-2.7", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
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"),
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"),
107 ]
108
109 test_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"),
112 ("lttng-modules-2.7", "lttng-tools-2.9", "Unsupported by modules"),
113 ("lttng-modules-2.7", "lttng-tools-2.10", "Unsupported by modules"),
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
128 test_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"),
144 ("lttng-modules-2.10", "lttng-tools-2.10", "Supported"),
145 ]
146
147
148 def get_metadata_file_path(base_trace_path):
149 metadata = os.path.join(base_trace_path, 'kernel', 'metadata')
150 return metadata
151
152
153 runtime_matrix_base_tracing = []
154 runtime_matrix_regen_metadata = []
155 runtime_matrix_statedump = []
156 runtime_matrix_starglobing_enabler = []
157
158 if not Settings.test_only:
159 runtime_matrix_base_tracing = test_matrix_base_tracing
160 runtime_matrix_regen_metadata = test_matrix_regen_metadata
161 runtime_matrix_statedump = test_matrix_statedump
162 runtime_matrix_starglobing_enabler = test_matrix_starglobing_enabler
163 else:
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)
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)
176 for tup in test_matrix_starglobing_enabler:
177 if (tup[0] in Settings.test_only or tup[1] in
178 Settings.test_only):
179 runtime_matrix_starglobing_enabler.append(tup)
180
181
182 @must_be_root
183 @pytest.mark.parametrize("modules_label,tools_label", runtime_matrix_base_tracing)
184 def test_modules_base_tracing(tmpdir, modules_label, tools_label):
185 modules = ProjectFactory.get_precook(modules_label)
186 if modules.skip:
187 pytest.skip("{} cannot be built on this kernel".format(modules.label))
188 tools = ProjectFactory.get_precook(tools_label)
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)
200
201 sessiond = sessiond_spawn(runtime)
202 runtime.load_test_module()
203
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:
215 pytest.fail("Return value of sessiond is not zero")
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)
224 def test_modules_regen_metadata(tmpdir, modules_label, tools_label, command, scenario):
225 modules = ProjectFactory.get_precook(modules_label)
226 if modules.skip:
227 pytest.skip("{} cannot be built on this kernel".format(modules.label))
228 tools = ProjectFactory.get_precook(tools_label)
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()
243
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))
249
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)
254 assert line_count(cp_out) == nb_events
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":
268 if modules_label == "lttng-modules-2.7":
269 # Error from lttng-modules-2.7 is not reported correctly by
270 # sessiond. But it is reported on the sessiond side.
271 # For now, run the command, validate that the error exist on
272 # sessiond side and mark as xfail.
273 runtime.run("lttng {}".format(command))
274 with pytest.raises(subprocess.CalledProcessError):
275 runtime.run("lttng {}".format(command))
276
277 # Make sure everything looks good on this side
278 stderr_path = runtime.get_subprocess_stderr_path(sessiond)
279 sessiond = runtime.subprocess_terminate(sessiond)
280 if scenario == "Unsupported by modules":
281 error_msg = "Error: Failed to regenerate the kernel metadata"
282 assert file_contains(stderr_path, [error_msg]), "Error message missing"
283 if modules_label == "lttng-modules-2.7":
284 pytest.xfail("Lttng-tools does not bubble up error from unsupported metadata regeneration")
285
286 return
287
288 runtime.run("lttng {}".format(command))
289 runtime.run("lttng stop")
290 runtime.run("lttng destroy -a")
291
292 sessiond = runtime.subprocess_terminate(sessiond)
293 if sessiond.returncode != 0:
294 pytest.fail("Return value of sessiond is not zero")
295
296 cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
297 assert line_count(cp_out) == nb_events
298
299
300 @must_be_root
301 @pytest.mark.parametrize("modules_label,tools_label,scenario", runtime_matrix_statedump)
302 def test_modules_statedump(tmpdir, modules_label, tools_label, scenario):
303 modules = ProjectFactory.get_precook(modules_label)
304 if modules.skip:
305 pytest.skip("{} cannot be built on this kernel".format(modules.label))
306 tools = ProjectFactory.get_precook(tools_label)
307 babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace)
308
309 nb_events = 100
310 if scenario == "Unsupported by tools" or scenario == "Unsupported by modules":
311 expected_event = 2
312 else:
313 expected_event = 4
314
315 with Run.get_runtime(str(tmpdir)) as runtime:
316 runtime.add_project(modules)
317 runtime.add_project(tools)
318 runtime.add_project(babeltrace)
319
320 trace_path = os.path.join(runtime.lttng_home, 'trace')
321 babeltrace_cmd = 'babeltrace {}'.format(trace_path)
322
323 sessiond = sessiond_spawn(runtime)
324 runtime.load_test_module()
325
326 runtime.run("lttng create trace -o {}".format(trace_path))
327 runtime.run("lttng enable-event -k lttng_statedump_start,lttng_statedump_end")
328 runtime.run("lttng start")
329
330 # Generate some event
331 with open(Settings.lttng_test_procfile, 'w') as procfile:
332 procfile.write("{}".format(nb_events))
333
334 if scenario == "Unsupported by tools" or scenario == "Unsupported by modules":
335 with pytest.raises(subprocess.CalledProcessError):
336 runtime.run("lttng regenerate statedump")
337 else:
338 runtime.run("lttng regenerate statedump")
339
340 runtime.run("lttng stop")
341 runtime.run("lttng destroy -a")
342
343 sessiond = runtime.subprocess_terminate(sessiond)
344 if sessiond.returncode != 0:
345 pytest.fail("Return value of sessiond is not zero")
346
347 cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
348 assert(line_count(cp_out) == expected_event)
349
350
351 @must_be_root
352 @pytest.mark.parametrize("modules_label,tools_label, scenario", runtime_matrix_starglobing_enabler)
353 def test_modules_starglobing_enabler(tmpdir, modules_label, tools_label, scenario):
354 modules = ProjectFactory.get_precook(modules_label)
355 if modules.skip:
356 pytest.skip("{} cannot be built on this kernel".format(modules.label))
357 tools = ProjectFactory.get_precook(tools_label)
358 babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace)
359
360 nb_events = 100
361
362 if scenario == "Unsupported by modules":
363 expected_events = 0
364 else:
365 expected_events = nb_events
366
367 with Run.get_runtime(str(tmpdir)) as runtime:
368 runtime.add_project(modules)
369 runtime.add_project(tools)
370 runtime.add_project(babeltrace)
371
372 trace_path = os.path.join(runtime.lttng_home, 'trace')
373 babeltrace_cmd = 'babeltrace {}'.format(trace_path)
374
375 sessiond = sessiond_spawn(runtime)
376 runtime.load_test_module()
377
378 runtime.run("lttng create trace -o {}".format(trace_path))
379
380 if scenario == "Unsupported by tools":
381 with pytest.raises(subprocess.CalledProcessError):
382 runtime.run("lttng enable-event -k 'lttng_test_*_even*'")
383 sessiond = runtime.subprocess_terminate(sessiond)
384 if sessiond.returncode != 0:
385 pytest.fail("Return value of sessiond is not zero")
386 return
387
388 runtime.run("lttng enable-event -k 'lttng_test_*_even*'")
389 runtime.run("lttng start")
390
391 # Generate some event
392 with open(Settings.lttng_test_procfile, 'w') as procfile:
393 procfile.write("{}".format(nb_events))
394
395 runtime.run("lttng stop")
396 runtime.run("lttng destroy -a")
397
398 sessiond = runtime.subprocess_terminate(sessiond)
399 if sessiond.returncode != 0:
400 pytest.fail("Return value of sessiond is not zero")
401
402 cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
403 assert(line_count(cp_out) == expected_events)
This page took 0.046144 seconds and 6 git commands to generate.