Commit | Line | Data |
---|---|---|
69e4e7d8 JR |
1 | import pytest |
2 | import subprocess | |
3 | import platform | |
4 | import shutil | |
5 | import os | |
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 | FC: Fully Compatible | |
14 | I: Incompatible | |
15 | ||
16 | +------------------------------------------------------------------------------+ | |
17 | | LTTng consumer daemon vs LTTng session daemon | | |
18 | +--------------------------+------------+------------+------------+------------+ | |
19 | | Consumerd/Sessiond | 2.7 | 2.8 | 2.9 | 2.10 | | |
20 | +--------------------------+------------+------------+------------+------------+ | |
21 | | 2.7 | FC | I | I | I | | |
22 | | 2.8 | I | FC | I | I | | |
23 | | 2.9 | I | I | FC | I | | |
24 | | 2.10 | I | I | I | FC | | |
25 | +--------------------------+------------+------------+------------+------------+ | |
26 | ||
27 | """ | |
28 | ||
29 | test_matrix_consumerd = [ | |
30 | ("lttng-tools-2.7", "lttng-tools-2.7", True), | |
31 | ("lttng-tools-2.7", "lttng-tools-2.8", False), | |
32 | ("lttng-tools-2.7", "lttng-tools-2.9", False), | |
33 | ("lttng-tools-2.7", "lttng-tools-2.10", False), | |
34 | ("lttng-tools-2.8", "lttng-tools-2.7", False), | |
35 | ("lttng-tools-2.8", "lttng-tools-2.8", True), | |
36 | ("lttng-tools-2.8", "lttng-tools-2.9", False), | |
37 | ("lttng-tools-2.8", "lttng-tools-2.10", False), | |
38 | ("lttng-tools-2.9", "lttng-tools-2.7", False), | |
39 | ("lttng-tools-2.9", "lttng-tools-2.8", False), | |
40 | ("lttng-tools-2.9", "lttng-tools-2.9", True), | |
41 | ("lttng-tools-2.9", "lttng-tools-2.10", False), | |
42 | ("lttng-tools-2.10", "lttng-tools-2.7", False), | |
43 | ("lttng-tools-2.10", "lttng-tools-2.8", False), | |
44 | ("lttng-tools-2.10", "lttng-tools-2.9", False), | |
45 | ("lttng-tools-2.10", "lttng-tools-2.10", True), | |
46 | ] | |
47 | ||
48 | runtime_matrix_consumerd = [] | |
49 | ||
50 | if not Settings.test_only: | |
51 | runtime_matrix_consumerd = test_matrix_consumerd | |
52 | else: | |
53 | for tup in test_matrix_consumerd: | |
54 | if (tup[0] in Settings.test_only or tup[1] in | |
55 | Settings.test_only): | |
56 | runtime_matrix_consumerd.append(tup) | |
57 | ||
58 | ||
59 | @pytest.mark.parametrize("consumerd_l,tools_l,should_work", runtime_matrix_consumerd) | |
60 | def test_consumerd_vs_sessiond(tmpdir, consumerd_l, tools_l, should_work): | |
61 | ||
62 | # Prepare environment | |
63 | consumerd = ProjectFactory.get_precook(consumerd_l) | |
64 | tools = ProjectFactory.get_precook(tools_l) | |
65 | ||
66 | app_path = os.path.join(str(tmpdir), "app") | |
67 | ||
68 | replacement_consumerd = utils.find_file(consumerd.installation_path, "lttng-consumerd") | |
69 | assert(replacement_consumerd) | |
70 | ||
71 | c_dict = {"32bit": "-consumerd32-path", "64bit": "--consumerd64-path"} | |
72 | platform_type = platform.architecture()[0] | |
73 | ||
74 | sessiond_opt_args = "{}={}".format(c_dict[platform_type], replacement_consumerd) | |
75 | ||
76 | with Run.get_runtime(str(tmpdir)) as runtime: | |
77 | runtime.add_project(tools) | |
78 | ||
79 | shutil.copytree(Settings.apps_gen_events_folder, app_path) | |
80 | runtime.run("make V=1", cwd=app_path) | |
81 | ||
82 | utils.sessiond_spawn(runtime, sessiond_opt_args) | |
83 | ||
84 | # Consumer is only called on channel creation | |
85 | runtime.run("lttng create") | |
86 | try: | |
87 | runtime.run("lttng enable-event -u tp:test", timeout=5) | |
88 | runtime.run("lttng start", timeout=5) | |
89 | ||
90 | # Run application | |
91 | cmd = './app {}'.format(100) | |
92 | runtime.run(cmd, cwd=app_path) | |
93 | ||
94 | runtime.run("lttng destroy -a", timeout=5) | |
95 | except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e: | |
96 | if should_work: | |
97 | raise e | |
98 | if not should_work: | |
99 | raise Exception("Supposed to fail") | |
100 |