Commit | Line | Data |
---|---|---|
7a8653b4 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 | ||
20 | """ | |
21 | First tuple member: lttng-ust label | |
22 | Second tuple member: lttng-tool label | |
23 | Third tuple member: expected scenario | |
24 | """ | |
25 | ||
26 | event_registration_error = "Error: UST app recv reg unsupported version" | |
27 | ||
28 | test_matrix_base_app_tracing_available = [ | |
29 | ("lttng-ust-2.7", "lttng-tools-2.7", True), | |
30 | ("lttng-ust-2.7", "lttng-tools-2.8", True), | |
31 | ("lttng-ust-2.7", "lttng-tools-2.9", True), | |
32 | ("lttng-ust-2.7", "lttng-tools-2.10", True), | |
33 | ("lttng-ust-2.8", "lttng-tools-2.7", True), | |
34 | ("lttng-ust-2.8", "lttng-tools-2.8", True), | |
35 | ("lttng-ust-2.8", "lttng-tools-2.9", True), | |
36 | ("lttng-ust-2.8", "lttng-tools-2.10", True), | |
37 | ("lttng-ust-2.9", "lttng-tools-2.7", True), | |
38 | ("lttng-ust-2.9", "lttng-tools-2.8", True), | |
39 | ("lttng-ust-2.9", "lttng-tools-2.9", True), | |
40 | ("lttng-ust-2.9", "lttng-tools-2.10", True), | |
41 | ("lttng-ust-2.10", "lttng-tools-2.7", True), | |
42 | ("lttng-ust-2.10", "lttng-tools-2.8", True), | |
43 | ("lttng-ust-2.10", "lttng-tools-2.9", True), | |
44 | ("lttng-ust-2.10", "lttng-tools-2.10", True), | |
45 | ] | |
46 | ||
47 | runtime_matrix_base_app_tracing_available = [] | |
48 | ||
49 | if not Settings.test_only: | |
50 | runtime_matrix_base_app_tracing_available = test_matrix_base_app_tracing_available | |
51 | else: | |
52 | for tup in test_matrix_base_app_tracing_available: | |
53 | if (tup[0] in Settings.test_only or tup[1] in | |
54 | Settings.test_only): | |
55 | runtime_matrix_base_app_tracing_available.append(tup) | |
56 | ||
57 | ||
58 | @pytest.mark.parametrize("ust_label,tools_label,success", runtime_matrix_base_app_tracing_available) | |
59 | def test_ust_app_tools_update_tracing_available(tmpdir, ust_label, tools_label, success): | |
60 | ||
61 | nb_events = 100 | |
62 | ||
63 | # Prepare environment | |
64 | ust = ProjectFactory.get_precook(ust_label) | |
65 | tools = ProjectFactory.get_precook(tools_label) | |
66 | babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace) | |
67 | ||
68 | tools_runtime_path = os.path.join(str(tmpdir), "tools") | |
69 | ust_runtime_path = os.path.join(str(tmpdir), "ust") | |
70 | app_path = os.path.join(str(tmpdir), "app") | |
71 | ||
72 | with Run.get_runtime(ust_runtime_path) as runtime_app, Run.get_runtime(tools_runtime_path) as runtime_tools: | |
73 | runtime_tools.add_project(tools) | |
74 | runtime_tools.add_project(babeltrace) | |
75 | ||
76 | runtime_app.add_project(ust) | |
77 | runtime_app.lttng_home = runtime_tools.lttng_home | |
78 | ||
79 | trace_path = os.path.join(runtime_tools.lttng_home, 'trace') | |
80 | ||
81 | # Make application using the ust runtime | |
82 | shutil.copytree(Settings.apps_gen_events_folder, app_path) | |
83 | runtime_app.run("make V=1", cwd=app_path) | |
84 | ||
85 | # Start lttng-sessiond | |
86 | sessiond = utils.sessiond_spawn(runtime_tools) | |
87 | ||
88 | # Create session using mi to get path and session name | |
89 | runtime_tools.run('lttng create trace --output={}'.format(trace_path)) | |
90 | ||
91 | runtime_tools.run('lttng enable-event -u tp:tptest') | |
92 | runtime_tools.run('lttng start') | |
93 | ||
94 | # Run application | |
95 | cmd = './app {}'.format(nb_events) | |
96 | runtime_tools.run(cmd, cwd=app_path) | |
97 | ||
98 | runtime_tools.run("lddtree ./app", cwd=app_path) | |
99 | runtime_app.run("lddtree ./app", cwd=app_path) | |
100 | ||
101 | # Stop tracing | |
102 | runtime_tools.run('lttng stop') | |
103 | runtime_tools.run('lttng destroy -a') | |
104 | cp = runtime_tools.subprocess_terminate(sessiond) | |
105 | if cp.returncode != 0: | |
106 | pytest.fail("Sessiond return code") | |
107 | ||
108 | ||
109 | cmd = 'babeltrace {}'.format(trace_path) | |
110 | if success : | |
111 | cp_process, cp_out, cp_err = runtime_tools.run(cmd) | |
112 | assert(utils.line_count(cp_out) == nb_events) | |
113 | else: | |
114 | with pytest.raises(subprocess.CalledProcessError): | |
115 | cp_process, cp_out, cp_err = runtime_tools.run(cmd) |