Fix: include stdlib.h in compat/string.h
[lttng-tools.git] / tests / regression / ust / baddr-statedump / test_baddr-statedump.py
CommitLineData
d4f53cc3
AB
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# 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.
9#
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
13# more details.
14#
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.
18
19import os
20import subprocess
21import re
22import shutil
23import sys
24
25test_path = os.path.dirname(os.path.abspath(__file__)) + "/"
26test_utils_path = test_path
27for i in range(4):
28 test_utils_path = os.path.dirname(test_utils_path)
29test_utils_path = test_utils_path + "/utils"
30sys.path.append(test_utils_path)
31from test_utils import *
32
33
34NR_TESTS = 7
35current_test = 1
36print("1..{0}".format(NR_TESTS))
37
38# Check if a sessiond is running... bail out if none found.
39if 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.""")
43
44session_info = create_session()
45enable_ust_tracepoint_event(session_info, "*")
46start_session(session_info)
47
5e7baece 48test_process = subprocess.Popen(test_path + "prog.strip", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
b6e2447a 49test_process.wait()
d4f53cc3
AB
50
51print_test_result(test_process.returncode == 0, current_test, "Test application exited normally")
52current_test += 1
53
54stop_session(session_info)
55
56# Check for statedump events in the resulting trace
57try:
58 babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
59except FileNotFoundError:
60 bail("Could not open babeltrace. Please make sure it is installed.", session_info)
61
62start_event_found = False
db4e2b3e 63bin_info_event_found = False
d4f53cc3
AB
64build_id_event_found = False
65debug_link_event_found = False
66end_event_found = False
67
68for event_line in babeltrace_process.stdout:
69 # Let babeltrace finish to get the return code
db4e2b3e 70 if start_event_found and bin_info_event_found and build_id_event_found and \
d4f53cc3
AB
71 debug_link_event_found and end_event_found:
72 continue
73
74 event_line = event_line.decode('utf-8').replace("\n", "")
75 if re.search(r".*lttng_ust_statedump:start.*", event_line) is not None:
76 start_event_found = True
db4e2b3e
AB
77 elif re.search(r".*lttng_ust_statedump:bin_info.*", event_line) is not None:
78 bin_info_event_found = True
d4f53cc3
AB
79 elif re.search(r".*lttng_ust_statedump:build_id.*", event_line) is not None:
80 build_id_event_found = True
81 elif re.search(r".*lttng_ust_statedump:debug_link.*", event_line) is not None:
82 debug_link_event_found = True
83 elif re.search(r".*lttng_ust_statedump:end.*", event_line) is not None:
84 end_event_found = True
85
86babeltrace_process.wait()
87
88print_test_result(babeltrace_process.returncode == 0, current_test, "Resulting trace is readable")
89current_test += 1
90
91print_test_result(start_event_found, current_test, "lttng_ust_statedump:start event found in resulting trace")
92current_test += 1
93
db4e2b3e 94print_test_result(bin_info_event_found, current_test, "lttng_ust_statedump:bin_info event found in resulting trace")
d4f53cc3
AB
95current_test += 1
96
97print_test_result(build_id_event_found, current_test, "lttng_ust_statedump:build_id event found in resulting trace")
98current_test += 1
99
100print_test_result(debug_link_event_found, current_test, "lttng_ust_statedump:debug_link event found in resulting trace")
101current_test += 1
102
103print_test_result(end_event_found, current_test, "lttng_ust_statedump:end event found in resulting trace")
104current_test += 1
105
106shutil.rmtree(session_info.tmp_directory)
This page took 0.044598 seconds and 5 git commands to generate.