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 *
25 print("1..{0}".format(NR_TESTS
))
27 # Check if a sessiond is running... bail out if none found.
28 if session_daemon_alive() == 0:
29 bail("""No sessiond running. Please make sure you are running this test
30 with the "run" shell script and verify that the lttng tools are
31 properly installed.""")
33 session_info
= create_session()
34 enable_ust_tracepoint_event(session_info
, "*")
35 start_session(session_info
)
37 test_process
= subprocess
.Popen(test_path
+ "prog.strip", stdout
=subprocess
.DEVNULL
, stderr
=subprocess
.DEVNULL
)
40 print_test_result(test_process
.returncode
== 0, current_test
, "Test application exited normally")
43 stop_session(session_info
)
45 # Check for statedump events in the resulting trace
47 babeltrace_process
= subprocess
.Popen(["babeltrace", session_info
.trace_path
], stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
48 except FileNotFoundError
:
49 bail("Could not open babeltrace. Please make sure it is installed.", session_info
)
51 start_event_found
= False
52 bin_info_event_found
= False
53 build_id_event_found
= False
54 debug_link_event_found
= False
55 end_event_found
= False
57 for event_line
in babeltrace_process
.stdout
:
58 # Let babeltrace finish to get the return code
59 if start_event_found
and bin_info_event_found
and build_id_event_found
and \
60 debug_link_event_found
and end_event_found
:
63 event_line
= event_line
.decode('utf-8').replace("\n", "")
64 if re
.search(r
".*lttng_ust_statedump:start.*", event_line
) is not None:
65 start_event_found
= True
66 elif re
.search(r
".*lttng_ust_statedump:bin_info.*", event_line
) is not None:
67 bin_info_event_found
= True
68 elif re
.search(r
".*lttng_ust_statedump:build_id.*", event_line
) is not None:
69 build_id_event_found
= True
70 elif re
.search(r
".*lttng_ust_statedump:debug_link.*", event_line
) is not None:
71 debug_link_event_found
= True
72 elif re
.search(r
".*lttng_ust_statedump:end.*", event_line
) is not None:
73 end_event_found
= True
75 babeltrace_process
.wait()
77 print_test_result(babeltrace_process
.returncode
== 0, current_test
, "Resulting trace is readable")
80 print_test_result(start_event_found
, current_test
, "lttng_ust_statedump:start event found in resulting trace")
83 print_test_result(bin_info_event_found
, current_test
, "lttng_ust_statedump:bin_info event found in resulting trace")
86 print_test_result(build_id_event_found
, current_test
, "lttng_ust_statedump:build_id event found in resulting trace")
89 print_test_result(debug_link_event_found
, current_test
, "lttng_ust_statedump:debug_link event found in resulting trace")
92 print_test_result(end_event_found
, current_test
, "lttng_ust_statedump:end event found in resulting trace")
95 shutil
.rmtree(session_info
.tmp_directory
)
This page took 0.041328 seconds and 5 git commands to generate.