Cleanup: run black on tree
[lttng-tools.git] / tests / regression / ust / baddr-statedump / test_baddr-statedump.py
CommitLineData
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
8import os
9import subprocess
10import re
11import shutil
12import sys
13
14test_path = os.path.dirname(os.path.abspath(__file__)) + "/"
15test_utils_path = test_path
16for i in range(4):
17 test_utils_path = os.path.dirname(test_utils_path)
18test_utils_path = test_utils_path + "/utils"
19sys.path.append(test_utils_path)
20from test_utils import *
21
22
23NR_TESTS = 7
24current_test = 1
25print("1..{0}".format(NR_TESTS))
26
27# Check if a sessiond is running... bail out if none found.
28if 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
35session_info = create_session()
36enable_ust_tracepoint_event(session_info, "*")
37start_session(session_info)
38
6a871bbe
KS
39test_process = subprocess.Popen(
40 test_path + "prog.strip", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
41)
b6e2447a 42test_process.wait()
d4f53cc3 43
6a871bbe
KS
44print_test_result(
45 test_process.returncode == 0, current_test, "Test application exited normally"
46)
d4f53cc3
AB
47current_test += 1
48
49stop_session(session_info)
50
51# Check for statedump events in the resulting trace
52try:
6a871bbe
KS
53 babeltrace_process = subprocess.Popen(
54 [BABELTRACE_BIN, session_info.trace_path],
55 stdout=subprocess.PIPE,
56 stderr=subprocess.PIPE,
57 )
d4f53cc3 58except 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
64start_event_found = False
db4e2b3e 65bin_info_event_found = False
d4f53cc3
AB
66build_id_event_found = False
67debug_link_event_found = False
68end_event_found = False
69
70for 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
93babeltrace_process.wait()
94
6a871bbe
KS
95print_test_result(
96 babeltrace_process.returncode == 0, current_test, "Resulting trace is readable"
97)
d4f53cc3
AB
98current_test += 1
99
6a871bbe
KS
100print_test_result(
101 start_event_found,
102 current_test,
103 "lttng_ust_statedump:start event found in resulting trace",
104)
d4f53cc3
AB
105current_test += 1
106
6a871bbe
KS
107print_test_result(
108 bin_info_event_found,
109 current_test,
110 "lttng_ust_statedump:bin_info event found in resulting trace",
111)
d4f53cc3
AB
112current_test += 1
113
6a871bbe
KS
114print_test_result(
115 build_id_event_found,
116 current_test,
117 "lttng_ust_statedump:build_id event found in resulting trace",
118)
d4f53cc3
AB
119current_test += 1
120
6a871bbe
KS
121print_test_result(
122 debug_link_event_found,
123 current_test,
124 "lttng_ust_statedump:debug_link event found in resulting trace",
125)
d4f53cc3
AB
126current_test += 1
127
6a871bbe
KS
128print_test_result(
129 end_event_found,
130 current_test,
131 "lttng_ust_statedump:end event found in resulting trace",
132)
d4f53cc3
AB
133current_test += 1
134
135shutil.rmtree(session_info.tmp_directory)
This page took 0.079295 seconds and 4 git commands to generate.