Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1131692iol; Fri, 10 Jun 2022 00:30:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQv0fZoBPq1nRxvHb8q3rTw2ae9gv48/+SebM+sd3GXoXeLYO47rop15W86XD96ojueVrN X-Received: by 2002:a05:6a00:150f:b0:51b:e050:d36e with SMTP id q15-20020a056a00150f00b0051be050d36emr37657409pfu.44.1654846227228; Fri, 10 Jun 2022 00:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654846227; cv=none; d=google.com; s=arc-20160816; b=Z2gQQ9uYqaGkDDd5ST7KR1t4JL9yQ75KjpWa6JuaP1aV4yQdyWWJ5RLrSS2UTUSAmd SlxnCtv0H3TkTqCrBCV8TCLYKFxy3Lw3pf5uo4D7JY8PHXkmOuLtzp+jS1hY/7gV55Iw R8cC/K83qaVvRRwkcTEuHeXqqJ153W+nu0rOMKiPJwSvZv4OM75k8hAoLv8/d5SKebw4 Z2SELPFT1gjjGWUuBSnv8ebNZcpF5mo8AwTC2aG8WLmiWiZRjFG5EvWsPn3FvIN5d+vF XRVBa5xyfpoyeACed3gfo4yBp4VLAL5zwFu1ylK9lcupA+G0YL4UvXbZf34H7W5pTLfs Yddw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=5k5O6BM46qWliWtNEp9U69i4obnOWwff8o5OGpqfmOo=; b=h4D4PMXKm8800gGyxn4oEutAKzVKAr+3b/JW0de6NnnLY/aKXeG0JBHfARQp/h1BJK BSq/9s583aTzI4qiNKxTn3eXg+i+KaByufmcQW+FNTOZu5JmckaQR+A4KsALsmaoQQL6 1fifSVylDwvDz+f/xyB5WCBAm11XM42AEJKNSgcJ9ei0PeQyBPoGa0b8affz8M5LQXW6 gYFZVZU8+uhEXLQtOxSz43u3UJ5h3hvdJcRz/g6pHIAFCxWrkgrXXjTr3/ZwIOO7Jdhb g5WsoVG+rqRqu0xE5lr5OdwHlYUB6yXfgl8snHp4ZU/xn6lBf4AXEAdZyK6wsJCsmPCv QY9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="T4wiv/qk"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i1-20020a170902cf0100b0016793c0e3dcsi13214069plg.545.2022.06.10.00.30.10; Fri, 10 Jun 2022 00:30:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="T4wiv/qk"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346861AbiFJH3I (ORCPT + 99 others); Fri, 10 Jun 2022 03:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346811AbiFJH3G (ORCPT ); Fri, 10 Jun 2022 03:29:06 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD7454026 for ; Fri, 10 Jun 2022 00:29:01 -0700 (PDT) Received: from localhost.localdomain (67.227.121.78.rev.sfr.net [78.121.227.67]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fdanis) by madras.collabora.co.uk (Postfix) with ESMTPSA id E52816601761 for ; Fri, 10 Jun 2022 08:28:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654846140; bh=82IgAWfLFNYPlguWJ7ZoflXqL3Yi81c7nu3MMQTh9QU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=T4wiv/qkIAbSo9jidqS/M+cqhJB99GMlnUMhcXyoe72Qny3bQSogPKGrboju1K8gU Iu4hc8jZ0fhZZyf+EXH+L4hIoZ0fsTHoa+e/nokx5CuZHT69E7TUXj2fmjcVf/xstM 20/WzFjq+T/qfBYbhXsZTaqMJm5OWMeK9rdFrVdlf5K96shNEnyracpdsNZJzHIX4f 44Qco/zb22F8UpGJ4PhJpetMffAKWfM3eR3EOsDRaZcRPZDIuTvLjBXNspfZ7tSVNt fMHFShyg3fTd+JQCzoW3gsp3GvoVutahTbTJvD+dfvWdHWYqgQj7jN7WCKNGB1EgB/ ox5Wv58MPtIcw== From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= 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 Message-Id: <20220610072850.16593-4-frederic.danis@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610072850.16593-1-frederic.danis@collabora.com> References: <20220610072850.16593-1-frederic.danis@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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