Cleanup: run black on tree
[lttng-tools.git] / tests / regression / ust / baddr-statedump / test_baddr-statedump.py
... / ...
CommitLineData
1#!/usr/bin/env python3
2#
3# Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4# Copyright (C) 2015 Antoine Busque <abusque@efficios.com>
5#
6# SPDX-License-Identifier: GPL-2.0-only
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:
29 bail(
30 """No sessiond running. Please make sure you are running this test
31 with the "run" shell script and verify that the lttng tools are
32 properly installed."""
33 )
34
35session_info = create_session()
36enable_ust_tracepoint_event(session_info, "*")
37start_session(session_info)
38
39test_process = subprocess.Popen(
40 test_path + "prog.strip", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
41)
42test_process.wait()
43
44print_test_result(
45 test_process.returncode == 0, current_test, "Test application exited normally"
46)
47current_test += 1
48
49stop_session(session_info)
50
51# Check for statedump events in the resulting trace
52try:
53 babeltrace_process = subprocess.Popen(
54 [BABELTRACE_BIN, session_info.trace_path],
55 stdout=subprocess.PIPE,
56 stderr=subprocess.PIPE,
57 )
58except FileNotFoundError:
59 bail(
60 "Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN),
61 session_info,
62 )
63
64start_event_found = False
65bin_info_event_found = False
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
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 ):
79 continue
80
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:bin_info.*", event_line) is not None:
85 bin_info_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
92
93babeltrace_process.wait()
94
95print_test_result(
96 babeltrace_process.returncode == 0, current_test, "Resulting trace is readable"
97)
98current_test += 1
99
100print_test_result(
101 start_event_found,
102 current_test,
103 "lttng_ust_statedump:start event found in resulting trace",
104)
105current_test += 1
106
107print_test_result(
108 bin_info_event_found,
109 current_test,
110 "lttng_ust_statedump:bin_info event found in resulting trace",
111)
112current_test += 1
113
114print_test_result(
115 build_id_event_found,
116 current_test,
117 "lttng_ust_statedump:build_id event found in resulting trace",
118)
119current_test += 1
120
121print_test_result(
122 debug_link_event_found,
123 current_test,
124 "lttng_ust_statedump:debug_link event found in resulting trace",
125)
126current_test += 1
127
128print_test_result(
129 end_event_found,
130 current_test,
131 "lttng_ust_statedump:end event found in resulting trace",
132)
133current_test += 1
134
135shutil.rmtree(session_info.tmp_directory)
This page took 0.023353 seconds and 4 git commands to generate.