From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 2/2] test-runner: Share build directory writable on coverage builds
Date: Mon, 28 Sep 2026 16:47:31 -0400 [thread overview]
Message-ID: <20260928204732.1265535-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20260928204732.1265535-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The root filesystem is shared read-only with the guest so gcov is not
able to write the .gcda files of binaries run by test-runner, e.g. by
the functional tests. Share the build directory writable over 9p and
mount it over the read-only one when coverage is enabled.
Assisted-by: Claude:claude-opus-5.5
---
Makefile.tools | 3 +++
tools/test-runner.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/Makefile.tools b/Makefile.tools
index 671b40fb0e42..658f92d7b9db 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -325,6 +325,9 @@ tools_btgatt_server_LDADD = src/libshared-mainloop.la \
lib/libbluetooth-internal.la
tools_test_runner_CFLAGS = $(WARNING_CFLAGS)
+if COVERAGE
+tools_test_runner_CFLAGS += -DHAVE_COVERAGE
+endif
tools_test_runner_LDFLAGS =
tools_rctest_LDADD = lib/libbluetooth-internal.la
diff --git a/tools/test-runner.c b/tools/test-runner.c
index 338e5b9da544..674ce072d959 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -577,6 +577,46 @@ static void terminate_signal(int sig)
terminate = 1;
}
+#define COVERAGE_TAG "bluez-coverage"
+
+static bool coverage_enabled(void)
+{
+#ifdef HAVE_COVERAGE
+ return true;
+#else
+ return false;
+#endif
+}
+
+/* The root filesystem is shared read-only, so gcov would be unable to write
+ * the .gcda files of the binaries run inside the guest. Share the build
+ * directory writable so it can be mounted over the read-only one.
+ */
+static void coverage_setup(struct strv *argv, const char *dir)
+{
+ if (!coverage_enabled())
+ return;
+
+ strv_append(argv, "-fsdev");
+ strv_append(argv, "local,id=fsdev-coverage,path=%s,readonly=off,"
+ "security_model=none,multidevs=remap", dir);
+ strv_append(argv, "-device");
+ strv_append(argv, "virtio-9p-pci,fsdev=fsdev-coverage,"
+ "mount_tag=" COVERAGE_TAG);
+}
+
+static void coverage_mount(const char *dir)
+{
+ if (!coverage_enabled())
+ return;
+
+ printf("Mounting %s writable for coverage\n", dir);
+
+ if (mount(COVERAGE_TAG, dir, "9p", 0,
+ "trans=virtio,version=9p2000.L") < 0)
+ perror("Failed to mount coverage directory");
+}
+
static bool rootfs_setup(struct rootfs *r, struct strv *argv)
{
const char *mem = "256M";
@@ -826,6 +866,8 @@ static int start_qemu(void)
strv_append(&argv, "-append");
strv_append(&argv, "%s", cmdline);
+ coverage_setup(&argv, cwd);
+
for (i = 0; i < num_devs; i++) {
strv_append(&argv, "-chardev");
strv_append(&argv, "socket,path=%s,id=bt%d", device_path, i);
@@ -1456,6 +1498,9 @@ static void run_command(char *cmdname, char *home)
return;
}
+ /* home is "HOME=<dir>" */
+ coverage_mount(home + 5);
+
if (num_devs) {
const char *node = "/dev/hvc1";
unsigned int basic_flags, extra_flags;
--
2.55.0
next prev parent reply other threads:[~2026-09-28 20:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 20:47 [PATCH BlueZ v1 1/2] build: Fix coverage target failing with stale .gcda files Luiz Augusto von Dentz
2026-09-28 20:47 ` Luiz Augusto von Dentz [this message]
2026-09-28 22:37 ` [BlueZ,v1,1/2] " bluez.test.bot
2026-09-29 15:20 ` [PATCH BlueZ v1 1/2] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260928204732.1265535-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.