3 # Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 # SPDX-License-Identifier: GPL-2.0-only
13 test_path
= os
.path
.dirname(os
.path
.abspath(__file__
)) + "/"
14 test_utils_path
= test_path
16 test_utils_path
= os
.path
.dirname(test_utils_path
)
17 test_utils_path
= test_utils_path
+ "/utils"
18 sys
.path
.append(test_utils_path
)
19 from test_utils
import *
24 print("1..{0}".format(NR_TESTS
))
26 # Check if a sessiond is running... bail out if none found.
27 if session_daemon_alive() == 0:
29 'No sessiond running. Please make sure you are running this test with the "run" shell script and verify that the lttng tools are properly installed.'
32 session_info
= create_session()
33 enable_ust_tracepoint_event(session_info
, "lttng_ust_libc*")
34 start_session(session_info
)
36 malloc_process
= subprocess
.Popen(
37 test_path
+ "prog", stdout
=subprocess
.DEVNULL
, stderr
=subprocess
.DEVNULL
42 malloc_process
.returncode
== 0, current_test
, "Test application exited normally"
46 stop_session(session_info
)
48 # Check for malloc events in the resulting trace
50 babeltrace_process
= subprocess
.Popen(
51 [BABELTRACE_BIN
, session_info
.trace_path
],
52 stdout
=subprocess
.PIPE
,
53 stderr
=subprocess
.PIPE
,
55 except FileNotFoundError
:
57 "Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN
),
61 malloc_event_found
= False
62 free_event_found
= False
64 for event_line
in babeltrace_process
.stdout
:
65 # Let babeltrace finish to get the return code
66 if malloc_event_found
and free_event_found
:
69 event_line
= event_line
.decode("utf-8").replace("\n", "")
70 if re
.search(r
".*lttng_ust_libc:malloc.*", event_line
) is not None:
71 malloc_event_found
= True
73 if re
.search(r
".*lttng_ust_libc:free.*", event_line
) is not None:
74 free_event_found
= True
76 babeltrace_process
.wait()
79 babeltrace_process
.returncode
== 0, current_test
, "Resulting trace is readable"
86 "lttng_ust_libc:malloc event found in resulting trace",
91 free_event_found
, current_test
, "lttng_ust_libc:free event found in resulting trace"
95 shutil
.rmtree(session_info
.tmp_directory
)
This page took 0.031702 seconds and 4 git commands to generate.