From: Jonathan Rajotte Date: Wed, 22 Nov 2017 19:11:08 +0000 (-0500) Subject: Introduce ust_app_tools_update tests X-Git-Url: http://git.efficios.com/?p=deliverable%2Flttng-ivc.git;a=commitdiff_plain;h=7a8653b4485695713e009bd5a76cff587e5587b0 Introduce ust_app_tools_update tests This provide a basic testing scenario where an app build against lttng-ust 2.x is run inside a runtime for version 2.(x+1) or 2.(x-1) in cases where we expect known features. Signed-off-by: Jonathan Rajotte --- diff --git a/lttng_ivc/tests/ust_app_tools_update/__init__.py b/lttng_ivc/tests/ust_app_tools_update/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lttng_ivc/tests/ust_app_tools_update/test_ust_app_vs_ust_tools.py b/lttng_ivc/tests/ust_app_tools_update/test_ust_app_vs_ust_tools.py new file mode 100644 index 0000000..da078b8 --- /dev/null +++ b/lttng_ivc/tests/ust_app_tools_update/test_ust_app_vs_ust_tools.py @@ -0,0 +1,115 @@ +import pytest +import os +import shutil +import signal +import subprocess + +import lttng_ivc.utils.ProjectFactory as ProjectFactory +import lttng_ivc.utils.utils as utils +import lttng_ivc.utils.runtime as Run +import lttng_ivc.settings as Settings + +""" + +FC: Fully Compatible +BC: Feature of the smallest version number will works. +TU: Tracing unavailable + +""" + +""" +First tuple member: lttng-ust label +Second tuple member: lttng-tool label +Third tuple member: expected scenario +""" + +event_registration_error = "Error: UST app recv reg unsupported version" + +test_matrix_base_app_tracing_available = [ + ("lttng-ust-2.7", "lttng-tools-2.7", True), + ("lttng-ust-2.7", "lttng-tools-2.8", True), + ("lttng-ust-2.7", "lttng-tools-2.9", True), + ("lttng-ust-2.7", "lttng-tools-2.10", True), + ("lttng-ust-2.8", "lttng-tools-2.7", True), + ("lttng-ust-2.8", "lttng-tools-2.8", True), + ("lttng-ust-2.8", "lttng-tools-2.9", True), + ("lttng-ust-2.8", "lttng-tools-2.10", True), + ("lttng-ust-2.9", "lttng-tools-2.7", True), + ("lttng-ust-2.9", "lttng-tools-2.8", True), + ("lttng-ust-2.9", "lttng-tools-2.9", True), + ("lttng-ust-2.9", "lttng-tools-2.10", True), + ("lttng-ust-2.10", "lttng-tools-2.7", True), + ("lttng-ust-2.10", "lttng-tools-2.8", True), + ("lttng-ust-2.10", "lttng-tools-2.9", True), + ("lttng-ust-2.10", "lttng-tools-2.10", True), +] + +runtime_matrix_base_app_tracing_available = [] + +if not Settings.test_only: + runtime_matrix_base_app_tracing_available = test_matrix_base_app_tracing_available +else: + for tup in test_matrix_base_app_tracing_available: + if (tup[0] in Settings.test_only or tup[1] in + Settings.test_only): + runtime_matrix_base_app_tracing_available.append(tup) + + +@pytest.mark.parametrize("ust_label,tools_label,success", runtime_matrix_base_app_tracing_available) +def test_ust_app_tools_update_tracing_available(tmpdir, ust_label, tools_label, success): + + nb_events = 100 + + # Prepare environment + ust = ProjectFactory.get_precook(ust_label) + tools = ProjectFactory.get_precook(tools_label) + babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace) + + tools_runtime_path = os.path.join(str(tmpdir), "tools") + ust_runtime_path = os.path.join(str(tmpdir), "ust") + app_path = os.path.join(str(tmpdir), "app") + + with Run.get_runtime(ust_runtime_path) as runtime_app, Run.get_runtime(tools_runtime_path) as runtime_tools: + runtime_tools.add_project(tools) + runtime_tools.add_project(babeltrace) + + runtime_app.add_project(ust) + runtime_app.lttng_home = runtime_tools.lttng_home + + trace_path = os.path.join(runtime_tools.lttng_home, 'trace') + + # Make application using the ust runtime + shutil.copytree(Settings.apps_gen_events_folder, app_path) + runtime_app.run("make V=1", cwd=app_path) + + # Start lttng-sessiond + sessiond = utils.sessiond_spawn(runtime_tools) + + # Create session using mi to get path and session name + runtime_tools.run('lttng create trace --output={}'.format(trace_path)) + + runtime_tools.run('lttng enable-event -u tp:tptest') + runtime_tools.run('lttng start') + + # Run application + cmd = './app {}'.format(nb_events) + runtime_tools.run(cmd, cwd=app_path) + + runtime_tools.run("lddtree ./app", cwd=app_path) + runtime_app.run("lddtree ./app", cwd=app_path) + + # Stop tracing + runtime_tools.run('lttng stop') + runtime_tools.run('lttng destroy -a') + cp = runtime_tools.subprocess_terminate(sessiond) + if cp.returncode != 0: + pytest.fail("Sessiond return code") + + + cmd = 'babeltrace {}'.format(trace_path) + if success : + cp_process, cp_out, cp_err = runtime_tools.run(cmd) + assert(utils.line_count(cp_out) == nb_events) + else: + with pytest.raises(subprocess.CalledProcessError): + cp_process, cp_out, cp_err = runtime_tools.run(cmd)