3 # Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
5 # SPDX-License-Identifier: GPL-2.0-only
13 test_path
= os
.path
.dirname(os
.path
.abspath(__file__
)) + "/"
14 test_utils_path
= test_path
16 test_utils_path
= os
.path
.dirname(test_utils_path
)
17 test_utils_path
= test_utils_path
+ "/utils"
18 sys
.path
.append(test_utils_path
)
19 from test_utils
import *
23 print("1..{0}".format(NR_TESTS
))
25 # Check if a sessiond is running... bail out if none found.
26 if session_daemon_alive() == 0:
28 'No sessiond running. Please make sure you are running this test with the "run" shell script and verify that the lttng tools are properly installed.'
31 session_info
= create_session()
32 enable_ust_tracepoint_event(session_info
, "ust_tests_td*")
33 start_session(session_info
)
35 test_env
= os
.environ
.copy()
36 test_env
["LTTNG_UST_REGISTER_TIMEOUT"] = "-1"
38 td_process
= subprocess
.Popen(
39 test_path
+ "type-declarations",
40 stdout
=subprocess
.DEVNULL
,
41 stderr
=subprocess
.DEVNULL
,
47 td_process
.returncode
== 0, current_test
, "Test application exited normally"
51 stop_session(session_info
)
53 # Check event fields using type declarations are present
55 babeltrace_process
= subprocess
.Popen(
56 [BABELTRACE_BIN
, session_info
.trace_path
],
57 stdout
=subprocess
.PIPE
,
58 stderr
=subprocess
.PIPE
,
60 except FileNotFoundError
:
61 bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN
))
64 for event_line
in babeltrace_process
.stdout
:
65 event_line
= event_line
.decode("utf-8").replace("\n", "")
66 event_lines
.append(event_line
)
67 babeltrace_process
.wait()
70 babeltrace_process
.returncode
== 0, current_test
, "Resulting trace is readable"
74 if babeltrace_process
.returncode
!= 0:
75 bail("Unreadable trace; can't proceed with analysis.")
78 len(event_lines
) == 5,
80 "Correct number of events found in resulting trace",
84 if len(event_lines
) != 5:
86 "Unexpected number of events found in resulting trace ("
87 + session_info
.trace_path
92 r
".*ust_tests_td:(.*):.*enumfield = \( \"(.*)\" :.*enumfield_bis
= \
( \"(.*)\" :.*enumfield_third
= .*:.*",
96 match is not None and match.group(1) == "tptest
",
98 "First tracepoint
is present
",
103 match is not None and match.group(2) == "zero
",
105 "First tracepoint
's enum value maps to zero",
110 match is not None and match.group(3) == "one",
112 "First tracepoint's second enum value maps to one
",
116 match = re.search(r".*ust_tests_td
:(.*):.*enumfield
= \
( \"(.*)\" :.*", event_lines[1])
118 match is not None and match.group(1) == "tptest_bis
",
120 "Second tracepoint
is present
",
125 match is not None and match.group(2) == "zero
",
127 "Second tracepoint
's enum value maps to zero",
132 r".*ust_tests_td:(.*):.*enumfield = \( \"(.*)\" :.*enumfield_bis = \( \"(.*)\" .*",
137 match is not None and match.group(2) == "one",
139 "Third tracepoint's enum value maps to one
",
144 '{ zero = ( "zero
" : container = 0 ), two = ( "two
" : container = 2 ), three = ( "three
" : container = 3 ), fifteen = ( "ten_to_twenty
" : container = 15 ), twenty_one = ( "twenty_one
" : container = 21 ) }'
147 "Auto
-incrementing enum values are correct
",
150 shutil.rmtree(session_info.tmp_directory)