From 358f4691e7c9b46551aa1f2f6f689e090eb9bce5 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 4 Jul 2016 18:24:19 -0400 Subject: [PATCH] Test UST's autoincrementing enumeration values MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- .../test_type_declarations.py | 8 +++++-- .../ust/type-declarations/type-declarations.c | 2 ++ .../ust/type-declarations/ust_tests_td.h | 24 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/regression/ust/type-declarations/test_type_declarations.py b/tests/regression/ust/type-declarations/test_type_declarations.py index b2fa282a1..5f78c9042 100644 --- a/tests/regression/ust/type-declarations/test_type_declarations.py +++ b/tests/regression/ust/type-declarations/test_type_declarations.py @@ -70,10 +70,10 @@ current_test += 1 if babeltrace_process.returncode != 0: bail("Unreadable trace; can't proceed with analysis.") -print_test_result(len(event_lines) == 4, current_test, "Correct number of events found in resulting trace") +print_test_result(len(event_lines) == 5, current_test, "Correct number of events found in resulting trace") current_test += 1 -if len(event_lines) != 4: +if len(event_lines) != 5: bail("Unexpected number of events found in resulting trace (" + session_info.trace_path + ")." ) match = re.search(r".*ust_tests_td:(.*):.*enumfield = \( \"(.*)\" :.*enumfield_bis = \( \"(.*)\" :.*enumfield_third = .*:.*", event_lines[0]) @@ -102,5 +102,9 @@ match = re.search(r".*ust_tests_td:(.*):.*enumfield = \( \"(.*)\" :.*enumfield_b print_test_result(match is not None and match.group(2) == "one", current_test,\ "Third tracepoint's enum value maps to one") +current_test += 1 + +print_test_result('{ zero = ( "zero" : container = 0 ), two = ( "two" : container = 2 ), three = ( "three" : container = 3 ), fifteen = ( "ten_to_twenty" : container = 15 ), twenty_one = ( "twenty_one" : container = 21 ) }' in event_lines[4], + current_test, 'Auto-incrementing enum values are correct') shutil.rmtree(session_info.tmp_directory) diff --git a/tests/regression/ust/type-declarations/type-declarations.c b/tests/regression/ust/type-declarations/type-declarations.c index fae09b713..516ff616e 100644 --- a/tests/regression/ust/type-declarations/type-declarations.c +++ b/tests/regression/ust/type-declarations/type-declarations.c @@ -35,5 +35,7 @@ int main(int argc, char *argv[]) tracepoint(ust_tests_td, tptest_bis, i % 2); } + tracepoint(ust_tests_td, test_auto); + return 0; } diff --git a/tests/regression/ust/type-declarations/ust_tests_td.h b/tests/regression/ust/type-declarations/ust_tests_td.h index 45bccbfab..5339b0900 100644 --- a/tests/regression/ust/type-declarations/ust_tests_td.h +++ b/tests/regression/ust/type-declarations/ust_tests_td.h @@ -43,6 +43,16 @@ TRACEPOINT_ENUM(ust_tests_td, testenum2, ) ) +TRACEPOINT_ENUM(ust_tests_td, testenum3, + TP_ENUM_VALUES( + ctf_enum_auto("zero") + ctf_enum_value("two", 2) + ctf_enum_auto("three") + ctf_enum_range("ten_to_twenty", 10, 20) + ctf_enum_auto("twenty_one") + ) +) + /* * Enumeration field is used twice to make sure the global type declaration * is entered only once in the metadata file. @@ -70,6 +80,20 @@ TRACEPOINT_EVENT(ust_tests_td, tptest_bis, ) ) +/* + * Test autoincrementing enumeration values. + */ +TRACEPOINT_EVENT(ust_tests_td, test_auto, + TP_ARGS(void), + TP_FIELDS( + ctf_enum(ust_tests_td, testenum3, int, zero, 0) + ctf_enum(ust_tests_td, testenum3, int, two, 2) + ctf_enum(ust_tests_td, testenum3, int, three, 3) + ctf_enum(ust_tests_td, testenum3, int, fifteen, 15) + ctf_enum(ust_tests_td, testenum3, int, twenty_one, 21) + ) +) + #endif /* _TRACEPOINT_UST_TESTS_TD_H */ #undef TRACEPOINT_INCLUDE -- 2.34.1