From faf5c654855a7a42093e43c4c739bb69dd2375d3 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 7 Jun 2020 18:54:29 -0400 Subject: [PATCH] Fix: tests: conditionally skip Python bindings test that requires Python plugins support As exposed by bug 1272 [1], there are some tests in test_trace_collection_message_iterator.py that depend on Python plugins being enabled. Running the tests with `--enable-python-bindings` and `--disable-python-plugins` therefore leads to these tests failing. Fix it by skipping them if the support for Python plugins is not enabled. [1] https://bugs.lttng.org/issues/1272 Change-Id: I4881a3b0a336b9078715837cb7f8f423bbc2b982 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/3621 Tested-by: jenkins Reviewed-by: Philippe Proulx CI-Build: Michael Jeanson --- configure.ac | 3 +++ .../python/bt2/test_trace_collection_message_iterator.py | 9 +++++++++ tests/plugins/sink.ctf.fs/test-assume-single-trace.sh | 5 +++++ tests/plugins/sink.ctf.fs/test-stream-names.sh | 5 +++++ tests/utils/env.sh.in | 6 ++++++ 5 files changed, 28 insertions(+) diff --git a/configure.ac b/configure.ac index c4162d99..716c9f4d 100644 --- a/configure.ac +++ b/configure.ac @@ -514,6 +514,9 @@ AE_IF_FEATURE_ENABLED([built-in-python-plugin-support], [AC_DEFINE([BT_BUILT_IN_PYTHON_PLUGIN_SUPPORT], [1], [Define to 1 to register plug-in attributes in static executable sections])] ) +AE_IF_FEATURE_ENABLED([python-plugins], [ENABLE_PYTHON_PLUGINS=1], [ENABLE_PYTHON_PLUGINS=0]) +AC_SUBST([ENABLE_PYTHON_PLUGINS]) + AE_IF_FEATURE_ENABLED([debug-info], [ENABLE_DEBUG_INFO_VAL=1], [ENABLE_DEBUG_INFO_VAL=0]) AC_SUBST([ENABLE_DEBUG_INFO_VAL]) diff --git a/tests/bindings/python/bt2/test_trace_collection_message_iterator.py b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py index 84b19cf9..53d838fc 100644 --- a/tests/bindings/python/bt2/test_trace_collection_message_iterator.py +++ b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py @@ -29,6 +29,7 @@ _AUTO_SOURCE_DISCOVERY_PARAMS_LOG_LEVEL_PATH = os.path.join( _METADATA_SYNTAX_ERROR_TRACE_PATH = os.path.join( _BT_CTF_TRACES_PATH, "fail", "metadata-syntax-error" ) +_BT_ENABLE_PYTHON_PLUGINS = os.environ["BT_TESTS_ENABLE_PYTHON_PLUGINS"] == "1" class _SomeSource( @@ -407,6 +408,10 @@ class _TestAutoDiscoverSourceComponentSpecs(unittest.TestCase): os.environ["BABELTRACE_PLUGIN_PATH"] = self._saved_babeltrace_plugin_path +@unittest.skipUnless( + _BT_ENABLE_PYTHON_PLUGINS, + "Support for Python plugins is disabled", +) class TestAutoDiscoverSourceComponentSpecsGrouping( _TestAutoDiscoverSourceComponentSpecs ): @@ -432,6 +437,10 @@ class TestAutoDiscoverSourceComponentSpecsGrouping( self.assertEqual(msgs[7].stream.name, "TestSourceSomeDir: some-dir") +@unittest.skipUnless( + _BT_ENABLE_PYTHON_PLUGINS, + "Support for Python plugins is disabled", +) class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( _TestAutoDiscoverSourceComponentSpecs ): diff --git a/tests/plugins/sink.ctf.fs/test-assume-single-trace.sh b/tests/plugins/sink.ctf.fs/test-assume-single-trace.sh index 69dfb362..37f52707 100755 --- a/tests/plugins/sink.ctf.fs/test-assume-single-trace.sh +++ b/tests/plugins/sink.ctf.fs/test-assume-single-trace.sh @@ -28,6 +28,11 @@ temp_output_dir=$(mktemp -d) trace_dir="$temp_output_dir/the-trace" +if [ "$BT_TESTS_ENABLE_PYTHON_PLUGINS" != "1" ]; then + plan_skip_all "This test requires the Python plugin provider" + exit +fi + plan_tests 7 bt_cli "$temp_stdout" "$temp_stderr" \ diff --git a/tests/plugins/sink.ctf.fs/test-stream-names.sh b/tests/plugins/sink.ctf.fs/test-stream-names.sh index e5993c7d..e6843769 100755 --- a/tests/plugins/sink.ctf.fs/test-stream-names.sh +++ b/tests/plugins/sink.ctf.fs/test-stream-names.sh @@ -30,6 +30,11 @@ temp_stderr=$(mktemp) temp_output_dir=$(mktemp -d) trace_dir="$temp_output_dir/trace" +if [ "$BT_TESTS_ENABLE_PYTHON_PLUGINS" != "1" ]; then + plan_skip_all "This test requires the Python plugin provider" + exit +fi + plan_tests 9 bt_cli "$temp_stdout" "$temp_stderr" \ diff --git a/tests/utils/env.sh.in b/tests/utils/env.sh.in index ab5b47e7..03d4440c 100644 --- a/tests/utils/env.sh.in +++ b/tests/utils/env.sh.in @@ -53,3 +53,9 @@ if [ -z "${BT_TESTS_ENABLE_ASAN:-}" ]; then BT_TESTS_ENABLE_ASAN="@ENABLE_ASAN@" fi export BT_TESTS_ENABLE_ASAN + +# Define to 1 to enable tests that depend on the Python plugins support +if [ -z "${BT_TESTS_ENABLE_PYTHON_PLUGINS:-}" ]; then + BT_TESTS_ENABLE_PYTHON_PLUGINS="@ENABLE_PYTHON_PLUGINS@" +fi +export BT_TESTS_ENABLE_PYTHON_PLUGINS -- 2.34.1