1 # Copyright (c) 2017 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
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:
10 # The above copyright notice and this permission notice shall be included in all
11 # copies or substantial portions of the Software.
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
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
35 NOTE: Kernel version is left to the Lttng-modules object on building. We assume
36 that a failing lttng-modules build is caused only by version validation. This
37 project is not dedicated to finding build problem but inter version problem.
39 NOTE: The command for regenerate metadata changed between 2.8 and 2.9 from
40 "metadata regenerate" to "regenerate metadata" breaking the cli ....bad
43 TODO:Packet sequence number. 5b3cf4f924befda843a7736daf84f8ecae5e86a4
44 LTTNG_RING_BUFFER_GET_SEQ_NUM
45 TODO:Stream instance id. 5594698f9c8ad13e0964c67946d1867df7757dae
46 LTTNG_RING_BUFFER_INSTANCE_ID
50 BC: Feature of the smallest version number will works.
52 +-------------------------------------------------------+
53 | LTTng Modules ABI vs LTTng Tools compatibility matrix |
54 +-------------------------------------------------------+
55 | Modules / Tools | 2.7 | 2.8 | 2.9 | 2.10 |
56 +------------------+------+------+------+---------------+
57 | 2.7 | FC | BC | BC | BC |
58 | 2.8 | BC | FC | BC | BC |
59 | 2.9 | BC | BC | FC | BC |
60 | 2.10 | BC | BC | BC | FC |
61 +------------------+------+------+------+---------------+
66 First tuple member: lttng-ust label
67 Second tuple member: lttng-tool label
68 Third tuple member: expected scenario
70 test_matrix_base_tracing
= [
71 ("lttng-modules-2.7", "lttng-tools-2.7"),
72 ("lttng-modules-2.7", "lttng-tools-2.8"),
73 ("lttng-modules-2.7", "lttng-tools-2.9"),
74 ("lttng-modules-2.7", "lttng-tools-2.10"),
75 ("lttng-modules-2.8", "lttng-tools-2.7"),
76 ("lttng-modules-2.8", "lttng-tools-2.8"),
77 ("lttng-modules-2.8", "lttng-tools-2.9"),
78 ("lttng-modules-2.8", "lttng-tools-2.10"),
79 ("lttng-modules-2.9", "lttng-tools-2.7"),
80 ("lttng-modules-2.9", "lttng-tools-2.8"),
81 ("lttng-modules-2.9", "lttng-tools-2.9"),
82 ("lttng-modules-2.9", "lttng-tools-2.10"),
83 ("lttng-modules-2.10", "lttng-tools-2.7"),
84 ("lttng-modules-2.10", "lttng-tools-2.8"),
85 ("lttng-modules-2.10", "lttng-tools-2.9"),
86 ("lttng-modules-2.10", "lttng-tools-2.10"),
89 test_matrix_regen_metadata
= [
90 ("lttng-modules-2.7", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
91 ("lttng-modules-2.7", "lttng-tools-2.8", "metadata regenerate", "Unsupported by module"),
92 ("lttng-modules-2.7", "lttng-tools-2.9", "regenerate metadata", "Unsupported by module"),
93 ("lttng-modules-2.7", "lttng-tools-2.10", "regenerate metadata", "Unsupported by module"),
94 ("lttng-modules-2.8", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
95 ("lttng-modules-2.8", "lttng-tools-2.8", "metadata regenerate", "Supported"),
96 ("lttng-modules-2.8", "lttng-tools-2.9", "regenerate metadata", "Supported"),
97 ("lttng-modules-2.8", "lttng-tools-2.10", "regenerate metadata", "Supported"),
98 ("lttng-modules-2.9", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
99 ("lttng-modules-2.9", "lttng-tools-2.8", "metadata regenerate", "Supported"),
100 ("lttng-modules-2.9", "lttng-tools-2.9", "regenerate metadata", "Supported"),
101 ("lttng-modules-2.9", "lttng-tools-2.10", "regenerate metadata", "Supported"),
102 ("lttng-modules-2.10", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
103 ("lttng-modules-2.10", "lttng-tools-2.8", "metadata regenerate", "Supported"),
104 ("lttng-modules-2.10", "lttng-tools-2.9", "regenerate metadata", "Supported"),
105 ("lttng-modules-2.10", "lttng-tools-2.10","regenerate metadata", "Supported"),
108 test_matrix_statedump
= [
109 ("lttng-modules-2.7", "lttng-tools-2.7", "Unsupported by tools"),
110 ("lttng-modules-2.7", "lttng-tools-2.8", "Unsupported by tools"),
111 ("lttng-modules-2.7", "lttng-tools-2.9", "Unsupported by module"),
112 ("lttng-modules-2.7", "lttng-tools-2.10", "Unsupported by module"),
113 ("lttng-modules-2.8", "lttng-tools-2.7", "Unsupported by tools"),
114 ("lttng-modules-2.8", "lttng-tools-2.8", "Unsupported by tools"),
115 ("lttng-modules-2.8", "lttng-tools-2.9", "Unsupported by modules"),
116 ("lttng-modules-2.8", "lttng-tools-2.10", "Unsupported by modules"),
117 ("lttng-modules-2.9", "lttng-tools-2.7", "Unsupported by tools"),
118 ("lttng-modules-2.9", "lttng-tools-2.8", "Unsupported by tools"),
119 ("lttng-modules-2.9", "lttng-tools-2.9", "Supported"),
120 ("lttng-modules-2.9", "lttng-tools-2.10", "Supported"),
121 ("lttng-modules-2.10", "lttng-tools-2.7", "Unsupported by tools"),
122 ("lttng-modules-2.10", "lttng-tools-2.8", "Unsupported by tools"),
123 ("lttng-modules-2.10", "lttng-tools-2.9", "Supported"),
124 ("lttng-modules-2.10", "lttng-tools-2.10", "Supported"),
127 test_matrix_starglobing_enabler
= [
128 ("lttng-modules-2.7", "lttng-tools-2.7", "Unsupported by tools"),
129 ("lttng-modules-2.7", "lttng-tools-2.8", "Unsupported by tools"),
130 ("lttng-modules-2.7", "lttng-tools-2.9", "Unsupported by tools"),
131 ("lttng-modules-2.7", "lttng-tools-2.10", "Unsupported by modules"),
132 ("lttng-modules-2.8", "lttng-tools-2.7", "Unsupported by tools"),
133 ("lttng-modules-2.8", "lttng-tools-2.8", "Unsupported by tools"),
134 ("lttng-modules-2.8", "lttng-tools-2.9", "Unsupported by tools"),
135 ("lttng-modules-2.8", "lttng-tools-2.10", "Unsupported by modules"),
136 ("lttng-modules-2.9", "lttng-tools-2.7", "Unsupported by tools"),
137 ("lttng-modules-2.9", "lttng-tools-2.8", "Unsupported by tools"),
138 ("lttng-modules-2.9", "lttng-tools-2.9", "Unsupported by tools"),
139 ("lttng-modules-2.9", "lttng-tools-2.10", "Unsupported by modules"),
140 ("lttng-modules-2.10", "lttng-tools-2.7", "Unsupported by tools"),
141 ("lttng-modules-2.10", "lttng-tools-2.8", "Unsupported by tools"),
142 ("lttng-modules-2.10", "lttng-tools-2.9", "Unsupported by tools"),
143 ("lttng-modules-2.10", "lttng-tools-2.10", "Supported"),
147 def get_metadata_file_path(base_trace_path
):
148 metadata
= os
.path
.join(base_trace_path
, 'kernel', 'metadata')
152 runtime_matrix_base_tracing
= []
153 runtime_matrix_regen_metadata
= []
154 runtime_matrix_statedump
= []
155 runtime_matrix_starglobing_enabler
= []
157 if not Settings
.test_only
:
158 runtime_matrix_base_tracing
= test_matrix_base_tracing
159 runtime_matrix_regen_metadata
= test_matrix_regen_metadata
160 runtime_matrix_statedump
= test_matrix_statedump
161 runtime_matrix_starglobing_enabler
= test_matrix_starglobing_enabler
163 for tup
in test_matrix_base_tracing
:
164 if (tup
[0] in Settings
.test_only
or tup
[1] in
166 runtime_matrix_base_tracing
.append(tup
)
167 for tup
in test_matrix_regen_metadata
:
168 if (tup
[0] in Settings
.test_only
or tup
[1] in
170 runtime_matrix_regen_metadata
.append(tup
)
171 for tup
in test_matrix_statedump
:
172 if (tup
[0] in Settings
.test_only
or tup
[1] in
174 runtime_matrix_statedump
.append(tup
)
175 for tup
in test_matrix_starglobing_enabler
:
176 if (tup
[0] in Settings
.test_only
or tup
[1] in
178 runtime_matrix_starglobing_enabler
.append(tup
)
182 @pytest.mark
.parametrize("modules_label,tools_label", runtime_matrix_base_tracing
)
183 def test_modules_base_tracing(tmpdir
, modules_label
, tools_label
):
184 modules
= ProjectFactory
.get_precook(modules_label
)
186 pytest
.skip("{} cannot be built on this kernel".format(modules
.label
))
187 tools
= ProjectFactory
.get_precook(tools_label
)
188 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
192 with Run
.get_runtime(str(tmpdir
)) as runtime
:
193 runtime
.add_project(modules
)
194 runtime
.add_project(tools
)
195 runtime
.add_project(babeltrace
)
197 trace_path
= os
.path
.join(runtime
.lttng_home
, 'trace')
198 babeltrace_cmd
= 'babeltrace {}'.format(trace_path
)
200 sessiond
= sessiond_spawn(runtime
)
201 runtime
.load_test_module()
203 runtime
.run("lttng create trace -o {}".format(trace_path
))
204 runtime
.run("lttng enable-event -k lttng_test_filter_event")
205 runtime
.run("lttng start")
206 with
open(Settings
.lttng_test_procfile
, 'w') as procfile
:
207 procfile
.write("{}".format(nb_events
))
209 runtime
.run("lttng stop")
210 runtime
.run("lttng destroy -a")
212 sessiond
= runtime
.subprocess_terminate(sessiond
)
213 if sessiond
.returncode
!= 0:
214 pytest
.fail("Return value of sessiond is not zero")
217 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
218 assert(line_count(cp_out
) == nb_events
)
222 @pytest.mark
.parametrize("modules_label,tools_label,command,scenario", runtime_matrix_regen_metadata
)
223 def test_modules_regen_metadata(tmpdir
, modules_label
, tools_label
, command
, scenario
):
224 modules
= ProjectFactory
.get_precook(modules_label
)
226 pytest
.skip("{} cannot be built on this kernel".format(modules
.label
))
227 tools
= ProjectFactory
.get_precook(tools_label
)
228 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
232 with Run
.get_runtime(str(tmpdir
)) as runtime
:
233 runtime
.add_project(modules
)
234 runtime
.add_project(tools
)
235 runtime
.add_project(babeltrace
)
237 trace_path
= os
.path
.join(runtime
.lttng_home
, 'trace')
238 babeltrace_cmd
= 'babeltrace {}'.format(trace_path
)
240 sessiond
= sessiond_spawn(runtime
)
241 runtime
.load_test_module()
243 runtime
.run("lttng create trace -o {}".format(trace_path
))
244 runtime
.run("lttng enable-event -k lttng_test_filter_event")
245 runtime
.run("lttng start")
246 with
open(Settings
.lttng_test_procfile
, 'w') as procfile
:
247 procfile
.write("{}".format(nb_events
))
249 runtime
.run("lttng stop")
251 # Validate that we have all event base on the current metadata
252 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
253 assert(line_count(cp_out
) == nb_events
)
255 # Empty the metadata file
256 open(get_metadata_file_path(trace_path
), 'w').close()
258 # Babeltrace should never be able to parse the trace
259 with pytest
.raises(subprocess
.CalledProcessError
):
260 runtime
.run(babeltrace_cmd
)
262 runtime
.run("lttng start")
264 # TODO: rework this a bit to differentiate each errors and rework how
265 # the condition are meet
266 if scenario
== "Unsupported by tools" or scenario
== "Unsupported by modules":
267 with pytest
.raises(subprocess
.CalledProcessError
):
268 runtime
.run("lttng {}".format(command
))
270 # Make sure everything looks good on this side
271 sessiond
= runtime
.subprocess_terminate(sessiond
)
272 if sessiond
.returncode
!= 0:
273 pytest
.fail("Return value of sessiond is not zero")
276 runtime
.run("lttng {}".format(command
))
277 runtime
.run("lttng stop")
278 runtime
.run("lttng destroy -a")
280 sessiond
= runtime
.subprocess_terminate(sessiond
)
281 if sessiond
.returncode
!= 0:
282 pytest
.fail("Return value of sessiond is not zero")
284 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
285 assert(line_count(cp_out
) == nb_events
)
289 @pytest.mark
.parametrize("modules_label,tools_label,scenario", runtime_matrix_statedump
)
290 def test_modules_statedump(tmpdir
, modules_label
, tools_label
, scenario
):
291 modules
= ProjectFactory
.get_precook(modules_label
)
293 pytest
.skip("{} cannot be built on this kernel".format(modules
.label
))
294 tools
= ProjectFactory
.get_precook(tools_label
)
295 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
298 if scenario
== "Unsupported by tools" or scenario
== "Unsupported by modules":
303 with Run
.get_runtime(str(tmpdir
)) as runtime
:
304 runtime
.add_project(modules
)
305 runtime
.add_project(tools
)
306 runtime
.add_project(babeltrace
)
308 trace_path
= os
.path
.join(runtime
.lttng_home
, 'trace')
309 babeltrace_cmd
= 'babeltrace {}'.format(trace_path
)
311 sessiond
= sessiond_spawn(runtime
)
312 runtime
.load_test_module()
314 runtime
.run("lttng create trace -o {}".format(trace_path
))
315 runtime
.run("lttng enable-event -k lttng_statedump_start,lttng_statedump_end")
316 runtime
.run("lttng start")
318 # Generate some event
319 with
open(Settings
.lttng_test_procfile
, 'w') as procfile
:
320 procfile
.write("{}".format(nb_events
))
322 if scenario
== "Unsupported by tools" or scenario
== "Unsupported by modules":
323 with pytest
.raises(subprocess
.CalledProcessError
):
324 runtime
.run("lttng regenerate statedump")
326 runtime
.run("lttng regenerate statedump")
328 runtime
.run("lttng stop")
329 runtime
.run("lttng destroy -a")
331 sessiond
= runtime
.subprocess_terminate(sessiond
)
332 if sessiond
.returncode
!= 0:
333 pytest
.fail("Return value of sessiond is not zero")
335 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
336 assert(line_count(cp_out
) == expected_event
)
340 @pytest.mark
.parametrize("modules_label,tools_label, scenario", runtime_matrix_starglobing_enabler
)
341 def test_modules_starglobing_enabler(tmpdir
, modules_label
, tools_label
, scenario
):
342 modules
= ProjectFactory
.get_precook(modules_label
)
344 pytest
.skip("{} cannot be built on this kernel".format(modules
.label
))
345 tools
= ProjectFactory
.get_precook(tools_label
)
346 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
350 if scenario
== "Unsupported by modules":
353 expected_events
= nb_events
355 with Run
.get_runtime(str(tmpdir
)) as runtime
:
356 runtime
.add_project(modules
)
357 runtime
.add_project(tools
)
358 runtime
.add_project(babeltrace
)
360 trace_path
= os
.path
.join(runtime
.lttng_home
, 'trace')
361 babeltrace_cmd
= 'babeltrace {}'.format(trace_path
)
363 sessiond
= sessiond_spawn(runtime
)
364 runtime
.load_test_module()
366 runtime
.run("lttng create trace -o {}".format(trace_path
))
368 if scenario
== "Unsupported by tools":
369 with pytest
.raises(subprocess
.CalledProcessError
):
370 runtime
.run("lttng enable-event -k 'lttng_test_*_even*'")
371 sessiond
= runtime
.subprocess_terminate(sessiond
)
372 if sessiond
.returncode
!= 0:
373 pytest
.fail("Return value of sessiond is not zero")
376 runtime
.run("lttng enable-event -k 'lttng_test_*_even*'")
377 runtime
.run("lttng start")
379 # Generate some event
380 with
open(Settings
.lttng_test_procfile
, 'w') as procfile
:
381 procfile
.write("{}".format(nb_events
))
383 runtime
.run("lttng stop")
384 runtime
.run("lttng destroy -a")
386 sessiond
= runtime
.subprocess_terminate(sessiond
)
387 if sessiond
.returncode
!= 0:
388 pytest
.fail("Return value of sessiond is not zero")
390 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
391 assert(line_count(cp_out
) == expected_events
)