Fix: special modules 2.7 cases for regen metadata
[deliverable/lttng-ivc.git] / lttng_ivc / tests / modules_abi_vs_tools / test_modules_abi_vs_tools.py
index c29206e9481615d728b9679e336ff00ca69d5713..fdc5bd64ad1ba95630c7f5568dd824e5805239e0 100644 (file)
@@ -29,6 +29,7 @@ import lttng_ivc.settings as Settings
 from lttng_ivc.utils.skip import must_be_root
 from lttng_ivc.utils.utils import sessiond_spawn
 from lttng_ivc.utils.utils import line_count
+from lttng_ivc.utils.utils import file_contains
 
 """
 
@@ -88,9 +89,9 @@ test_matrix_base_tracing = [
 
 test_matrix_regen_metadata = [
     ("lttng-modules-2.7", "lttng-tools-2.7",  "metadata regenerate", "Unsupported by tools"),
-    ("lttng-modules-2.7", "lttng-tools-2.8",  "metadata regenerate", "Unsupported by module"),
-    ("lttng-modules-2.7", "lttng-tools-2.9",  "regenerate metadata", "Unsupported by module"),
-    ("lttng-modules-2.7", "lttng-tools-2.10", "regenerate metadata", "Unsupported by module"),
+    ("lttng-modules-2.7", "lttng-tools-2.8",  "metadata regenerate", "Unsupported by modules"),
+    ("lttng-modules-2.7", "lttng-tools-2.9",  "regenerate metadata", "Unsupported by modules"),
+    ("lttng-modules-2.7", "lttng-tools-2.10", "regenerate metadata", "Unsupported by modules"),
     ("lttng-modules-2.8", "lttng-tools-2.7",  "metadata regenerate", "Unsupported by tools"),
     ("lttng-modules-2.8", "lttng-tools-2.8",  "metadata regenerate", "Supported"),
     ("lttng-modules-2.8", "lttng-tools-2.9",  "regenerate metadata", "Supported"),
@@ -108,8 +109,8 @@ test_matrix_regen_metadata = [
 test_matrix_statedump = [
     ("lttng-modules-2.7", "lttng-tools-2.7",  "Unsupported by tools"),
     ("lttng-modules-2.7", "lttng-tools-2.8",  "Unsupported by tools"),
-    ("lttng-modules-2.7", "lttng-tools-2.9",  "Unsupported by module"),
-    ("lttng-modules-2.7", "lttng-tools-2.10", "Unsupported by module"),
+    ("lttng-modules-2.7", "lttng-tools-2.9",  "Unsupported by modules"),
+    ("lttng-modules-2.7", "lttng-tools-2.10", "Unsupported by modules"),
     ("lttng-modules-2.8", "lttng-tools-2.7",  "Unsupported by tools"),
     ("lttng-modules-2.8", "lttng-tools-2.8",  "Unsupported by tools"),
     ("lttng-modules-2.8", "lttng-tools-2.9",  "Unsupported by modules"),
@@ -250,7 +251,7 @@ def test_modules_regen_metadata(tmpdir, modules_label, tools_label, command, sce
 
         # Validate that we have all event base on the current metadata
         cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
-        assert(line_count(cp_out) == nb_events)
+        assert line_count(cp_out) == nb_events
 
         # Empty the metadata file
         open(get_metadata_file_path(trace_path), 'w').close()
@@ -264,13 +265,27 @@ def test_modules_regen_metadata(tmpdir, modules_label, tools_label, command, sce
         # TODO: rework this a bit to differentiate each errors and rework how
         # the condition are meet
         if scenario == "Unsupported by tools" or scenario == "Unsupported by modules":
-            with pytest.raises(subprocess.CalledProcessError):
+            if modules_label == "lttng-modules-2.7" and scenario == "Unsupported by modules":
+                # Error from lttng-modules-2.7 is not reported correctly by
+                # sessiond. But it is reported on the sessiond side.
+                # For now, run the command, validate that the error exist on
+                # sessiond side and mark as xfail.
                 runtime.run("lttng {}".format(command))
+            else:
+                with pytest.raises(subprocess.CalledProcessError):
+                    runtime.run("lttng {}".format(command))
 
             # Make sure everything looks good on this side
+            runtime.run("lttng stop")
+            runtime.run("lttng destroy -a")
+            stderr_path = runtime.get_subprocess_stderr_path(sessiond)
             sessiond = runtime.subprocess_terminate(sessiond)
-            if sessiond.returncode != 0:
-                pytest.fail("Return value of sessiond is not zero")
+            if scenario == "Unsupported by modules":
+                error_msg = "Error: Failed to regenerate the kernel metadata"
+                assert file_contains(stderr_path, [error_msg]), "Error message missing"
+            if modules_label == "lttng-modules-2.7" and scenario == "Unsupported by modules":
+                pytest.xfail("Lttng-tools does not bubble up error from unsupported metadata regeneration")
+
             return
 
         runtime.run("lttng {}".format(command))
@@ -282,7 +297,7 @@ def test_modules_regen_metadata(tmpdir, modules_label, tools_label, command, sce
             pytest.fail("Return value of sessiond is not zero")
 
         cp_process, cp_out, cp_err = runtime.run(babeltrace_cmd)
-        assert(line_count(cp_out) == nb_events)
+        assert line_count(cp_out) == nb_events
 
 
 @must_be_root
This page took 0.025502 seconds and 5 git commands to generate.