Commit | Line | Data |
---|---|---|
d4f53cc3 AB |
1 | #!/usr/bin/env python3 |
2 | # | |
9d16b343 MJ |
3 | # Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
4 | # Copyright (C) 2015 Antoine Busque <abusque@efficios.com> | |
d4f53cc3 | 5 | # |
9d16b343 | 6 | # SPDX-License-Identifier: GPL-2.0-only |
d4f53cc3 AB |
7 | |
8 | import os | |
9 | import subprocess | |
10 | import re | |
11 | import shutil | |
12 | import sys | |
13 | ||
14 | test_path = os.path.dirname(os.path.abspath(__file__)) + "/" | |
15 | test_utils_path = test_path | |
16 | for i in range(4): | |
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 * | |
21 | ||
22 | ||
23 | NR_TESTS = 7 | |
24 | current_test = 1 | |
25 | print("1..{0}".format(NR_TESTS)) | |
26 | ||
27 | # Check if a sessiond is running... bail out if none found. | |
28 | if session_daemon_alive() == 0: | |
6a871bbe KS |
29 | bail( |
30 | """No sessiond running. Please make sure you are running this test | |
d4f53cc3 | 31 | with the "run" shell script and verify that the lttng tools are |
6a871bbe KS |
32 | properly installed.""" |
33 | ) | |
d4f53cc3 AB |
34 | |
35 | session_info = create_session() | |
36 | enable_ust_tracepoint_event(session_info, "*") | |
37 | start_session(session_info) | |
38 | ||
6a871bbe KS |
39 | test_process = subprocess.Popen( |
40 | test_path + "prog.strip", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL | |
41 | ) | |
b6e2447a | 42 | test_process.wait() |
d4f53cc3 | 43 | |
6a871bbe KS |
44 | print_test_result( |
45 | test_process.returncode == 0, current_test, "Test application exited normally" | |
46 | ) | |
d4f53cc3 AB |
47 | current_test += 1 |
48 | ||
49 | stop_session(session_info) | |
50 | ||
51 | # Check for statedump events in the resulting trace | |
52 | try: | |
6a871bbe KS |
53 | babeltrace_process = subprocess.Popen( |
54 | [BABELTRACE_BIN, session_info.trace_path], | |
55 | stdout=subprocess.PIPE, | |
56 | stderr=subprocess.PIPE, | |
57 | ) | |
d4f53cc3 | 58 | except FileNotFoundError: |
6a871bbe KS |
59 | bail( |
60 | "Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN), | |
61 | session_info, | |
62 | ) | |
d4f53cc3 AB |
63 | |
64 | start_event_found = False | |
db4e2b3e | 65 | bin_info_event_found = False |
d4f53cc3 AB |
66 | build_id_event_found = False |
67 | debug_link_event_found = False | |
68 | end_event_found = False | |
69 | ||
70 | for event_line in babeltrace_process.stdout: | |
71 | # Let babeltrace finish to get the return code | |
6a871bbe KS |
72 | if ( |
73 | start_event_found | |
74 | and bin_info_event_found | |
75 | and build_id_event_found | |
76 | and debug_link_event_found | |
77 | and end_event_found | |
78 | ): | |
d4f53cc3 AB |
79 | continue |
80 | ||
6a871bbe | 81 | event_line = event_line.decode("utf-8").replace("\n", "") |
d4f53cc3 AB |
82 | if re.search(r".*lttng_ust_statedump:start.*", event_line) is not None: |
83 | start_event_found = True | |
db4e2b3e AB |
84 | elif re.search(r".*lttng_ust_statedump:bin_info.*", event_line) is not None: |
85 | bin_info_event_found = True | |
d4f53cc3 AB |
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 | |
92 | ||
93 | babeltrace_process.wait() | |
94 | ||
6a871bbe KS |
95 | print_test_result( |
96 | babeltrace_process.returncode == 0, current_test, "Resulting trace is readable" | |
97 | ) | |
d4f53cc3 AB |
98 | current_test += 1 |
99 | ||
6a871bbe KS |
100 | print_test_result( |
101 | start_event_found, | |
102 | current_test, | |
103 | "lttng_ust_statedump:start event found in resulting trace", | |
104 | ) | |
d4f53cc3 AB |
105 | current_test += 1 |
106 | ||
6a871bbe KS |
107 | print_test_result( |
108 | bin_info_event_found, | |
109 | current_test, | |
110 | "lttng_ust_statedump:bin_info event found in resulting trace", | |
111 | ) | |
d4f53cc3 AB |
112 | current_test += 1 |
113 | ||
6a871bbe KS |
114 | print_test_result( |
115 | build_id_event_found, | |
116 | current_test, | |
117 | "lttng_ust_statedump:build_id event found in resulting trace", | |
118 | ) | |
d4f53cc3 AB |
119 | current_test += 1 |
120 | ||
6a871bbe KS |
121 | print_test_result( |
122 | debug_link_event_found, | |
123 | current_test, | |
124 | "lttng_ust_statedump:debug_link event found in resulting trace", | |
125 | ) | |
d4f53cc3 AB |
126 | current_test += 1 |
127 | ||
6a871bbe KS |
128 | print_test_result( |
129 | end_event_found, | |
130 | current_test, | |
131 | "lttng_ust_statedump:end event found in resulting trace", | |
132 | ) | |
d4f53cc3 AB |
133 | current_test += 1 |
134 | ||
135 | shutil.rmtree(session_info.tmp_directory) |