Commit | Line | Data |
---|---|---|
e93e3f39 JR |
1 | import pytest |
2 | import os | |
3 | import shutil | |
4 | import signal | |
5 | import subprocess | |
6 | ||
7 | import lttng_ivc.utils.ProjectFactory as ProjectFactory | |
8 | import lttng_ivc.utils.utils as utils | |
9 | import lttng_ivc.utils.runtime as Run | |
10 | import lttng_ivc.settings as Settings | |
11 | ||
12 | """ | |
13 | ||
14 | FC: Fully Compatible | |
15 | BC: Feature of the smallest version number will works. | |
16 | TU: Tracing unavailable | |
17 | ||
18 | +------------------------------------------------------------------------------+ | |
19 | | LTTng UST control protocol compatibility matrix | | |
20 | | (between applications and tools linked on LTTng UST and liblttng-ust-ctl) | | |
21 | +--------------------------+------------+------------+------------+------------+ | |
22 | | LTTng UST / LTTng Tools | 2.7 (6.0) | 2.8 (6.1) | 2.9 (7.1) | 2.10 (7.2) | | |
23 | +--------------------------+------------+------------+------------+------------+ | |
24 | | 2.7 (6.0) | FC | BC | TU | TU | | |
25 | | 2.8 (6.1) | BC | FC | TU | TU | | |
26 | | 2.9 (7.1) | TU | TU | FC | BC | | |
27 | | 2.10 (7.2) | TU | TU | BC | FC | | |
28 | +--------------------------+------------+------------+------------+------------+ | |
29 | ||
30 | Version number of this API is defined in include/lttng/ust-abi.h of lttng-ust project | |
31 | ||
32 | """ | |
33 | ||
34 | """ | |
35 | First tuple member: lttng-ust label | |
36 | Second tuple member: lttng-tool label | |
37 | Third tuple member: expected scenario | |
38 | """ | |
39 | ||
40 | test_matrix_tracing_available = [ | |
41 | ("lttng-ust-2.7", "lttng-tools-2.7", True), | |
42 | ("lttng-ust-2.7", "lttng-tools-2.8", True), | |
43 | ("lttng-ust-2.7", "lttng-tools-2.9", False), | |
44 | ("lttng-ust-2.7", "lttng-tools-2.10", False), | |
45 | ("lttng-ust-2.8", "lttng-tools-2.7", True), | |
46 | ("lttng-ust-2.8", "lttng-tools-2.8", True), | |
47 | ("lttng-ust-2.8", "lttng-tools-2.9", False), | |
48 | ("lttng-ust-2.8", "lttng-tools-2.10", False), | |
49 | ("lttng-ust-2.9", "lttng-tools-2.7", False), | |
50 | ("lttng-ust-2.9", "lttng-tools-2.8", False), | |
51 | ("lttng-ust-2.9", "lttng-tools-2.9", True), | |
52 | ("lttng-ust-2.9", "lttng-tools-2.10", True), | |
53 | ("lttng-ust-2.10", "lttng-tools-2.7", False), | |
54 | ("lttng-ust-2.10", "lttng-tools-2.8", False), | |
55 | ("lttng-ust-2.10", "lttng-tools-2.9", True), | |
56 | ("lttng-ust-2.10", "lttng-tools-2.10", True), | |
57 | ] | |
58 | ||
59 | # Only consider test case for which tracing is valid | |
36df6d36 | 60 | test_matrix_app_context = [ |
e93e3f39 JR |
61 | ("lttng-ust-2.7", "lttng-tools-2.7", ""), |
62 | ("lttng-ust-2.7", "lttng-tools-2.8", ""), | |
63 | ("lttng-ust-2.7", "lttng-tools-2.9", ""), | |
64 | ("lttng-ust-2.7", "lttng-tools-2.10", ""), | |
65 | ("lttng-ust-2.8", "lttng-tools-2.7", ""), | |
66 | ("lttng-ust-2.8", "lttng-tools-2.8", ""), | |
67 | ("lttng-ust-2.8", "lttng-tools-2.9", ""), | |
68 | ("lttng-ust-2.8", "lttng-tools-2.10", ""), | |
69 | ("lttng-ust-2.9", "lttng-tools-2.7", ""), | |
70 | ("lttng-ust-2.9", "lttng-tools-2.8", ""), | |
71 | ("lttng-ust-2.9", "lttng-tools-2.9", ""), | |
72 | ("lttng-ust-2.9", "lttng-tools-2.10", ""), | |
73 | ("lttng-ust-2.10", "lttng-tools-2.7", ""), | |
74 | ("lttng-ust-2.10", "lttng-tools-2.8", ""), | |
75 | ("lttng-ust-2.10", "lttng-tools-2.9", ""), | |
76 | ("lttng-ust-2.10", "lttng-tools-2.10", ""), | |
77 | ] | |
78 | ||
79 | runtime_matrix_tracing_available = [] | |
80 | ||
81 | if not Settings.test_only: | |
82 | runtime_matrix_tracing_available = test_matrix_tracing_available | |
83 | else: | |
84 | for tup in test_matrix_tracing_available: | |
85 | if (tup[0] in Settings.test_only or tup[1] in | |
86 | Settings.test_only): | |
87 | runtime_matrix_tracing_available.append(tup) | |
88 | ||
89 | ||
e93e3f39 JR |
90 | @pytest.mark.parametrize("ust_label,tools_label, should_trace", runtime_matrix_tracing_available) |
91 | def test_ust_app_tracing_available(tmpdir, ust_label, tools_label, should_trace): | |
92 | ||
581ef8bb JR |
93 | if ((ust_label == "lttng-ust-2.7" and tools_label == "lttng-tools-2.8") or |
94 | (ust_label == "lttng-ust-2.8" and tools_label == "lttng-tools-2.7")): | |
95 | pytest.xfail("FAiling but should work, problem regarding the size of fields structure") | |
96 | ||
e93e3f39 JR |
97 | nb_events = 100 |
98 | ||
99 | # Prepare environment | |
100 | ust = ProjectFactory.get_precook(ust_label) | |
101 | tools = ProjectFactory.get_precook(tools_label) | |
102 | babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace) | |
103 | ||
104 | tools_runtime_path = os.path.join(str(tmpdir), "tools") | |
105 | ust_runtime_path = os.path.join(str(tmpdir), "ust") | |
106 | app_path = os.path.join(str(tmpdir), "app") | |
107 | ||
108 | with Run.get_runtime(ust_runtime_path) as runtime_app, Run.get_runtime(tools_runtime_path) as runtime_tools: | |
109 | runtime_tools.add_project(tools) | |
110 | runtime_tools.add_project(babeltrace) | |
111 | ||
112 | runtime_app.add_project(ust) | |
113 | runtime_app.lttng_home = runtime_tools.lttng_home | |
114 | ||
115 | trace_path = os.path.join(runtime_tools.lttng_home, 'trace') | |
116 | ||
117 | # Make application using the ust runtime | |
118 | shutil.copytree(Settings.apps_gen_events_folder, app_path) | |
119 | runtime_app.run("make V=1", cwd=app_path) | |
120 | ||
121 | # Start lttng-sessiond | |
36df6d36 | 122 | sessiond = utils.sessiond_spawn(runtime_tools) |
e93e3f39 JR |
123 | |
124 | # Create session using mi to get path and session name | |
125 | runtime_tools.run('lttng create trace --output={}'.format(trace_path)) | |
126 | ||
127 | # TODO: test with event present in listing | |
128 | ||
129 | runtime_tools.run('lttng enable-event -u tp:tptest') | |
130 | runtime_tools.run('lttng start') | |
131 | ||
132 | # Run application | |
133 | cmd = './app {}'.format(nb_events) | |
134 | runtime_app.run(cmd, cwd=app_path) | |
135 | ||
136 | # Stop tracing | |
137 | runtime_tools.run('lttng destroy -a') | |
36df6d36 | 138 | runtime_tools.subprocess_terminate(sessiond) |
e93e3f39 JR |
139 | |
140 | try: | |
141 | # Read trace with babeltrace and check for event count via number of line | |
142 | cmd = 'babeltrace {}'.format(trace_path) | |
143 | cp_process, cp_out, cp_err = runtime_tools.run(cmd) | |
144 | assert(utils.line_count(cp_out) == nb_events) | |
145 | except subprocess.CalledProcessError as e: | |
146 | # Check if we expected a problem here | |
147 | if should_trace: | |
148 | # Something happened | |
149 | raise e |