Commit | Line | Data |
---|---|---|
efdd48db JR |
1 | # Copyright (c) 2017 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
2 | # | |
3 | # Permission is hereby granted, free of charge, to any person obtaining a copy | |
4 | # of this software and associated documentation files (the "Software"), to deal | |
5 | # in the Software without restriction, including without limitation the rights | |
6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
7 | # copies of the Software, and to permit persons to whom the Software is | |
8 | # furnished to do so, subject to the following conditions: | |
9 | # | |
10 | # The above copyright notice and this permission notice shall be included in all | |
11 | # copies or substantial portions of the Software. | |
12 | # | |
13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
19 | # SOFTWARE. | |
20 | ||
7a8653b4 JR |
21 | import pytest |
22 | import os | |
23 | import shutil | |
24 | import signal | |
25 | import subprocess | |
26 | ||
27 | import lttng_ivc.utils.ProjectFactory as ProjectFactory | |
28 | import lttng_ivc.utils.utils as utils | |
29 | import lttng_ivc.utils.runtime as Run | |
30 | import lttng_ivc.settings as Settings | |
31 | ||
32 | """ | |
33 | ||
34 | FC: Fully Compatible | |
35 | BC: Feature of the smallest version number will works. | |
36 | TU: Tracing unavailable | |
37 | ||
38 | """ | |
39 | ||
40 | """ | |
41 | First tuple member: lttng-ust label | |
42 | Second tuple member: lttng-tool label | |
43 | Third tuple member: expected scenario | |
44 | """ | |
45 | ||
46 | event_registration_error = "Error: UST app recv reg unsupported version" | |
47 | ||
48 | test_matrix_base_app_tracing_available = [ | |
49 | ("lttng-ust-2.7", "lttng-tools-2.7", True), | |
50 | ("lttng-ust-2.7", "lttng-tools-2.8", True), | |
51 | ("lttng-ust-2.7", "lttng-tools-2.9", True), | |
52 | ("lttng-ust-2.7", "lttng-tools-2.10", True), | |
53 | ("lttng-ust-2.8", "lttng-tools-2.7", True), | |
54 | ("lttng-ust-2.8", "lttng-tools-2.8", True), | |
55 | ("lttng-ust-2.8", "lttng-tools-2.9", True), | |
56 | ("lttng-ust-2.8", "lttng-tools-2.10", True), | |
57 | ("lttng-ust-2.9", "lttng-tools-2.7", True), | |
58 | ("lttng-ust-2.9", "lttng-tools-2.8", True), | |
59 | ("lttng-ust-2.9", "lttng-tools-2.9", True), | |
60 | ("lttng-ust-2.9", "lttng-tools-2.10", True), | |
61 | ("lttng-ust-2.10", "lttng-tools-2.7", True), | |
62 | ("lttng-ust-2.10", "lttng-tools-2.8", True), | |
63 | ("lttng-ust-2.10", "lttng-tools-2.9", True), | |
64 | ("lttng-ust-2.10", "lttng-tools-2.10", True), | |
65 | ] | |
66 | ||
67 | runtime_matrix_base_app_tracing_available = [] | |
68 | ||
69 | if not Settings.test_only: | |
70 | runtime_matrix_base_app_tracing_available = test_matrix_base_app_tracing_available | |
71 | else: | |
72 | for tup in test_matrix_base_app_tracing_available: | |
73 | if (tup[0] in Settings.test_only or tup[1] in | |
74 | Settings.test_only): | |
75 | runtime_matrix_base_app_tracing_available.append(tup) | |
76 | ||
77 | ||
78 | @pytest.mark.parametrize("ust_label,tools_label,success", runtime_matrix_base_app_tracing_available) | |
79 | def test_ust_app_tools_update_tracing_available(tmpdir, ust_label, tools_label, success): | |
80 | ||
81 | nb_events = 100 | |
82 | ||
83 | # Prepare environment | |
84 | ust = ProjectFactory.get_precook(ust_label) | |
85 | tools = ProjectFactory.get_precook(tools_label) | |
86 | babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace) | |
87 | ||
88 | tools_runtime_path = os.path.join(str(tmpdir), "tools") | |
89 | ust_runtime_path = os.path.join(str(tmpdir), "ust") | |
90 | app_path = os.path.join(str(tmpdir), "app") | |
91 | ||
92 | with Run.get_runtime(ust_runtime_path) as runtime_app, Run.get_runtime(tools_runtime_path) as runtime_tools: | |
93 | runtime_tools.add_project(tools) | |
94 | runtime_tools.add_project(babeltrace) | |
95 | ||
96 | runtime_app.add_project(ust) | |
97 | runtime_app.lttng_home = runtime_tools.lttng_home | |
98 | ||
99 | trace_path = os.path.join(runtime_tools.lttng_home, 'trace') | |
100 | ||
101 | # Make application using the ust runtime | |
102 | shutil.copytree(Settings.apps_gen_events_folder, app_path) | |
103 | runtime_app.run("make V=1", cwd=app_path) | |
104 | ||
105 | # Start lttng-sessiond | |
106 | sessiond = utils.sessiond_spawn(runtime_tools) | |
107 | ||
108 | # Create session using mi to get path and session name | |
109 | runtime_tools.run('lttng create trace --output={}'.format(trace_path)) | |
110 | ||
111 | runtime_tools.run('lttng enable-event -u tp:tptest') | |
112 | runtime_tools.run('lttng start') | |
113 | ||
114 | # Run application | |
115 | cmd = './app {}'.format(nb_events) | |
116 | runtime_tools.run(cmd, cwd=app_path) | |
117 | ||
118 | runtime_tools.run("lddtree ./app", cwd=app_path) | |
119 | runtime_app.run("lddtree ./app", cwd=app_path) | |
120 | ||
121 | # Stop tracing | |
122 | runtime_tools.run('lttng stop') | |
123 | runtime_tools.run('lttng destroy -a') | |
124 | cp = runtime_tools.subprocess_terminate(sessiond) | |
125 | if cp.returncode != 0: | |
126 | pytest.fail("Sessiond return code") | |
127 | ||
128 | ||
129 | cmd = 'babeltrace {}'.format(trace_path) | |
130 | if success : | |
131 | cp_process, cp_out, cp_err = runtime_tools.run(cmd) | |
132 | assert(utils.line_count(cp_out) == nb_events) | |
133 | else: | |
134 | with pytest.raises(subprocess.CalledProcessError): | |
135 | cp_process, cp_out, cp_err = runtime_tools.run(cmd) |