Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4953069pxj; Tue, 25 May 2021 22:17:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyicvdW/0VUZs1iwmhhRo9ASi6EbS0OVdurJ7i0+CYuei7F9GnEZqA9r2x4Lvw8u6SF+4Z/ X-Received: by 2002:a6b:6b11:: with SMTP id g17mr22798563ioc.72.1622006239398; Tue, 25 May 2021 22:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622006239; cv=none; d=google.com; s=arc-20160816; b=dKiV/wSg99bcQBUXR+j6+UONkJvc3on5GxnShZmv6HhxxV+E4VK2BOdKbM6J0GlSmb PC16rxTxZJiH4QJStwmE3NbCKTR15ZE4Um52YTEx2dgsN7k7r1AjrE7Hb9u+vbOTfz7Z ARTBK44sY7Z7fns4oMHNwYMMEsggnpU9egQNMwnT8F1Y1qzVBubraoJy4sa7Fz2redmP 3B1mA8bUKhPS52avimybfA2bAAvmNsaEHAtckxWFE/CXAZe+TfarAueTRORXXKJNTsWb sHXCeIRx6QIsiNAOnzlyO89fwLWy8CT+w0649LyD9sLPtwrH9gnIKRqkMPGeBVLiLwnR J/9w== 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=V9FyyF9jdSeK5S3rBQkL/uwGCuTX2AyYnA3Dlag4pLU=; b=kwJtCFnbkWlfx8zvYKkXaDMFeWJTzzA0gM4tbhrephFkI2zRLzM/uQrazN4e46TyK8 KVVveVmK/YltYVAW95Ulox3YnDYPQgMawDR6k+Fw9iWbmHhGN3SNeKkalEP/ToWnomyI rJ4rIC724NePFL+Hgz8fPzCathZgvGPMW0EB9sDnJClXrM3RPSLXKaiH1m4Vi/CxJb+Z DV6HgBr7k5YsD0Z7zKUz5sgTxaPZ+olloiz7Ijoq4nq0gwL2Xo3mQRDIRfHpGOKzCd7N R0Ddu1DhO3SA0fAuVHKM3MnEoo1024n/ViTUv/AoeLJ6xkNxovB6XubxzKi/+wIq3ubf 32Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UugGpP2o; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si5339059ilu.55.2021.05.25.22.17.05; Tue, 25 May 2021 22:17: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UugGpP2o; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbhEZFPB (ORCPT + 99 others); Wed, 26 May 2021 01:15:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230366AbhEZFOq (ORCPT ); Wed, 26 May 2021 01:14:46 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5C8DC061574 for ; Tue, 25 May 2021 22:13:15 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id y202so77262pfc.6 for ; Tue, 25 May 2021 22:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=V9FyyF9jdSeK5S3rBQkL/uwGCuTX2AyYnA3Dlag4pLU=; b=UugGpP2oZDST6ydnEIlcE+mtcrln3MaHc9maNyssOuoAcGdbFa9tSt71nJhPImzx/V pRloNgvV854VrJkf055zkFJzUq7CTXqvFC5jKqjuF1wzpbf830oykh+q7w5p66V40WCR TGWuRhyt4fW3EgDHeOtqTuAtgfsHo+t75CSWBSEE22BDLhm1fSeETZQ/OBP2oLeeKHv7 097CdUf2RM/+nLnNynCTgscbAee4xLkH1G/EzIutTNEK7K71cwP72VapmUg4GKiPU43M 7pDQAMCtdwR7fj0r5J0RnAFou1H/zyAhxrwVKZevNCNvhWxMULxApHIw42pffw4XKEaf auwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V9FyyF9jdSeK5S3rBQkL/uwGCuTX2AyYnA3Dlag4pLU=; b=Nbilu5iccasGL4QQ3HXMoH7pGR5A+ugWIiZTxSYZmE2n7ZvLTUqkVK8k2M+9rE9wD7 3y0tBXND9sWL3g10cuYKuO8j8Za34cz6xVaws+T/8vSf0YlgsQOfISe/lNw5QBm5Dtng CglaevJd5wTGub0gkJeDC+AXLEx4XZMcanFdzWWqxyvLLDB0YwtD5Mh31s7LGA5j18II HrQaS5Myw2yA6VAqNbve4mHKwfS1gl61BulTQiaYIxTrzRIja1rblpoVvVWLmFQ+Bnkt uTV4cYDpiBB+bccghq8SYs+l00q1T6Ew4zqF4OmNA+0NzaMSEBZqE25prjJjrELroneT xX1w== X-Gm-Message-State: AOAM531vbBDPyFdgWWDU/8RU/dohXcaXGUadOw5dm7UanW8RCEnF7NsN RkGCL49QslBGwnzMFZXmRmuq2fpEgypMRQ== X-Received: by 2002:a65:68d4:: with SMTP id k20mr11376463pgt.442.1622005995223; Tue, 25 May 2021 22:13:15 -0700 (PDT) Received: from han1-mobl3.intel.com ([2601:1c0:6a01:d830::e853]) by smtp.gmail.com with ESMTPSA id h8sm13865944pfv.60.2021.05.25.22.13.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 22:13:14 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [PATCH V2 4/4] tools/mgmt-tester: Add test cases for get/set device flags Date: Tue, 25 May 2021 22:13:10 -0700 Message-Id: <20210526051310.423630-4-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210526051310.423630-1-hj.tedd.an@gmail.com> References: <20210526051310.423630-1-hj.tedd.an@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An This patch adds test cases for get/set device flags commands. --- tools/mgmt-tester.c | 182 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index 767e010a6..4550d6e9c 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -8990,6 +8990,140 @@ static void setup_phy_configuration(const void *test_data) NULL, NULL); } +static const uint8_t get_dev_flags_param[] = { + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x00, /* Type */ +}; + +static const uint8_t get_dev_flags_rsp_param[] = { + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x00, /* Type */ + 0x01, 0x00, 0x00, 0x00, /* Supported Flages */ + 0x00, 0x00, 0x00, 0x00, /* Current Flages */ +}; + +static const struct generic_data get_dev_flags_success = { + .send_opcode = MGMT_OP_GET_DEVICE_FLAGS, + .send_param = get_dev_flags_param, + .send_len = sizeof(get_dev_flags_param), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_param = get_dev_flags_rsp_param, + .expect_len = sizeof(get_dev_flags_rsp_param), +}; + +static const uint8_t get_dev_flags_param_fail_1[] = { + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ +}; + +static const struct generic_data get_dev_flags_fail_1 = { + .send_opcode = MGMT_OP_GET_DEVICE_FLAGS, + .send_param = get_dev_flags_param_fail_1, + .send_len = sizeof(get_dev_flags_param_fail_1), + .expect_status = MGMT_STATUS_INVALID_PARAMS, +}; + +static void setup_get_dev_flags(const void *test_data) +{ + struct test_data *data = tester_get_data(); + unsigned char param[] = { 0x01 }; + const unsigned char *add_param; + size_t add_param_len; + + tester_print("Powering on controller (with added device)"); + + if (data->hciemu_type == HCIEMU_TYPE_LE) { + add_param = add_device_success_param_2; + add_param_len = sizeof(add_device_success_param_2); + } else { + add_param = add_device_success_param_1; + add_param_len = sizeof(add_device_success_param_1); + } + + mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index, + add_param_len, add_param, NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index, + sizeof(param), param, + setup_powered_callback, NULL, NULL); +} + +static const uint8_t set_dev_flags_param[] = { + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x00, /* Type */ + 0x01, 0x00, 0x00, 0x00, /* Current Flages */ +}; + +static const uint8_t set_dev_flags_rsp_param[] = { + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x00, /* Type */ +}; + +static const uint8_t dev_flags_changed_param[] = { + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x00, /* Type */ + 0x01, 0x00, 0x00, 0x00, /* Supported Flages */ + 0x01, 0x00, 0x00, 0x00, /* Current Flages */ +}; + +static const struct generic_data set_dev_flags_success = { + .send_opcode = MGMT_OP_SET_DEVICE_FLAGS, + .send_param = set_dev_flags_param, + .send_len = sizeof(set_dev_flags_param), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_param = set_dev_flags_rsp_param, + .expect_len = sizeof(set_dev_flags_rsp_param), + .expect_alt_ev = MGMT_EV_DEVICE_FLAGS_CHANGED, + .expect_alt_ev_param = dev_flags_changed_param, + .expect_alt_ev_len = sizeof(dev_flags_changed_param), +}; + +static const uint8_t set_dev_flags_param_fail_1[] = { + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x00, /* Type */ +}; + +static const struct generic_data set_dev_flags_fail_1 = { + .send_opcode = MGMT_OP_SET_DEVICE_FLAGS, + .send_param = set_dev_flags_param_fail_1, + .send_len = sizeof(set_dev_flags_param_fail_1), + .expect_status = MGMT_STATUS_INVALID_PARAMS, +}; + +static const uint8_t set_dev_flags_param_fail_2[] = { + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x00, /* Type */ + 0x03, 0x00, 0x00, 0x00, /* Current Flages */ +}; + +static const struct generic_data set_dev_flags_fail_2 = { + .send_opcode = MGMT_OP_SET_DEVICE_FLAGS, + .send_param = set_dev_flags_param_fail_2, + .send_len = sizeof(set_dev_flags_param_fail_2), + .expect_status = MGMT_STATUS_INVALID_PARAMS, + .expect_param = set_dev_flags_rsp_param, + .expect_len = sizeof(set_dev_flags_rsp_param), +}; + +static const uint8_t set_dev_flags_param_fail_3[] = { + 0x11, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x00, /* Type */ + 0x01, 0x00, 0x00, 0x00, /* Current Flages */ +}; + +static const uint8_t set_dev_flags_rsp_param_fail_3[] = { + 0x11, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x00, /* Type */ +}; + +static const struct generic_data set_dev_flags_fail_3 = { + .send_opcode = MGMT_OP_SET_DEVICE_FLAGS, + .send_param = set_dev_flags_param_fail_3, + .send_len = sizeof(set_dev_flags_param_fail_3), + .expect_status = MGMT_STATUS_INVALID_PARAMS, + .expect_param = set_dev_flags_rsp_param_fail_3, + .expect_len = sizeof(set_dev_flags_rsp_param_fail_3), +}; + static bool power_off(uint16_t index) { int sk, err; @@ -11010,5 +11144,53 @@ int main(int argc, char *argv[]) NULL, test_command_generic); + /* MGMT_OP_GET_DEVICE_FLAGS + * Success + */ + test_bredrle50("Get Device Flags - Success", + &get_dev_flags_success, + setup_get_dev_flags, + test_command_generic); + + /* MGMT_OP_GET_DEVICE_FLAGS + * Fail - Invalid parameter + */ + test_bredrle50("Get Device Flags - Invalid Parameter", + &get_dev_flags_fail_1, + setup_get_dev_flags, + test_command_generic); + + /* MGMT_OP_SET_DEVICE_FLAGS + * Success + */ + test_bredrle50("Set Device Flags - Success", + &set_dev_flags_success, + setup_get_dev_flags, + test_command_generic); + + /* MGMT_OP_SET_DEVICE_FLAGS + * Invalid Parameter - Missing parameter + */ + test_bredrle50("Set Device Flags - Invalid Parameter 1", + &set_dev_flags_fail_1, + setup_get_dev_flags, + test_command_generic); + + /* MGMT_OP_SET_DEVICE_FLAGS + * Invalid Parameter - Not supported value + */ + test_bredrle50("Set Device Flags - Invalid Parameter 2", + &set_dev_flags_fail_2, + setup_get_dev_flags, + test_command_generic); + + /* MGMT_OP_SET_DEVICE_FLAGS + * Device not exist + */ + test_bredrle50("Set Device Flags - Device not found", + &set_dev_flags_fail_3, + setup_get_dev_flags, + test_command_generic); + return tester_run(); } -- 2.26.3