Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1509085rwl; Fri, 24 Mar 2023 11:25:21 -0700 (PDT) X-Google-Smtp-Source: AKy350aXZ8lHmC7gYfTRjcIbZw8Fxhy+YzgoDgSdcsoavejWhNdiuVngdeCx8A4zCjHELqBbHUNs X-Received: by 2002:aa7:dc1a:0:b0:4fc:eb46:6b69 with SMTP id b26-20020aa7dc1a000000b004fceb466b69mr3900332edu.23.1679682321681; Fri, 24 Mar 2023 11:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679682321; cv=none; d=google.com; s=arc-20160816; b=FCf6mCVd0p2lwI9QDfZN6+FpYE17aWCHNTKyDBZ9Ufi38rUY3W+lEDhUaoFRyFtJkD OHTLxiOMv9ilOdmz4ePKrBF5IByvYMtFskdVsgiHo89UHlcnMKR+MzCERO1oM8fldntL 83lRiMCSyurXNus3VjdxfvViTdjdAdedX6wH3HloO09zp/bMuQxQbgD4P4HM5KK9SOPy GZm8Wb7rRgiWgpduMPmS5ylX+QxdDfcjBJfK7gyIhmIrsduhUtDO45FHhbaKyTpihS9W qT5JgVysACcW+R/ACTVKkF05km5VAXYc2h9BUTmXVhHerhwnokKLjp6ES6m659Lx7zbv dgXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=aSW5lVN/XdDnqsYnEdlvJ79vqtFaMV3jR95gfz5aEeg=; b=yKwnUpo7ywsQz/vwrKTnOOIqpWfFWasa8Yu8thWsxAsUNqC4nXv+9w5jki85Fn0zio FJqTpdbAB1wYtDT1QpqyqmrVCgj9+T3NJRvS3p/iKk6G6TlnZnGyqKp/kkDuSRURjeYD iuh7X5qYP0ZnqLAeh7LPcJxSbsszEERz2Id24UDWhRQbE0dSMJMEPi5ZoupTvaqgXRyk tYkmfXCkXICuUMG5fVPJtL+UAUvV2RbEekUrpHLZm0I639WCmGWsAAVXAEgvdksWlxq1 9DLQRT6/u0FLqR9Gx1jCGqpY5hGEcSl22ZsurdYLLOVaQtQJNmtczXINH+TspEp6MFdl Pb0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Dy3NhjDi; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x19-20020aa7d6d3000000b004abf4239d3esi20788204edr.254.2023.03.24.11.24.57; Fri, 24 Mar 2023 11:25:21 -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=@google.com header.s=20210112 header.b=Dy3NhjDi; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231656AbjCXSSe (ORCPT + 99 others); Fri, 24 Mar 2023 14:18:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231966AbjCXSSa (ORCPT ); Fri, 24 Mar 2023 14:18:30 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A01D18B17 for ; Fri, 24 Mar 2023 11:18:21 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id y32-20020a634960000000b0050fa03fa554so983711pgk.1 for ; Fri, 24 Mar 2023 11:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679681901; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=aSW5lVN/XdDnqsYnEdlvJ79vqtFaMV3jR95gfz5aEeg=; b=Dy3NhjDiXi4oiBF4Tnsprf/JOEIbUmTgkSnrcpUHd0skU6GPYbKoD5p5d61/8P+ytH PVS19xEOlnpdhjb6mhBLyvgn5Mqd7dqoN3NAqfYcUk142ez2T1s8hoOZulhAQ5Igehbj omKpZVKsrqM+lxRRBUgoHZE7sMYUmuNA7NdYOwsdsnfw57tu1dTZsB1DjJAxMnPc1jup IDTPPQJcU0u4QylXwCkvYkhLWyaBkD1Tzt3rxlMHSokGcLwII5w8Sv/X/2YraS21OyDm 2FFPQgv/QzPTopPYKdXu+ZFaqpvs1vn+g+ZYpIq2dh85qVq9rV4arYoyVAcB/cLp0zfs 0bYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679681901; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aSW5lVN/XdDnqsYnEdlvJ79vqtFaMV3jR95gfz5aEeg=; b=Bb12yLn8sTZyr8u18DJNj306UzfhdQqnDoO9M+8wDYNcBrtfVcfOQR/r9RLYFbBOWF GX/nzBNxabSCEjjFa+zh6WLxWPYfNp+cmOEGJrvfCoFc6+md/jcwsW3wowWcYP9XnhuF 6aZcbFt/e9DLm1wmX3wbEgq/bwQIPA0spqjZ4Rc6kkc5e3Ueog2yFhLdHdT9rCyqbFeN kO7R66/i8PfIMlVKqybLY97ECc3N87TYT5uxJ9k3M9VS5h6waXOXZfXVKTiJkNaIkR5n 2EkzhtObnSW1t0VFcznFzBLwTC7B7lSC7EXkolbDhl5dEd0X2Y2qS6vfOCutwRWHUNtj GDOA== X-Gm-Message-State: AAQBX9c2yQejvxxuckq/mIT3Uv3Pfrc5fiwSfM+J+/8uNKoUql7h//BW Z1FglXdemo7UDXo+/W+XgHeDpq3kBiN7jQ== X-Received: from mmandlik-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:2893]) (user=mmandlik job=sendgmr) by 2002:a17:90a:c095:b0:234:acfd:c8da with SMTP id o21-20020a17090ac09500b00234acfdc8damr1138137pjs.2.1679681900832; Fri, 24 Mar 2023 11:18:20 -0700 (PDT) Date: Fri, 24 Mar 2023 11:18:16 -0700 In-Reply-To: <20230324111613.BlueZ.v4.1.I21ac5a143b0e42eef4ff71ef04ef0e53a294932a@changeid> Mime-Version: 1.0 References: <20230324111613.BlueZ.v4.1.I21ac5a143b0e42eef4ff71ef04ef0e53a294932a@changeid> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230324111613.BlueZ.v4.2.I6b8d9794fa661c63824306ccc8eecf6479040b1a@changeid> Subject: [BlueZ PATCH v4 2/2] mgmt-tester: Add devcoredump test From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Manish Mandlik Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 Add mgmt-tester test for hci devcoredump. This test triggers the devcoredump with a test data and verifies the generated devcoredump file for the test data and correct devcoredump header fields. --- Changes in v4: - New patch in the series tools/mgmt-tester.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index a56c38173..838ae5d2b 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -12511,6 +12511,77 @@ static void test_suspend_resume_success_10(const void *test_data) tester_wait(2, trigger_force_resume, NULL); } +#define MAX_COREDUMP_BUF_LEN 512 +#define MAX_COREDUMP_LINE_LEN 40 + +static void test_hci_devcd(const void *test_data) +{ + struct test_data *data = tester_get_data(); + struct vhci *vhci = hciemu_get_vhci(data->hciemu); + char buf[MAX_COREDUMP_BUF_LEN] = {0}; + char delim[] = "\n"; + char *line; + char *saveptr; + unsigned int i = 0; + + char dump_data[] = "test data"; + char expected[][MAX_COREDUMP_LINE_LEN] = { + "Bluetooth devcoredump", + "State: 2", + "Controller Name: vhci_ctrl", + "Firmware Version: vhci_fw", + "Driver: vhci_drv", + "Vendor: vhci", + "--- Start dump ---", + }; + + /* Triggers the devcoredump */ + if (vhci_force_devcd(vhci, dump_data, sizeof(dump_data))) { + tester_warn("Unable to set force_devcoredump"); + tester_test_failed(); + return; + } + + /* Read the generated devcoredump file */ + if (vhci_read_devcd(vhci, buf, sizeof(buf)) <= 0) { + tester_warn("Unable to read devcoredump"); + tester_test_failed(); + return; + } + + /* Verify if all devcoredump header fields are present */ + line = strtok_r(buf, delim, &saveptr); + while (i < ARRAY_SIZE(expected)) { + if (!line || strcmp(line, expected[i])) { + tester_warn("Incorrect coredump data: %s (expected %s)", + line, expected[i]); + tester_test_failed(); + return; + } + + if (!strcmp(line, "State: 2")) { + /* After updating the devcoredump state, the HCI + * devcoredump API adds a `\0` at the end. Skip it + * before reading the next line. + */ + saveptr++; + } + + line = strtok_r(NULL, delim, &saveptr); + i++; + } + + /* Verify the devcoredump data */ + if (!line || strcmp(line, dump_data)) { + tester_warn("Incorrect coredump data: %s (expected %s)", line, + dump_data); + tester_test_failed(); + return; + } + + tester_test_passed(); +} + int main(int argc, char *argv[]) { tester_init(&argc, &argv); @@ -14651,5 +14722,12 @@ int main(int argc, char *argv[]) setup_ll_privacy_add_device, test_command_generic); + /* HCI devcoredump + * Setup : Power on + * Run: Trigger devcoredump via force_devcoredump + * Expect: Devcoredump is generated with correct data + */ + test_bredrle("HCI devcoredump", NULL, NULL, test_hci_devcd); + return tester_run(); } -- 2.40.0.348.gf938b09366-goog