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:
28 bail("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.")
30 session_info
= create_session()
31 enable_ust_tracepoint_event(session_info
, "lttng_ust_libc*")
32 start_session(session_info
)
34 malloc_process
= subprocess
.Popen(test_path
+ "prog", stdout
=subprocess
.DEVNULL
, stderr
=subprocess
.DEVNULL
)
37 print_test_result(malloc_process
.returncode
== 0, current_test
, "Test application exited normally")
40 stop_session(session_info
)
42 # Check for malloc events in the resulting trace
44 babeltrace_process
= subprocess
.Popen([BABELTRACE_BIN
, session_info
.trace_path
], stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
45 except FileNotFoundError
:
46 bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN
), session_info
)
48 malloc_event_found
= False
49 free_event_found
= False
51 for event_line
in babeltrace_process
.stdout
:
52 # Let babeltrace finish to get the return code
53 if malloc_event_found
and free_event_found
:
56 event_line
= event_line
.decode('utf-8').replace("\n", "")
57 if re
.search(r
".*lttng_ust_libc:malloc.*", event_line
) is not None:
58 malloc_event_found
= True
60 if re
.search(r
".*lttng_ust_libc:free.*", event_line
) is not None:
61 free_event_found
= True
63 babeltrace_process
.wait()
65 print_test_result(babeltrace_process
.returncode
== 0, current_test
, "Resulting trace is readable")
68 print_test_result(malloc_event_found
, current_test
, "lttng_ust_libc:malloc event found in resulting trace")
71 print_test_result(free_event_found
, current_test
, "lttng_ust_libc:free event found in resulting trace")
74 shutil
.rmtree(session_info
.tmp_directory
)
This page took 0.031325 seconds and 5 git commands to generate.