]> git.liburcu.org Git - lttng-tools.git/commitdiff
tests: Test ABI diff of liblttng-ctl
authorKienan Stewart <kstewart@efficios.com>
Fri, 17 Jan 2025 21:01:24 +0000 (16:01 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 28 Jan 2025 19:12:26 +0000 (19:12 +0000)
Change-Id: Ic401829c4485773215013bd4233f589f39549372
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
tests/regression/Makefile.am
tests/regression/tools/Makefile.am
tests/regression/tools/lttng-ctl/Makefile.am [new file with mode: 0644]
tests/regression/tools/lttng-ctl/test_liblttng-ctl_abi.py [new file with mode: 0755]

index 59c00fe880c97e4cbf74db4649c000a1957d52a5..40135ce48ad2b6a86a31b5f66b0c74098d3287aa 100644 (file)
@@ -1280,6 +1280,7 @@ AC_CONFIG_FILES([
        tests/regression/tools/health/Makefile
        tests/regression/tools/tracefile-limits/Makefile
        tests/regression/tools/snapshots/Makefile
+       tests/regression/tools/lttng-ctl/Makefile
        tests/regression/tools/live/Makefile
        tests/regression/tools/exclusion/Makefile
        tests/regression/tools/save-load/Makefile
index 86a351d08ca3acadb7a83d0cb8f204b4a1ae1906..c0665c8a11c69623a2b8a510e699159d1d24ac0b 100644 (file)
@@ -71,6 +71,7 @@ SERIAL_TESTS = tools/base-path/test_ust \
 TESTS = tools/live/test_early_inactive_app.py \
        tools/live/test_miss_short_lived_app.py \
        tools/live/test_per_application_leaks.py \
+       tools/lttng-ctl/test_liblttng-ctl_abi.py \
        tools/context/test_ust.py \
        tools/client/test_session_commands.py \
        tools/client/test_event_rule_listing.py \
index ecd4eabd62d5d9c1faab9f5065977f69ca2a5eb4..e88fd67bc5eb2f83ea90790b19eff54333f0f2dd 100644 (file)
@@ -10,6 +10,7 @@ SUBDIRS = base-path \
        filtering \
        health \
        live \
+       lttng-ctl \
        metadata \
        mi \
        notification \
diff --git a/tests/regression/tools/lttng-ctl/Makefile.am b/tests/regression/tools/lttng-ctl/Makefile.am
new file mode 100644 (file)
index 0000000..a6dae04
--- /dev/null
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# SPDX-FileCopyrightText: 2025 Kienan Stewart <kstewart@efficios.com>
+
+noinst_SCRIPTS = test_liblttng-ctl_abi.py
+EXTRA_DIST = test_liblttng-ctl_abi.py
+
+all-local:
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for script in $(EXTRA_DIST); do \
+                       cp -f $(srcdir)/$$script $(builddir); \
+               done; \
+       fi
+
+clean-local:
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for script in $(EXTRA_DIST); do \
+                       rm -f $(builddir)/$$script; \
+               done; \
+       fi
diff --git a/tests/regression/tools/lttng-ctl/test_liblttng-ctl_abi.py b/tests/regression/tools/lttng-ctl/test_liblttng-ctl_abi.py
new file mode 100755 (executable)
index 0000000..4680b10
--- /dev/null
@@ -0,0 +1,106 @@
+#!/usr/bin/env python3
+#
+# SPDX-FileCopyrightText: 2025 Kienan Stewart <kstewart@efficios.com>
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+"""
+Generate a representation of the ABI for the built liblttng-ctl library, and
+diff against the stored copy, if any.
+"""
+
+import os
+import pathlib
+import shutil
+import subprocess
+import sys
+import tempfile
+
+test_utils_import_path = pathlib.Path(__file__).absolute().parents[3] / "utils"
+sys.path.append(str(test_utils_import_path))
+
+import lttngtest
+
+
+def test_abi_diff(tap, test_env):
+    if not shutil.which("abidw") or not shutil.which("abidiff"):
+        tap.skip("abidw and abidiff are not available")
+        return
+
+    lttngctl_path = (
+        pathlib.Path(test_env._project_root) / "src/lib/lttng-ctl/.libs/liblttng-ctl.so"
+    )
+    lttngctl_version = os.readlink(str(lttngctl_path)).split(".", 2)[-1]
+    tap.diagnostic("Discovered liblttng-ctl version '{}'".format(lttngctl_version))
+
+    abi_path = pathlib.Path(
+        test_env._project_root
+    ) / "src/lib/lttng-ctl/abi_ref/{}/abi.xml".format(lttngctl_version)
+
+    headers_dir = pathlib.Path(test_env._project_root) / "include"
+
+    if not lttngctl_path.exists():
+        tap.skip("'{}' does not exist".format(str(lttngctl_path)))
+        return
+
+    if not abi_path.exists():
+        tap.skip("'{}' does not exist".format(str(abi_path)))
+        return
+
+    abi_tmp = tempfile.NamedTemporaryFile()
+    abidw_command = [
+        "abidw",
+        "--drop-undefined-syms",
+        "--drop-private-types",
+        "--headers-dir",
+        str(headers_dir),
+        str(lttngctl_path),
+    ]
+
+    tap.diagnostic("Generation command: `{}`".format(" ".join(abidw_command)))
+    abidw = subprocess.Popen(
+        abidw_command,
+        stdout=abi_tmp.file,
+        stderr=subprocess.PIPE,
+    )
+    abidw.wait()
+    if abidw.returncode != 0:
+        tap.diagnostic(abidw.stderr.read().decode("utf-8"))
+        tap.fail(
+            "Failed to produce XML representation of current ABI, returncode '{}'".format(
+                abidw.returncode
+            )
+        )
+        return
+
+    abidiff_command = ["abidiff", str(abi_path), str(abi_tmp.name)]
+    tap.diagnostic("Diff command: `{}`".format(" ".join(abidiff_command)))
+    abidiff = subprocess.Popen(
+        abidiff_command,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.STDOUT,
+    )
+    abidiff.wait()
+
+    message = "No ABI changes detected"
+    success = True
+    if abidiff.returncode & 8 == 8:
+        success = False
+        message = "Breaking ABI changes detected"
+    elif abidiff.returncode & 4 == 4:
+        message = "ABI changes changes detected"
+    elif abidiff.returncode != 0:
+        success = False
+        message = "Error running abidiff, return code '{}'".format(abidiff.returncode)
+
+    tap.diagnostic("ABI diff output:\n{}".format(abidiff.stdout.read().decode("utf-8")))
+    tap.test(success, message)
+
+
+tap = lttngtest.TapGenerator(1)
+with lttngtest.test_environment(
+    log=tap.diagnostic, with_relayd=False, with_sessiond=False
+) as test_env:
+    test_abi_diff(tap, test_env)
+
+sys.exit(0 if tap.is_successful else 1)
This page took 0.032023 seconds and 4 git commands to generate.