6 import lttng_ivc
.utils
.ProjectFactory
as ProjectFactory
7 import lttng_ivc
.utils
.runtime
as Run
8 import lttng_ivc
.settings
as Settings
9 from lttng_ivc
.utils
.skip
import must_be_root
10 from lttng_ivc
.utils
.utils
import sessiond_spawn
11 from lttng_ivc
.utils
.utils
import line_count
15 NOTE: Kernel version is left to the Lttng-modules object on building. We assume
16 that a failing lttng-modules build is caused only by version validation. This
17 project is not dedicated to finding build problem but inter version problem.
19 NOTE: The command for regenerate metadata changed between 2.8 and 2.9 from
20 "metadata regenerate" to "regenerate metadata" breaking the cli ....bad
23 TODO:Packet sequence number. 5b3cf4f924befda843a7736daf84f8ecae5e86a4
24 LTTNG_RING_BUFFER_GET_SEQ_NUM
25 TODO:Stream instance id. 5594698f9c8ad13e0964c67946d1867df7757dae
26 LTTNG_RING_BUFFER_INSTANCE_ID
30 BC: Feature of the smallest version number will works.
32 +-------------------------------------------------------+
33 | LTTng Modules ABI vs LTTng Tools compatibility matrix |
34 +-------------------------------------------------------+
35 | Modules / Tools | 2.7 | 2.8 | 2.9 | 2.10 |
36 +------------------+------+------+------+---------------+
37 | 2.7 | FC | BC | BC | BC |
38 | 2.8 | BC | FC | BC | BC |
39 | 2.9 | BC | BC | FC | BC |
40 | 2.10 | BC | BC | BC | FC |
41 +------------------+------+------+------+---------------+
46 First tuple member: lttng-ust label
47 Second tuple member: lttng-tool label
48 Third tuple member: expected scenario
50 test_matrix_base_tracing
= [
51 ("lttng-modules-2.7", "lttng-tools-2.7"),
52 ("lttng-modules-2.7", "lttng-tools-2.8"),
53 ("lttng-modules-2.7", "lttng-tools-2.9"),
54 ("lttng-modules-2.7", "lttng-tools-2.10"),
55 ("lttng-modules-2.8", "lttng-tools-2.7"),
56 ("lttng-modules-2.8", "lttng-tools-2.8"),
57 ("lttng-modules-2.8", "lttng-tools-2.9"),
58 ("lttng-modules-2.8", "lttng-tools-2.10"),
59 ("lttng-modules-2.9", "lttng-tools-2.7"),
60 ("lttng-modules-2.9", "lttng-tools-2.8"),
61 ("lttng-modules-2.9", "lttng-tools-2.9"),
62 ("lttng-modules-2.9", "lttng-tools-2.10"),
63 ("lttng-modules-2.10", "lttng-tools-2.7"),
64 ("lttng-modules-2.10", "lttng-tools-2.8"),
65 ("lttng-modules-2.10", "lttng-tools-2.9"),
66 ("lttng-modules-2.10", "lttng-tools-2.10"),
69 test_matrix_regen_metadata
= [
70 ("lttng-modules-2.7", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
71 ("lttng-modules-2.7", "lttng-tools-2.8", "metadata regenerate", "Unsupported by module"),
72 ("lttng-modules-2.7", "lttng-tools-2.9", "regenerate metadata", "Unsupported by module"),
73 ("lttng-modules-2.7", "lttng-tools-2.10", "regenerate metadata", "Unsupported by module"),
74 ("lttng-modules-2.8", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
75 ("lttng-modules-2.8", "lttng-tools-2.8", "metadata regenerate", "Supported"),
76 ("lttng-modules-2.8", "lttng-tools-2.9", "regenerate metadata", "Supported"),
77 ("lttng-modules-2.8", "lttng-tools-2.10", "regenerate metadata", "Supported"),
78 ("lttng-modules-2.9", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
79 ("lttng-modules-2.9", "lttng-tools-2.8", "metadata regenerate", "Supported"),
80 ("lttng-modules-2.9", "lttng-tools-2.9", "regenerate metadata", "Supported"),
81 ("lttng-modules-2.9", "lttng-tools-2.10", "regenerate metadata", "Supported"),
82 ("lttng-modules-2.10", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
83 ("lttng-modules-2.10", "lttng-tools-2.8", "metadata regenerate", "Supported"),
84 ("lttng-modules-2.10", "lttng-tools-2.9", "regenerate metadata", "Supported"),
85 ("lttng-modules-2.10", "lttng-tools-2.10","regenerate metadata", "Supported"),
88 test_matrix_statedump
= [
89 ("lttng-modules-2.7", "lttng-tools-2.7", "Unsupported by tools"),
90 ("lttng-modules-2.7", "lttng-tools-2.8", "Unsupported by tools"),
91 ("lttng-modules-2.7", "lttng-tools-2.9", "Unsupported by module"),
92 ("lttng-modules-2.7", "lttng-tools-2.10", "Unsupported by module"),
93 ("lttng-modules-2.8", "lttng-tools-2.7", "Unsupported by tools"),
94 ("lttng-modules-2.8", "lttng-tools-2.8", "Unsupported by tools"),
95 ("lttng-modules-2.8", "lttng-tools-2.9", "Unsupported by modules"),
96 ("lttng-modules-2.8", "lttng-tools-2.10", "Unsupported by modules"),
97 ("lttng-modules-2.9", "lttng-tools-2.7", "Unsupported by tools"),
98 ("lttng-modules-2.9", "lttng-tools-2.8", "Unsupported by tools"),
99 ("lttng-modules-2.9", "lttng-tools-2.9", "Supported"),
100 ("lttng-modules-2.9", "lttng-tools-2.10", "Supported"),
101 ("lttng-modules-2.10", "lttng-tools-2.7", "Unsupported by tools"),
102 ("lttng-modules-2.10", "lttng-tools-2.8", "Unsupported by tools"),
103 ("lttng-modules-2.10", "lttng-tools-2.9", "Supported"),
104 ("lttng-modules-2.10", "lttng-tools-2.10", "Supported"),
107 test_matrix_starglobing_enabler
= [
108 ("lttng-modules-2.7", "lttng-tools-2.7", "Unsupported by tools"),
109 ("lttng-modules-2.7", "lttng-tools-2.8", "Unsupported by tools"),
110 ("lttng-modules-2.7", "lttng-tools-2.9", "Unsupported by tools"),
111 ("lttng-modules-2.7", "lttng-tools-2.10", "Unsupported by modules"),
112 ("lttng-modules-2.8", "lttng-tools-2.7", "Unsupported by tools"),
113 ("lttng-modules-2.8", "lttng-tools-2.8", "Unsupported by tools"),
114 ("lttng-modules-2.8", "lttng-tools-2.9", "Unsupported by tools"),
115 ("lttng-modules-2.8", "lttng-tools-2.10", "Unsupported by modules"),
116 ("lttng-modules-2.9", "lttng-tools-2.7", "Unsupported by tools"),
117 ("lttng-modules-2.9", "lttng-tools-2.8", "Unsupported by tools"),
118 ("lttng-modules-2.9", "lttng-tools-2.9", "Unsupported by tools"),
119 ("lttng-modules-2.9", "lttng-tools-2.10", "Unsupported by modules"),
120 ("lttng-modules-2.10", "lttng-tools-2.7", "Unsupported by tools"),
121 ("lttng-modules-2.10", "lttng-tools-2.8", "Unsupported by tools"),
122 ("lttng-modules-2.10", "lttng-tools-2.9", "Unsupported by tools"),
123 ("lttng-modules-2.10", "lttng-tools-2.10", "Supported"),
127 def get_metadata_file_path(base_trace_path
):
128 metadata
= os
.path
.join(base_trace_path
, 'kernel', 'metadata')
132 runtime_matrix_base_tracing
= []
133 runtime_matrix_regen_metadata
= []
134 runtime_matrix_statedump
= []
135 runtime_matrix_starglobing_enabler
= []
137 if not Settings
.test_only
:
138 runtime_matrix_base_tracing
= test_matrix_base_tracing
139 runtime_matrix_regen_metadata
= test_matrix_regen_metadata
140 runtime_matrix_statedump
= test_matrix_statedump
141 runtime_matrix_starglobing_enabler
= test_matrix_starglobing_enabler
143 for tup
in test_matrix_base_tracing
:
144 if (tup
[0] in Settings
.test_only
or tup
[1] in
146 runtime_matrix_base_tracing
.append(tup
)
147 for tup
in test_matrix_regen_metadata
:
148 if (tup
[0] in Settings
.test_only
or tup
[1] in
150 runtime_matrix_regen_metadata
.append(tup
)
151 for tup
in test_matrix_statedump
:
152 if (tup
[0] in Settings
.test_only
or tup
[1] in
154 runtime_matrix_statedump
.append(tup
)
155 for tup
in test_matrix_starglobing_enabler
:
156 if (tup
[0] in Settings
.test_only
or tup
[1] in
158 runtime_matrix_starglobing_enabler
.append(tup
)
162 @pytest.mark
.parametrize("modules_label,tools_label", runtime_matrix_base_tracing
)
163 def test_modules_base_tracing(tmpdir
, modules_label
, tools_label
):
164 modules
= ProjectFactory
.get_precook(modules_label
)
166 pytest
.skip("{} cannot be built on this kernel".format(modules
.label
))
167 tools
= ProjectFactory
.get_precook(tools_label
)
168 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
172 with Run
.get_runtime(str(tmpdir
)) as runtime
:
173 runtime
.add_project(modules
)
174 runtime
.add_project(tools
)
175 runtime
.add_project(babeltrace
)
177 trace_path
= os
.path
.join(runtime
.lttng_home
, 'trace')
178 babeltrace_cmd
= 'babeltrace {}'.format(trace_path
)
180 sessiond
= sessiond_spawn(runtime
)
181 runtime
.load_test_module()
183 runtime
.run("lttng create trace -o {}".format(trace_path
))
184 runtime
.run("lttng enable-event -k lttng_test_filter_event")
185 runtime
.run("lttng start")
186 with
open(Settings
.lttng_test_procfile
, 'w') as procfile
:
187 procfile
.write("{}".format(nb_events
))
189 runtime
.run("lttng stop")
190 runtime
.run("lttng destroy -a")
192 sessiond
= runtime
.subprocess_terminate(sessiond
)
193 if sessiond
.returncode
!= 0:
194 pytest
.fails("Return value of sessiond is not zero")
197 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
198 assert(line_count(cp_out
) == nb_events
)
202 @pytest.mark
.parametrize("modules_label,tools_label,command,scenario", runtime_matrix_regen_metadata
)
203 def test_modules_regen_metadata(tmpdir
, modules_label
, tools_label
, command
, scenario
):
204 modules
= ProjectFactory
.get_precook(modules_label
)
206 pytest
.skip("{} cannot be built on this kernel".format(modules
.label
))
207 tools
= ProjectFactory
.get_precook(tools_label
)
208 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
212 with Run
.get_runtime(str(tmpdir
)) as runtime
:
213 runtime
.add_project(modules
)
214 runtime
.add_project(tools
)
215 runtime
.add_project(babeltrace
)
217 trace_path
= os
.path
.join(runtime
.lttng_home
, 'trace')
218 babeltrace_cmd
= 'babeltrace {}'.format(trace_path
)
220 sessiond
= sessiond_spawn(runtime
)
221 runtime
.load_test_module()
223 runtime
.run("lttng create trace -o {}".format(trace_path
))
224 runtime
.run("lttng enable-event -k lttng_test_filter_event")
225 runtime
.run("lttng start")
226 with
open(Settings
.lttng_test_procfile
, 'w') as procfile
:
227 procfile
.write("{}".format(nb_events
))
229 runtime
.run("lttng stop")
231 # Validate that we have all event base on the current metadata
232 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
233 assert(line_count(cp_out
) == nb_events
)
235 # Empty the metadata file
236 open(get_metadata_file_path(trace_path
), 'w').close()
238 # Babeltrace should never be able to parse the trace
239 with pytest
.raises(subprocess
.CalledProcessError
):
240 runtime
.run(babeltrace_cmd
)
242 runtime
.run("lttng start")
244 # TODO: rework this a bit to differentiate each errors and rework how
245 # the condition are meet
246 if scenario
== "Unsupported by tools" or scenario
== "Unsupported by modules":
247 with pytest
.raises(subprocess
.CalledProcessError
):
248 runtime
.run("lttng {}".format(command
))
250 # Make sure everything looks good on this side
251 sessiond
= runtime
.subprocess_terminate(sessiond
)
252 if sessiond
.returncode
!= 0:
253 pytest
.fails("Return value of sessiond is not zero")
256 runtime
.run("lttng {}".format(command
))
257 runtime
.run("lttng stop")
258 runtime
.run("lttng destroy -a")
260 sessiond
= runtime
.subprocess_terminate(sessiond
)
261 if sessiond
.returncode
!= 0:
262 pytest
.fails("Return value of sessiond is not zero")
264 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
265 assert(line_count(cp_out
) == nb_events
)
269 @pytest.mark
.parametrize("modules_label,tools_label,scenario", runtime_matrix_statedump
)
270 def test_modules_statedump(tmpdir
, modules_label
, tools_label
, scenario
):
271 modules
= ProjectFactory
.get_precook(modules_label
)
273 pytest
.skip("{} cannot be built on this kernel".format(modules
.label
))
274 tools
= ProjectFactory
.get_precook(tools_label
)
275 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
278 if scenario
== "Unsupported by tools" or scenario
== "Unsupported by modules":
283 with Run
.get_runtime(str(tmpdir
)) as runtime
:
284 runtime
.add_project(modules
)
285 runtime
.add_project(tools
)
286 runtime
.add_project(babeltrace
)
288 trace_path
= os
.path
.join(runtime
.lttng_home
, 'trace')
289 babeltrace_cmd
= 'babeltrace {}'.format(trace_path
)
291 sessiond
= sessiond_spawn(runtime
)
292 runtime
.load_test_module()
294 runtime
.run("lttng create trace -o {}".format(trace_path
))
295 runtime
.run("lttng enable-event -k lttng_statedump_start,lttng_statedump_end")
296 runtime
.run("lttng start")
298 # Generate some event
299 with
open(Settings
.lttng_test_procfile
, 'w') as procfile
:
300 procfile
.write("{}".format(nb_events
))
302 if scenario
== "Unsupported by tools" or scenario
== "Unsupported by modules":
303 with pytest
.raises(subprocess
.CalledProcessError
):
304 runtime
.run("lttng regenerate statedump")
306 runtime
.run("lttng regenerate statedump")
308 runtime
.run("lttng stop")
309 runtime
.run("lttng destroy -a")
311 sessiond
= runtime
.subprocess_terminate(sessiond
)
312 if sessiond
.returncode
!= 0:
313 pytest
.fails("Return value of sessiond is not zero")
315 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
316 assert(line_count(cp_out
) == expected_event
)
320 @pytest.mark
.parametrize("modules_label,tools_label, scenario", runtime_matrix_starglobing_enabler
)
321 def test_modules_starglobing_enabler(tmpdir
, modules_label
, tools_label
, scenario
):
322 modules
= ProjectFactory
.get_precook(modules_label
)
324 pytest
.skip("{} cannot be built on this kernel".format(modules
.label
))
325 tools
= ProjectFactory
.get_precook(tools_label
)
326 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
330 if scenario
== "Unsupported by modules":
333 expected_events
= nb_events
335 with Run
.get_runtime(str(tmpdir
)) as runtime
:
336 runtime
.add_project(modules
)
337 runtime
.add_project(tools
)
338 runtime
.add_project(babeltrace
)
340 trace_path
= os
.path
.join(runtime
.lttng_home
, 'trace')
341 babeltrace_cmd
= 'babeltrace {}'.format(trace_path
)
343 sessiond
= sessiond_spawn(runtime
)
344 runtime
.load_test_module()
346 runtime
.run("lttng create trace -o {}".format(trace_path
))
348 if scenario
== "Unsupported by tools":
349 with pytest
.raises(subprocess
.CalledProcessError
):
350 runtime
.run("lttng enable-event -k 'lttng_test_*_even*'")
351 sessiond
= runtime
.subprocess_terminate(sessiond
)
352 if sessiond
.returncode
!= 0:
353 pytest
.fails("Return value of sessiond is not zero")
356 runtime
.run("lttng enable-event -k 'lttng_test_*_even*'")
357 runtime
.run("lttng start")
359 # Generate some event
360 with
open(Settings
.lttng_test_procfile
, 'w') as procfile
:
361 procfile
.write("{}".format(nb_events
))
363 runtime
.run("lttng stop")
364 runtime
.run("lttng destroy -a")
366 sessiond
= runtime
.subprocess_terminate(sessiond
)
367 if sessiond
.returncode
!= 0:
368 pytest
.fails("Return value of sessiond is not zero")
370 cp_process
, cp_out
, cp_err
= runtime
.run(babeltrace_cmd
)
371 assert(line_count(cp_out
) == expected_events
)