From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 3/3] test-runner: Add udevd and trigger events
Date: Fri, 10 Jun 2022 09:28:50 +0200 [thread overview]
Message-ID: <20220610072850.16593-4-frederic.danis@collabora.com> (raw)
In-Reply-To: <20220610072850.16593-1-frederic.danis@collabora.com>
Kernel events should have been managed so the audio card is accessible
from PipeWire
---
tools/test-runner.c | 83 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 80 insertions(+), 3 deletions(-)
diff --git a/tools/test-runner.c b/tools/test-runner.c
index bbbca5b5d..e79e3b6e9 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -251,13 +251,14 @@ static void start_qemu(void)
"rootfstype=9p "
"rootflags=trans=virtio,version=9p2000.L "
"acpi=off pci=noacpi noapic quiet ro init=%s "
- "bluetooth.enable_ecred=1"
+ "bluetooth.enable_ecred=1 "
"TESTHOME=%s TESTDBUS=%u TESTDAEMON=%u "
"TESTDBUSSESSION=%u XDG_RUNTIME_DIR=/run/user/0 "
+ "AUDIO_SUPPORT=%u "
"TESTMONITOR=%u TESTEMULATOR=%u TESTDEVS=%d "
"TESTAUTO=%u TESTARGS=\'%s\'",
initcmd, cwd, start_dbus, start_daemon,
- start_dbus_session,
+ start_dbus_session, audio_support,
start_monitor, start_emulator, num_devs,
run_auto, testargs);
@@ -724,13 +725,70 @@ static pid_t start_btvirt(const char *home)
return pid;
}
+static void trigger_udev(void)
+{
+ char *argv[3], *envp[1];
+ pid_t pid;
+
+ argv[0] = "/bin/udevadm";
+ argv[1] = "trigger";
+ argv[2] = NULL;
+
+ envp[0] = NULL;
+
+ printf("Triggering udev events\n");
+
+ pid = fork();
+ if (pid < 0) {
+ perror("Failed to fork new process");
+ return;
+ }
+
+ if (pid == 0) {
+ execve(argv[0], argv, envp);
+ exit(EXIT_SUCCESS);
+ }
+
+ printf("udev trigger process %d created\n", pid);
+}
+
+static pid_t start_udevd(void)
+{
+ char *argv[2], *envp[1];
+ pid_t pid;
+
+ argv[0] = "/lib/systemd/systemd-udevd";
+ argv[1] = NULL;
+
+ envp[0] = NULL;
+
+ printf("Starting udevd daemon\n");
+
+ pid = fork();
+ if (pid < 0) {
+ perror("Failed to fork new process");
+ return -1;
+ }
+
+ if (pid == 0) {
+ execve(argv[0], argv, envp);
+ exit(EXIT_SUCCESS);
+ }
+
+ printf("udevd daemon process %d created\n", pid);
+
+ trigger_udev();
+
+ return pid;
+}
+
static void run_command(char *cmdname, char *home)
{
char *argv[9], *envp[3];
int pos = 0, idx = 0;
int serial_fd;
pid_t pid, dbus_pid, daemon_pid, monitor_pid, emulator_pid,
- dbus_session_pid;
+ dbus_session_pid, udevd_pid;
if (num_devs) {
const char *node = "/dev/ttyS1";
@@ -746,6 +804,11 @@ static void run_command(char *cmdname, char *home)
} else
serial_fd = -1;
+ if (audio_support)
+ udevd_pid = start_udevd();
+ else
+ udevd_pid = -1;
+
if (start_dbus) {
create_dbus_system_conf();
dbus_pid = start_dbus_daemon(false);
@@ -874,6 +937,11 @@ start_next:
monitor_pid = -1;
}
+ if (corpse == udevd_pid) {
+ printf("udevd terminated\n");
+ udevd_pid = -1;
+ }
+
if (corpse == pid)
break;
}
@@ -898,6 +966,9 @@ start_next:
if (monitor_pid > 0)
kill(monitor_pid, SIGTERM);
+ if (udevd_pid > 0)
+ kill(udevd_pid, SIGTERM);
+
if (serial_fd >= 0) {
close(serial_fd);
serial_fd = -1;
@@ -980,6 +1051,12 @@ static void run_tests(void)
start_emulator = true;
}
+ ptr = strstr(cmdline, "AUDIO_SUPPORT=1");
+ if (ptr) {
+ printf("Audio support requested\n");
+ audio_support = true;
+ }
+
ptr = strstr(cmdline, "TESTHOME=");
if (ptr) {
home = ptr + 4;
--
2.25.1
next prev parent reply other threads:[~2022-06-10 7:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 7:28 [PATCH BlueZ v2 0/3] test-runner: Add support for audio daemons Frédéric Danis
2022-06-10 7:28 ` [PATCH BlueZ v2 1/3] test-runner: Add DBus session support Frédéric Danis
2022-06-10 9:51 ` test-runner: Add support for audio daemons bluez.test.bot
2022-06-10 7:28 ` [PATCH BlueZ v2 2/3] test-runner: Add audio card support Frédéric Danis
2022-06-10 15:48 ` Luiz Augusto von Dentz
2022-06-10 7:28 ` Frédéric Danis [this message]
2022-06-10 15:50 ` [PATCH BlueZ v2 3/3] test-runner: Add udevd and trigger events Luiz Augusto von Dentz
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=20220610072850.16593-4-frederic.danis@collabora.com \
--to=frederic.danis@collabora.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.