3 # Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 # Copyright (C) 2015 Antoine Busque <abusque@efficios.com>
6 # SPDX-License-Identifier: GPL-2.0-only
14 test_path
= os
.path
.dirname(os
.path
.abspath(__file__
)) + "/"
15 test_utils_path
= test_path
17 test_utils_path
= os
.path
.dirname(test_utils_path
)
18 test_utils_path
= test_utils_path
+ "/utils"
19 sys
.path
.append(test_utils_path
)
20 from test_utils
import *
23 have_dlmopen
= os
.environ
.get("LTTNG_TOOLS_HAVE_DLMOPEN") == "1"
28 print("1..{0}".format(NR_TESTS
))
30 # Check if a sessiond is running... bail out if none found.
31 if session_daemon_alive() == 0:
33 """No sessiond running. Please make sure you are running this test
34 with the "run" shell script and verify that the lttng tools are
35 properly installed."""
38 session_info
= create_session()
39 enable_ust_tracepoint_event(session_info
, "*")
40 start_session(session_info
)
42 test_env
= os
.environ
.copy()
43 test_env
["LD_PRELOAD"] = test_env
.get("LD_PRELOAD", "") + ":liblttng-ust-dl.so"
44 test_env
["LD_LIBRARY_PATH"] = test_env
.get("LD_LIBRARY_PATH", "") + ":" + test_path
45 test_process
= subprocess
.Popen(
47 stdout
=subprocess
.DEVNULL
,
48 stderr
=subprocess
.DEVNULL
,
54 test_process
.returncode
== 0, current_test
, "Test application exited normally"
58 stop_session(session_info
)
60 # Check for dl events in the resulting trace
62 babeltrace_process
= subprocess
.Popen(
63 [BABELTRACE_BIN
, session_info
.trace_path
],
64 stdout
=subprocess
.PIPE
,
65 stderr
=subprocess
.PIPE
,
67 except FileNotFoundError
:
69 "Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN
),
73 dlopen_event_found
= 0
74 dlmopen_event_found
= 0
75 build_id_event_found
= 0
76 debug_link_event_found
= 0
77 dlclose_event_found
= 0
79 load_build_id_event_found
= 0
80 load_debug_link_event_found
= 0
81 unload_event_found
= 0
86 for event_line
in babeltrace_process
.stdout
:
88 event_line
= event_line
.decode("utf-8").replace("\n", "")
89 if re
.search(r
".*lttng_ust_dl:dlopen.*", event_line
) is not None:
90 dlopen_event_found
+= 1
91 elif re
.search(r
".*lttng_ust_dl:dlmopen.*", event_line
) is not None:
92 dlmopen_event_found
+= 1
93 elif re
.search(r
".*lttng_ust_dl:build_id.*", event_line
) is not None:
94 build_id_event_found
+= 1
95 elif re
.search(r
".*lttng_ust_dl:debug_link.*", event_line
) is not None:
96 debug_link_event_found
+= 1
97 elif re
.search(r
".*lttng_ust_dl:dlclose.*", event_line
) is not None:
98 dlclose_event_found
+= 1
99 elif re
.search(r
".*lttng_ust_lib:build_id.*", event_line
) is not None:
100 load_build_id_event_found
+= 1
101 elif re
.search(r
".*lttng_ust_lib:debug_link.*", event_line
) is not None:
102 load_debug_link_event_found
+= 1
103 elif re
.search(r
".*lttng_ust_lib:unload.*", event_line
) is not None:
104 unload_event_found
+= 1
105 elif re
.search(r
".*lttng_ust_lib:load.*", event_line
) is not None:
106 load_event_found
+= 1
107 if re
.search(r
".*lttng_ust_lib:load.*libfoo.*", event_line
) is not None:
108 load_libfoo_found
+= 1
109 elif re
.search(r
".*lttng_ust_lib:load.*libbar.*", event_line
) is not None:
110 load_libbar_found
+= 1
111 elif re
.search(r
".*lttng_ust_lib:load.*libzzz.*", event_line
) is not None:
112 load_libzzz_found
+= 1
114 babeltrace_process
.wait()
117 babeltrace_process
.returncode
== 0, current_test
, "Resulting trace is readable"
122 dlopen_event_found
> 0,
124 "lttng_ust_dl:dlopen event found in resulting trace",
130 dlmopen_event_found
> 0,
132 "lttng_ust_dl:dlmopen event found in resulting trace",
135 skip_test(current_test
, "dlmopen() is not available")
140 build_id_event_found
> 0,
142 "lttng_ust_dl:build_id event found in resulting trace",
147 debug_link_event_found
> 0,
149 "lttng_ust_dl:debug_link event found in resulting trace",
154 dlclose_event_found
> 0,
156 "lttng_ust_dl:dlclose event found in resulting trace",
161 load_event_found
> 0,
163 "lttng_ust_lib:load event found in resulting trace",
168 load_build_id_event_found
> 0,
170 "lttng_ust_lib:build_id event found in resulting trace",
175 load_debug_link_event_found
> 0,
177 "lttng_ust_lib:debug_link event found in resulting trace",
182 unload_event_found
== 3,
184 "lttng_ust_lib:unload event found 3 times in resulting trace",
189 load_libfoo_found
== 1,
191 "lttng_ust_lib:load libfoo.so event found once in resulting trace",
196 load_libbar_found
== 1,
198 "lttng_ust_lib:load libbar.so event found once in resulting trace",
203 load_libzzz_found
== 1,
205 "lttng_ust_lib:load libzzz.so event found once in resulting trace",
209 shutil
.rmtree(session_info
.tmp_directory
)