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.
17 +-----------------------------------------+-----+------+------+-------+
18 | LTTng UST tracepoint instrumentation API/ABI: |
19 | Application vs LTTng UST library |
20 +-----------------------------------------+-----+------+------+-------+
21 | Application Instrumentation / LTTng UST | 2.7 | 2.8 | 2.9 | 2.10 |
22 +-----------------------------------------+-----+------+------+-------+
23 | 2.7 | FC | BC | BC | BC |
24 | 2.8 | BC | FC | BC | BC |
25 | 2.9 | BC | BC | FC | BC |
26 | 2.10 | BC | BC | BC | FC |
27 +-----------------------------------------+-----+------+------+-------+
29 Using tracepoint.h as a reference for change between version.
31 Compile application with under test version (Application instrumentation) tracepoints but do not link with provider.
32 Build provider with reference version (ust)
33 Launch application with provider using ld_preload.
34 Validate that events are registered.
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
),
56 ("lttng-ust-2.7", "lttng-tools-2.8", fail_app
),
57 ("lttng-ust-2.7", "lttng-tools-2.9", fail_app
),
58 ("lttng-ust-2.7", "lttng-tools-2.10", fail_app
),
59 ("lttng-ust-2.8", "lttng-tools-2.7", fail_provider
),
60 ("lttng-ust-2.8", "lttng-tools-2.8", success
),
61 ("lttng-ust-2.8", "lttng-tools-2.9", success
),
62 ("lttng-ust-2.8", "lttng-tools-2.10", success
),
63 ("lttng-ust-2.9", "lttng-tools-2.7", fail_provider
),
64 ("lttng-ust-2.9", "lttng-tools-2.8", success
),
65 ("lttng-ust-2.9", "lttng-tools-2.9", success
),
66 ("lttng-ust-2.9", "lttng-tools-2.10", success
),
67 ("lttng-ust-2.10", "lttng-tools-2.7", fail_provider
),
68 ("lttng-ust-2.10", "lttng-tools-2.8", success
),
69 ("lttng-ust-2.10", "lttng-tools-2.9", success
),
70 ("lttng-ust-2.10", "lttng-tools-2.10", success
),
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", runtime_matrix_enum
)
109 def test_ust_tracepoint_abi_api_vs_ust_enum(tmpdir
, ust_label
, tools_label
, scenario
):
112 nb_expected_events
= 200
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_app
, Run
.get_runtime(tools_runtime_path
) as runtime_tools
:
124 runtime_tools
.add_project(tools
)
125 runtime_tools
.add_project(babeltrace
)
127 runtime_app
.add_project(ust
)
128 runtime_app
.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_tools
.run("make provider-enum", cwd
=app_path
)
141 runtime_tools
.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_app
.run("make app-enum", cwd
=app_path
)
149 runtime_app
.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 destroy -a')
166 runtime_tools
.subprocess_terminate(sessiond
)
169 # Read trace with babeltrace and check for event count via number of line
170 cmd
= 'babeltrace {}'.format(trace_path
)
171 cp_process
, cp_out
, cp_err
= runtime_tools
.run(cmd
)
172 assert(utils
.line_count(cp_out
) == nb_expected_events
)
174 @pytest.mark
.parametrize("ust_label,tools_label,scenario", runtime_matrix_base
)
175 def test_ust_tracepoint_abi_api_vs_ust_base(tmpdir
, ust_label
, tools_label
, scenario
):
178 nb_expected_events
= 200
180 # Prepare environment
181 ust
= ProjectFactory
.get_precook(ust_label
)
182 tools
= ProjectFactory
.get_precook(tools_label
)
183 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
185 tools_runtime_path
= os
.path
.join(str(tmpdir
), "tools")
186 ust_runtime_path
= os
.path
.join(str(tmpdir
), "ust")
187 app_path
= os
.path
.join(str(tmpdir
), "app")
189 with Run
.get_runtime(ust_runtime_path
) as runtime_app
, Run
.get_runtime(tools_runtime_path
) as runtime_tools
:
190 runtime_tools
.add_project(tools
)
191 runtime_tools
.add_project(babeltrace
)
193 runtime_app
.add_project(ust
)
194 runtime_app
.lttng_home
= runtime_tools
.lttng_home
196 trace_path
= os
.path
.join(runtime_tools
.lttng_home
, 'trace')
198 # Make application using the ust runtime
199 shutil
.copytree(Settings
.apps_preload_provider_folder
, app_path
)
201 # Use the testing env to make the probe
202 runtime_tools
.run("make provider", cwd
=app_path
)
204 # Use the ust env to test tracepoint instrumentation
205 runtime_app
.run("make app", cwd
=app_path
)
207 # Start lttng-sessiond
208 sessiond
= utils
.sessiond_spawn(runtime_tools
)
210 # Create session using mi to get path and session name
211 runtime_tools
.run('lttng create trace --output={}'.format(trace_path
))
213 runtime_tools
.run('lttng enable-event -u tp:tptest,tp:tpenum')
214 runtime_tools
.run('lttng start')
217 cmd
= './app {}'.format(nb_loop
)
218 runtime_tools
.run(cmd
, cwd
=app_path
, ld_preload
="./libtp.so")
221 runtime_tools
.run('lttng destroy -a')
222 runtime_tools
.subprocess_terminate(sessiond
)
225 # Read trace with babeltrace and check for event count via number of line
226 cmd
= 'babeltrace {}'.format(trace_path
)
227 cp_process
, cp_out
, cp_err
= runtime_tools
.run(cmd
)
228 assert(utils
.line_count(cp_out
) == nb_expected_events
)