3 # Copyright (C) - 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 # Copyright (C) - 2015 Antoine Busque <abusque@efficios.com>
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License, version 2 only, as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 # You should have received a copy of the GNU General Public License along with
16 # this program; if not, write to the Free Software Foundation, Inc., 51
17 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 test_path
= os
.path
.dirname(os
.path
.abspath(__file__
)) + "/"
26 test_utils_path
= test_path
28 test_utils_path
= os
.path
.dirname(test_utils_path
)
29 test_utils_path
= test_utils_path
+ "/utils"
30 sys
.path
.append(test_utils_path
)
31 from test_utils
import *
36 print("1..{0}".format(NR_TESTS
))
38 # Check if a sessiond is running... bail out if none found.
39 if session_daemon_alive() == 0:
40 bail("""No sessiond running. Please make sure you are running this test
41 with the "run" shell script and verify that the lttng tools are
42 properly installed.""")
44 session_info
= create_session()
45 enable_ust_tracepoint_event(session_info
, "*")
46 start_session(session_info
)
48 test_process
= subprocess
.Popen(test_path
+ "prog", stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
49 if sys
.version_info
>= (3, 3):
52 except subprocess
.TimeoutExpired
:
54 bail("Failed to run ust baddr-statedump test application.", session_info
)
58 print_test_result(test_process
.returncode
== 0, current_test
, "Test application exited normally")
61 stop_session(session_info
)
63 # Check for statedump events in the resulting trace
65 babeltrace_process
= subprocess
.Popen(["babeltrace", session_info
.trace_path
], stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
66 except FileNotFoundError
:
67 bail("Could not open babeltrace. Please make sure it is installed.", session_info
)
69 start_event_found
= False
70 soinfo_event_found
= False
71 build_id_event_found
= False
72 debug_link_event_found
= False
73 end_event_found
= False
75 for event_line
in babeltrace_process
.stdout
:
76 # Let babeltrace finish to get the return code
77 if start_event_found
and soinfo_event_found
and build_id_event_found
and \
78 debug_link_event_found
and end_event_found
:
81 event_line
= event_line
.decode('utf-8').replace("\n", "")
82 if re
.search(r
".*lttng_ust_statedump:start.*", event_line
) is not None:
83 start_event_found
= True
84 elif re
.search(r
".*lttng_ust_statedump:soinfo.*", event_line
) is not None:
85 soinfo_event_found
= True
86 elif re
.search(r
".*lttng_ust_statedump:build_id.*", event_line
) is not None:
87 build_id_event_found
= True
88 elif re
.search(r
".*lttng_ust_statedump:debug_link.*", event_line
) is not None:
89 debug_link_event_found
= True
90 elif re
.search(r
".*lttng_ust_statedump:end.*", event_line
) is not None:
91 end_event_found
= True
93 babeltrace_process
.wait()
95 print_test_result(babeltrace_process
.returncode
== 0, current_test
, "Resulting trace is readable")
98 print_test_result(start_event_found
, current_test
, "lttng_ust_statedump:start event found in resulting trace")
101 print_test_result(soinfo_event_found
, current_test
, "lttng_ust_statedump:soinfo event found in resulting trace")
104 print_test_result(build_id_event_found
, current_test
, "lttng_ust_statedump:build_id event found in resulting trace")
107 print_test_result(debug_link_event_found
, current_test
, "lttng_ust_statedump:debug_link event found in resulting trace")
110 print_test_result(end_event_found
, current_test
, "lttng_ust_statedump:end event found in resulting trace")
113 shutil
.rmtree(session_info
.tmp_directory
)
This page took 0.031925 seconds and 5 git commands to generate.