Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1312507pxj; Fri, 4 Jun 2021 11:02:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNjx/CktOFCImDNSCH+hhxCbcc1LpaCYC22D3X9SaSZITJ4p/l79cYYv7lPaPSEUDs5wXi X-Received: by 2002:a17:906:f854:: with SMTP id ks20mr5284706ejb.67.1622829739595; Fri, 04 Jun 2021 11:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622829739; cv=none; d=google.com; s=arc-20160816; b=t3I47p+Oo57tyH2TcXDVlqHzNOW9uNiEwq89VmSuMDau/I635yAteneV7zSEVSmPlZ kZJKvhm0btiAYXV21Dn0N9iOdKzHHLJ9K2JpqIu/+6fUwpDIQr8H75MdxWGsuA+LgKL8 ZxNRncuCgFvcYy1BAiVUyLioAv4ipTa45s0K1rpC44NtgJjMG0dWN00RyqVOiaJHSPE6 6zSnE4iGfR1Cp2uEtRY8ZsRFJewWiSmnD2jjvrjbCyBBu5YWprjGl8uKwGaB90wtv9Se 71UUjo/IPBDo+MfJJZsNSniq4pSwuDJHEHpS2kHI/jfVypsAyQSNUsinN0k+XyG/EfVb f1XQ== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=6+2RHY122IPcdRJ+aHc83IAIhiE0wEM/JUkjmzpuow4=; b=l8POR2JhUlhmA36ePeMaz3zGCCSfXjbWWDHi0d8HRSLhJ6W93ewJqMbCbkjiJ9chFX YczjM/bzDGjJbbMRfZeVeh26tmp/Wm4M9Uatg1GOgulWYiBtfIHhiqIFe2+EaWk9BSvu 748HlqbkjsYpkH/V7WYp25thM5j1uM94OMClEMN29+dlCI4qDywyF6mv3/Zc39QsM+Vy wi/2Zoi8iOp0Df0d8nHGA2WJMjZiQoT2BKm3MbUPOKSx7C8oNHKwJQDnqDUDnOLog7OI VSXOC4W628pmGCMpt+hmxjj8fRcsWmABAHH8iVovMJLTQ38M0KEVFhqXNxoJNa8cO42P HUvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si5617942edi.582.2021.06.04.11.01.39; Fri, 04 Jun 2021 11:02:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbhFDSBX (ORCPT + 99 others); Fri, 4 Jun 2021 14:01:23 -0400 Received: from mga04.intel.com ([192.55.52.120]:26404 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbhFDSBX (ORCPT ); Fri, 4 Jun 2021 14:01:23 -0400 IronPort-SDR: GFQb5GoifLJKwh58PlWNmQRa3CzoafnPr4nM3rBwUfC43HT7fVwV8OXclwO+VAikvRUI9VaorP sZHo/Svrt68Q== X-IronPort-AV: E=McAfee;i="6200,9189,10005"; a="202482061" X-IronPort-AV: E=Sophos;i="5.83,248,1616482800"; d="scan'208";a="202482061" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2021 10:59:20 -0700 IronPort-SDR: Qc5xrIB+TaOODrzXHuMI9qy/NoTtd7vlsA0jPT4pixx5PsYost8WdZ8qAnGFVgmMtn/mbII6mj xMIwt9WsAuCw== X-IronPort-AV: E=Sophos;i="5.83,248,1616482800"; d="scan'208";a="401033661" Received: from beomtaek-mobl2.amr.corp.intel.com (HELO istotlan-desk.intel.com) ([10.212.156.80]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2021 10:59:20 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, tedd.an@intel.com, Inga Stotland Subject: [PATCH BlueZ v2] tools/mgmt-tester: Fix expected HCI command accounting Date: Fri, 4 Jun 2021 10:59:13 -0700 Message-Id: <20210604175913.256979-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This fixes test condition count in the expected HCI command callback. When the expected HCI opcode is detected, mark the condition as done. Any subsequent HCI commands are ignored. Without this fix, in couple of test cases where the expected HCI command is detected more than once, the test may be erroneously reported as a failure or prematurely declared as a success before waiting on an expected MGMT event condition. The test cases where this behavior is fixed: Remove Ext Advertising - Success 1 Remove Ext Advertising - Success 2 --- tools/mgmt-tester.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index c5073fe2b..6109883ad 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -52,6 +52,7 @@ struct test_data { uint16_t mgmt_index; struct hciemu *hciemu; enum hciemu_type hciemu_type; + bool expect_hci_command_done; int unmet_conditions; int unmet_setup_conditions; int sk; @@ -7021,9 +7022,11 @@ static void command_hci_callback(uint16_t opcode, const void *param, tester_print("HCI Command 0x%04x length %u", opcode, length); - if (opcode != test->expect_hci_command || data->unmet_conditions <= 0) + if (opcode != test->expect_hci_command || data->expect_hci_command_done) return; + data->expect_hci_command_done = true; + if (test->expect_hci_func) expect_hci_param = test->expect_hci_func(&expect_hci_len); -- 2.26.3