| 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 | |
| 21 | import pytest |
| 22 | import os |
| 23 | |
| 24 | import lttng_ivc.utils.ProjectFactory as ProjectFactory |
| 25 | import lttng_ivc.utils.utils as utils |
| 26 | import lttng_ivc.utils.runtime as Run |
| 27 | import lttng_ivc.settings as Settings |
| 28 | |
| 29 | """ |
| 30 | Backward compatibility testing for lttng-ctl |
| 31 | """ |
| 32 | |
| 33 | """ |
| 34 | First tuple member: lttng-tools label from which the client (lttng bin) is sourced |
| 35 | Second tuple member: lttng-tools label for runtime sessiond and lttng-ctl |
| 36 | Third tuple member: expected scenario |
| 37 | """ |
| 38 | |
| 39 | test_matrix_basic_listing = [ |
| 40 | ("lttng-tools-2.7", "lttng-tools-2.7", "Success"), |
| 41 | ("lttng-tools-2.7", "lttng-tools-2.8", "Success"), |
| 42 | ("lttng-tools-2.7", "lttng-tools-2.9", "Success"), |
| 43 | ("lttng-tools-2.7", "lttng-tools-2.10", "Success"), |
| 44 | ("lttng-tools-2.8", "lttng-tools-2.7", "Missing symbol"), |
| 45 | ("lttng-tools-2.8", "lttng-tools-2.8", "Success"), |
| 46 | ("lttng-tools-2.8", "lttng-tools-2.9", "Success"), |
| 47 | ("lttng-tools-2.8", "lttng-tools-2.10", "Success"), |
| 48 | ("lttng-tools-2.9", "lttng-tools-2.7", "Missing symbol"), |
| 49 | ("lttng-tools-2.9", "lttng-tools-2.8", "Missing symbol"), |
| 50 | ("lttng-tools-2.9", "lttng-tools-2.9", "Success"), |
| 51 | ("lttng-tools-2.9", "lttng-tools-2.10", "Success"), |
| 52 | ("lttng-tools-2.10", "lttng-tools-2.7", "Missing symbol"), |
| 53 | ("lttng-tools-2.10", "lttng-tools-2.8", "Missing symbol"), |
| 54 | ("lttng-tools-2.10", "lttng-tools-2.9", "Missing symbol"), |
| 55 | ("lttng-tools-2.10", "lttng-tools-2.10", "Success"), |
| 56 | ] |
| 57 | |
| 58 | runtime_matrix_basic_listing = [] |
| 59 | |
| 60 | if not Settings.test_only: |
| 61 | runtime_matrix_basic_listing = test_matrix_basic_listing |
| 62 | else: |
| 63 | for tup in test_matrix_basic_listing: |
| 64 | if (tup[0] in Settings.test_only or tup[1] in |
| 65 | Settings.test_only): |
| 66 | runtime_matrix_basic_listing.append(tup) |
| 67 | |
| 68 | @pytest.mark.parametrize("client_label,tools_label,outcome", runtime_matrix_basic_listing) |
| 69 | def test_tools_liblttng_ctl_vs_sessiond_basic_listing(tmpdir, client_label, tools_label, outcome): |
| 70 | |
| 71 | # Prepare environment |
| 72 | client = ProjectFactory.get_precook(client_label) |
| 73 | tools = ProjectFactory.get_precook(tools_label) |
| 74 | |
| 75 | tools_runtime_path = os.path.join(str(tmpdir), "tools") |
| 76 | |
| 77 | lttng_client = os.path.join(client.installation_path, "bin/lttng") |
| 78 | |
| 79 | with Run.get_runtime(tools_runtime_path) as runtime_tools: |
| 80 | runtime_tools.add_project(tools) |
| 81 | |
| 82 | sessiond = utils.sessiond_spawn(runtime_tools) |
| 83 | |
| 84 | cp, out, err = runtime_tools.run('{} create trace'.format(lttng_client), check_return=False) |
| 85 | if outcome == "Missing symbol": |
| 86 | assert(cp.returncode != 0) |
| 87 | assert(utils.file_contains(err, "Missing symbol")) |
| 88 | return |
| 89 | |
| 90 | assert(cp.returncode == 0) |
| 91 | |
| 92 | runtime_tools.run('lttng enable-event -u tp:tptest') |
| 93 | runtime_tools.run('lttng start') |
| 94 | |
| 95 | # Stop tracing |
| 96 | runtime_tools.run('lttng stop') |
| 97 | runtime_tools.run('lttng destroy -a') |
| 98 | cp = runtime_tools.subprocess_terminate(sessiond) |
| 99 | if cp.returncode != 0: |
| 100 | pytest.fail("Sessiond return code") |