[lttng-dev] [RFC Patch Tools 3/3] Update regression tests for UST global structure declarations

Geneviève Bastien gbastien+lttng at versatic.net
Wed Mar 26 10:55:12 EDT 2014


And fix enumeration tests that didn't work anymore.

Signed-off-by: Geneviève Bastien <gbastien+lttng at versatic.net>
---
 .../global-type-declarations.c                     |  9 ++++++
 .../test_global_type_declarations.py               | 31 ++++++++++++++++----
 .../ust/global-type-declarations/ust_tests_gtd.h   | 33 ++++++++++++++++++++++
 3 files changed, 67 insertions(+), 6 deletions(-)

diff --git a/tests/regression/ust/global-type-declarations/global-type-declarations.c b/tests/regression/ust/global-type-declarations/global-type-declarations.c
index edd6fc7..b20a9e9 100644
--- a/tests/regression/ust/global-type-declarations/global-type-declarations.c
+++ b/tests/regression/ust/global-type-declarations/global-type-declarations.c
@@ -27,11 +27,20 @@
 int main(int argc, char *argv[])
 {
 	int i;
+	char text[10] = "test";
 
 	for (i = 0; i < 2; i++) {
 		tracepoint(ust_tests_gtd, tptest, i%2, (i+1)%2);
 		tracepoint(ust_tests_gtd, tptest_bis, i%2);
 	}
 
+	tracepoint(ust_tests_gtd, tptest_struct, 0, text, strlen(text));
+
+	/*
+	 * Add a normal tracepoint after, just to be sure the previous dynamic
+	 * fields didn't wrongly offset the next event.
+	 */
+	tracepoint(ust_tests_gtd, tptest_bis, 1);
+
 	return 0;
 }
diff --git a/tests/regression/ust/global-type-declarations/test_global_type_declarations.py b/tests/regression/ust/global-type-declarations/test_global_type_declarations.py
index 5661b35..da1b476 100644
--- a/tests/regression/ust/global-type-declarations/test_global_type_declarations.py
+++ b/tests/regression/ust/global-type-declarations/test_global_type_declarations.py
@@ -29,7 +29,7 @@ test_utils_path = test_utils_path + "/utils"
 sys.path.append(test_utils_path)
 from test_utils import *
 
-NR_TESTS = 9
+NR_TESTS = 12
 current_test = 1
 print("1..{0}".format(NR_TESTS))
 
@@ -78,13 +78,14 @@ 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) == 6, current_test, "Correct number of events found in resulting trace")
 current_test += 1
 
-if len(event_lines) != 4:
+if len(event_lines) != 6:
     bail("Unexpected number of events found in resulting trace (" + session_info.trace_path + ")." )
 
-match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( \"(.*)\" :.*enumfield_bis = \( \"(.*)\" :.*", event_lines[0])
+# Test enumeration fields in tracepoints
+match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( (.*) :.*enumfield_bis = \( (.*) :.*", event_lines[0])
 print_test_result(match is not None and match.group(1) == "tptest", current_test,\
                       "First tracepoint is present")
 current_test += 1
@@ -97,7 +98,7 @@ print_test_result(match is not None and match.group(3) == "one", current_test,\
                       "First tracepoint's second enum value maps to one")
 current_test += 1
 
-match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( \"(.*)\" :.*", event_lines[1])
+match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( (.*) :.*", event_lines[1])
 print_test_result(match is not None and match.group(1) == "tptest_bis", current_test,\
                       "Second tracepoint is present")
 current_test += 1
@@ -106,9 +107,27 @@ print_test_result(match is not None and match.group(2) == "zero", current_test,\
                       "Second tracepoint's enum value maps to zero")
 current_test += 1
 
-match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( \"(.*)\" :.*enumfield_bis = \( \"(.*)\" .*", event_lines[2])
+match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( (.*) :.*enumfield_bis = \( (.*) .*", event_lines[2])
 
 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
+
+# Test structure fields in tracepoint
+match = re.search(r".*ust_tests_gtd:(.*):.*structfield = { _outer_seqfield_length = 4, outer_seqfield = \[ \[0\] = 116, \[1\] = 101, \[2\] = 115, \[3\] = 116 \].*", event_lines[4])
+print_test_result(match is not None and match.group(1) == "tptest_struct", current_test,\
+                      "Struct field in tracepoint is present with field dynamic sequence")
+current_test += 1
+
+# Test inner structure fields in tracepoint
+match = re.search(r".*ust_tests_gtd:(.*):.*innerfield = { arrfield = \[ \[0\] = 116, \[1\] = 101, \[2\] = 115, \[3\] = 116, \[4\] = 0, \[5\] = 0, \[6\] = 0, \[7\] = 0, \[8\] = 0, \[9\] = 0 \], _inner_seqfield_length = 4, inner_seqfield = \[ \[0\] = 116, \[1\] = 101, \[2\] = 115, \[3\] = 116 \], enumfield = \( zero : container = 0 \) } }.*", event_lines[4])
+print_test_result(match is not None and match.group(1) == "tptest_struct", current_test,\
+                      "Inner struct field inside another struct is present with fields dynamic sequence, array and enumeration")
+current_test += 1
+
+match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( one : container = 1 \) }", event_lines[5])
+print_test_result(match is not None and match.group(1) == "tptest_bis", current_test,\
+                      "Tracepoint after struct and dynamic field is correct")
+current_test += 1
 
 shutil.rmtree(session_info.tmp_directory)
diff --git a/tests/regression/ust/global-type-declarations/ust_tests_gtd.h b/tests/regression/ust/global-type-declarations/ust_tests_gtd.h
index ad3df0c..41b1c43 100644
--- a/tests/regression/ust/global-type-declarations/ust_tests_gtd.h
+++ b/tests/regression/ust/global-type-declarations/ust_tests_gtd.h
@@ -36,6 +36,27 @@ TRACEPOINT_ENUM(ust_tests_gtd, testenum,
 	)
 )
 
+/* Structure contains dynamic field and enumeration */
+TRACEPOINT_STRUCT(ust_tests_gtd, inner_struct,
+	TP_ARGS(char *, text, size_t, textlen,
+		int, enumvalue),
+	TP_FIELDS(
+		ctf_array(char, arrfield, text, 10)
+		ctf_sequence(char, inner_seqfield, text, size_t, textlen)
+		ctf_enum(ust_tests_gtd, testenum, enumfield, enumvalue)
+	)
+)
+
+/* Structure contains dynamic field and another structure */
+TRACEPOINT_STRUCT(ust_tests_gtd, outer_struct,
+	TP_ARGS(char *, text, size_t, textlen,
+		int, enumvalue),
+	TP_FIELDS(
+		ctf_sequence(char, outer_seqfield, text, size_t, textlen)
+		ctf_struct(ust_tests_gtd, inner_struct, innerfield, text, textlen, enumvalue)
+	)
+)
+
 /*
  * Enumeration field is used twice to make sure the global type declaration
  * is entered only once in the metadata file.
@@ -59,6 +80,18 @@ TRACEPOINT_EVENT(ust_tests_gtd, tptest_bis,
 	)
 )
 
+/*
+ * This structure uses a structure fields that contains both dynamic fields
+ * and another structure, who itself contains dynamic fields and an
+ * enumeration.
+ */
+TRACEPOINT_EVENT(ust_tests_gtd, tptest_struct,
+	TP_ARGS(int, enumval, char *, text, size_t, textlen),
+	TP_FIELDS(
+		ctf_struct(ust_tests_gtd, outer_struct, structfield, text, textlen, enumval)
+	)
+)
+
 #endif /* _TRACEPOINT_UST_TESTS_GLOBAL_TYPE_DECLARATIONS_H */
 
 #undef TRACEPOINT_INCLUDE
-- 
1.9.1




More information about the lttng-dev mailing list