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
15 BC: Feature of the smallest version number will works.
16 EU: Event unavailable for tracing
18 +-----------------------------------------+-----+------+------+-------+
19 | LTTng UST tracepoint API/ABI: |
20 | Probe provider vs LTTng UST library |
21 +-----------------------------------------+-----+------+------+-------+
22 | Probe Provider / LTTng UST | 2.7 | 2.8 | 2.9 | 2.10 |
23 +-----------------------------------------+-----+------+------+-------+
24 | 2.7 | FC | BC | BC | BC |
25 | 2.8 | EU | FC | BC | BC |
26 | 2.9 | EU | EU | FC | BC |
27 | 2.10 | EU | EU | EU | FC |
28 +-----------------------------------------+-----+------+------+-------+
30 Using tracepoint.h as a reference for change between version.
32 Compile application with version under test (Probe Provider) tracepoints but do not link with provider.
33 Build provider with version under test (Probe Provider)
34 Launch application with provider using ld_preload.
35 Validate that events are registered and present in trace.
39 First tuple member: application lttng-ust version
40 Second tuple member: reference (lttng-ust,lttng-tools) version
41 Third tuple member: expected scenario
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.
50 fail_provider
= "fail_on_provider"
51 fail_app
= "fail_on_app"
55 ("lttng-ust-2.7", "lttng-tools-2.7", fail_provider
, 0),
56 ("lttng-ust-2.7", "lttng-tools-2.8", fail_provider
, 0),
57 ("lttng-ust-2.7", "lttng-tools-2.9", fail_provider
, 0),
58 ("lttng-ust-2.7", "lttng-tools-2.10", fail_provider
, 0),
59 ("lttng-ust-2.8", "lttng-tools-2.7", success
, 100),
60 ("lttng-ust-2.8", "lttng-tools-2.8", success
, 200),
61 ("lttng-ust-2.8", "lttng-tools-2.9", success
, 200),
62 ("lttng-ust-2.8", "lttng-tools-2.10", success
, 200),
63 ("lttng-ust-2.9", "lttng-tools-2.7", success
, 100),
64 ("lttng-ust-2.9", "lttng-tools-2.8", success
, 200),
65 ("lttng-ust-2.9", "lttng-tools-2.9", success
, 200),
66 ("lttng-ust-2.9", "lttng-tools-2.10", success
, 200),
67 ("lttng-ust-2.10", "lttng-tools-2.7", success
, 100),
68 ("lttng-ust-2.10", "lttng-tools-2.8", success
, 200),
69 ("lttng-ust-2.10", "lttng-tools-2.9", success
, 200),
70 ("lttng-ust-2.10", "lttng-tools-2.10", success
, 200),
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
),
92 runtime_matrix_enum
= []
93 runtime_matrix_base
= []
95 if not Settings
.test_only
:
96 runtime_matrix_enum
= test_matrix_enum
97 runtime_matrix_base
= test_matrix_base
99 for tup
in test_matrix_enum
:
100 if (tup
[0] in Settings
.test_only
or tup
[1] in
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
106 runtime_matrix_base
.append(tup
)
108 @pytest.mark
.parametrize("ust_label,tools_label,scenario, expected_event", runtime_matrix_enum
)
109 def test_ust_tracepoint_abi_api_vs_ust_enum(tmpdir
, ust_label
, tools_label
, scenario
, expected_event
):
112 nb_expected_events
= expected_event
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
)
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")
123 with Run
.get_runtime(ust_runtime_path
) as runtime_ust
, Run
.get_runtime(tools_runtime_path
) as runtime_tools
:
124 runtime_tools
.add_project(tools
)
125 runtime_tools
.add_project(babeltrace
)
127 runtime_ust
.add_project(ust
)
128 runtime_ust
.lttng_home
= runtime_tools
.lttng_home
130 trace_path
= os
.path
.join(runtime_tools
.lttng_home
, 'trace')
132 # Make application using the ust runtime
133 shutil
.copytree(Settings
.apps_preload_provider_folder
, app_path
)
135 # Use the testing env to make the probe
136 if scenario
== fail_provider
:
137 with pytest
.raises(subprocess
.CalledProcessError
):
138 runtime_ust
.run("make provider-enum", cwd
=app_path
)
141 runtime_ust
.run("make provider-enum", cwd
=app_path
)
143 # Use the ust env to test tracepoint instrumentation
144 if scenario
== fail_app
:
145 with pytest
.raises(subprocess
.CalledProcessError
):
146 runtime_tools
.run("make app-enum", cwd
=app_path
)
149 runtime_ust
.run("make app-enum", cwd
=app_path
)
151 # Start lttng-sessiond
152 sessiond
= utils
.sessiond_spawn(runtime_tools
)
154 # Create session using mi to get path and session name
155 runtime_tools
.run('lttng create trace --output={}'.format(trace_path
))
157 runtime_tools
.run('lttng enable-event -u tp:tptest,tp:tpenum')
158 runtime_tools
.run('lttng start')
161 cmd
= './app-enum {}'.format(nb_loop
)
162 runtime_tools
.run(cmd
, cwd
=app_path
, ld_preload
="./libtp-enum.so")
165 runtime_tools
.run('lttng stop')
166 runtime_tools
.run('lttng destroy -a')
167 runtime_tools
.subprocess_terminate(sessiond
)
170 # Read trace with babeltrace and check for event count via number of line
171 cmd
= 'babeltrace {}'.format(trace_path
)
172 cp_process
, cp_out
, cp_err
= runtime_tools
.run(cmd
)
173 assert(utils
.line_count(cp_out
) == nb_expected_events
)
175 @pytest.mark
.parametrize("ust_label,tools_label,scenario", runtime_matrix_base
)
176 def test_ust_tracepoint_probe_abi_api_vs_ust_base(tmpdir
, ust_label
, tools_label
, scenario
):
179 nb_expected_events
= 200
181 # Prepare environment
182 ust
= ProjectFactory
.get_precook(ust_label
)
183 tools
= ProjectFactory
.get_precook(tools_label
)
184 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
186 tools_runtime_path
= os
.path
.join(str(tmpdir
), "tools")
187 ust_runtime_path
= os
.path
.join(str(tmpdir
), "ust")
188 app_path
= os
.path
.join(str(tmpdir
), "app")
190 with Run
.get_runtime(ust_runtime_path
) as runtime_ust
, Run
.get_runtime(tools_runtime_path
) as runtime_tools
:
191 runtime_tools
.add_project(tools
)
192 runtime_tools
.add_project(babeltrace
)
194 runtime_ust
.add_project(ust
)
195 runtime_ust
.lttng_home
= runtime_tools
.lttng_home
197 trace_path
= os
.path
.join(runtime_tools
.lttng_home
, 'trace')
199 # Make application using the ust runtime
200 shutil
.copytree(Settings
.apps_preload_provider_folder
, app_path
)
202 # Use the testing env to make the probe
203 runtime_ust
.run("make provider", cwd
=app_path
)
205 # Use the ust env to test tracepoint instrumentation
206 runtime_ust
.run("make app", cwd
=app_path
)
208 # Start lttng-sessiond
209 sessiond
= utils
.sessiond_spawn(runtime_tools
)
211 # Create session using mi to get path and session name
212 runtime_tools
.run('lttng create trace --output={}'.format(trace_path
))
214 runtime_tools
.run('lttng enable-event -u tp:tptest,tp:tpenum')
215 runtime_tools
.run('lttng start')
218 cmd
= './app {}'.format(nb_loop
)
219 runtime_tools
.run(cmd
, cwd
=app_path
, ld_preload
="./libtp.so")
222 runtime_tools
.run('lttng stop')
223 runtime_tools
.run('lttng destroy -a')
224 runtime_tools
.subprocess_terminate(sessiond
)
227 # Read trace with babeltrace and check for event count via number of line
228 cmd
= 'babeltrace {}'.format(trace_path
)
229 cp_process
, cp_out
, cp_err
= runtime_tools
.run(cmd
)
230 assert(utils
.line_count(cp_out
) == nb_expected_events
)