2021-10-04 23:52:44

by Tedd Ho-Jeong An

[permalink] [raw]
Subject: [BlueZ PATCH] tools/mgmt-tester: Fix the suspend reason code

From: Tedd Ho-Jeong An <[email protected]>

This patch fixes the suspend reason code to align with the corrent
kernel implementation.
---
tools/mgmt-tester.c | 86 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 80 insertions(+), 6 deletions(-)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 45fa9c2e1..acca9ef20 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -340,6 +340,34 @@ static int set_debugfs_force_suspend(int index, bool enable)
return err;
}

+static int set_debugfs_force_wakeup(int index, bool enable)
+{
+ int fd, n, err;
+ char val, path[64];
+
+ err = 0;
+
+ /* path for the debugfs file
+ * /sys/kernel/debug/bluetooth/hciX/force_suspend
+ */
+ memset(path, 0, sizeof(path));
+ sprintf(path, "/sys/kernel/debug/bluetooth/hci%d/force_wakeup", index);
+
+ fd = open(path, O_RDWR);
+ if (fd < 0)
+ return -errno;
+
+ val = (enable) ? 'Y' : 'N';
+
+ n = write(fd, &val, sizeof(val));
+ if (n < (ssize_t) sizeof(val))
+ err = -errno;
+
+ close(fd);
+
+ return err;
+}
+
static const uint8_t set_exp_feat_param_debug[] = {
0x1c, 0xda, 0x47, 0x1c, 0x48, 0x6c, 0x01, 0xab, /* UUID - Debug */
0x9f, 0x46, 0xec, 0xb9, 0x30, 0x25, 0x99, 0xd4,
@@ -10103,6 +10131,10 @@ static const uint8_t suspend_state_param_running[] = {
0x00,
};

+static const uint8_t suspend_state_param_disconnect[] = {
+ 0x01,
+};
+
static const uint8_t suspend_state_param_page_scan[] = {
0x02,
};
@@ -10116,8 +10148,8 @@ static const uint8_t resume_state_param_non_bt_wake[] = {
static const struct generic_data suspend_resume_success_1 = {
.setup_settings = settings_powered,
.expect_alt_ev = MGMT_EV_CONTROLLER_SUSPEND,
- .expect_alt_ev_param = suspend_state_param_page_scan,
- .expect_alt_ev_len = sizeof(suspend_state_param_page_scan),
+ .expect_alt_ev_param = suspend_state_param_disconnect,
+ .expect_alt_ev_len = sizeof(suspend_state_param_disconnect),
};

static void test_suspend_resume_success_1(const void *test_data)
@@ -10173,8 +10205,8 @@ static const struct generic_data suspend_resume_success_3 = {
.setup_expect_hci_param = le_add_to_accept_list_param,
.setup_expect_hci_len = sizeof(le_add_to_accept_list_param),
.expect_alt_ev = MGMT_EV_CONTROLLER_SUSPEND,
- .expect_alt_ev_param = suspend_state_param_page_scan,
- .expect_alt_ev_len = sizeof(suspend_state_param_page_scan),
+ .expect_alt_ev_param = suspend_state_param_disconnect,
+ .expect_alt_ev_len = sizeof(suspend_state_param_disconnect),
};

static void setup_suspend_resume_success_3(const void *test_data)
@@ -10215,8 +10247,8 @@ static const struct generic_data suspend_resume_success_4 = {
.setup_expect_hci_param = set_ext_adv_on_set_adv_enable_param,
.setup_expect_hci_len = sizeof(set_ext_adv_on_set_adv_enable_param),
.expect_alt_ev = MGMT_EV_CONTROLLER_SUSPEND,
- .expect_alt_ev_param = suspend_state_param_page_scan,
- .expect_alt_ev_len = sizeof(suspend_state_param_page_scan),
+ .expect_alt_ev_param = suspend_state_param_disconnect,
+ .expect_alt_ev_len = sizeof(suspend_state_param_disconnect),
};

static void setup_suspend_resume_success_4(const void *test_data)
@@ -10306,6 +10338,39 @@ static const struct generic_data suspend_resume_success_6 = {
.just_works = true,
};

+static const struct generic_data suspend_resume_success_7 = {
+ .setup_settings = settings_powered,
+ .expect_alt_ev = MGMT_EV_CONTROLLER_SUSPEND,
+ .expect_alt_ev_param = suspend_state_param_page_scan,
+ .expect_alt_ev_len = sizeof(suspend_state_param_page_scan),
+};
+
+static void test_suspend_resume_success_7(const void *test_data)
+{
+ bool suspend;
+ int err;
+
+ /* Set Force Wakeup */
+ suspend = true;
+ err = set_debugfs_force_wakeup(0, suspend);
+ if (err) {
+ tester_warn("Unable to enable the force_wakeup");
+ tester_test_failed();
+ return;
+ }
+
+ /* Triggers the suspend */
+ suspend = true;
+ err = set_debugfs_force_suspend(0, suspend);
+ if (err) {
+ tester_warn("Unable to enable the force_suspend");
+ tester_test_failed();
+ return;
+ }
+ test_command_generic(test_data);
+}
+
+
int main(int argc, char *argv[])
{
tester_init(&argc, &argv);
@@ -12059,6 +12124,15 @@ int main(int argc, char *argv[])
setup_pairing_acceptor,
test_suspend_resume_success_5);

+ /* Suspend/Resume
+ * Setup : Power on and register Suspend Event
+ * Run: Enable suspend via force_suspend
+ * Expect: Receive the Suspend Event
+ */
+ test_bredrle50("Suspend/Resume - Success 7 (Suspend/Force Wakeup)",
+ &suspend_resume_success_7,
+ NULL, test_suspend_resume_success_7);
+
/* MGMT_OP_READ_EXP_FEATURE
* Read Experimental features - success
*/
--
2.25.1


2021-10-04 23:54:10

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ] tools/mgmt-tester: Fix the suspend reason code

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=557383

---Test result---

Test Summary:
CheckPatch PASS 0.48 seconds
GitLint PASS 0.28 seconds
Prep - Setup ELL PASS 43.19 seconds
Build - Prep PASS 0.21 seconds
Build - Configure PASS 7.72 seconds
Build - Make PASS 184.40 seconds
Make Check PASS 9.19 seconds
Make Distcheck PASS 220.77 seconds
Build w/ext ELL - Configure PASS 7.74 seconds
Build w/ext ELL - Make PASS 179.59 seconds



---
Regards,
Linux Bluetooth

2021-10-05 18:43:58

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [BlueZ] tools/mgmt-tester: Fix the suspend reason code

Hi Tedd,

On Mon, Oct 4, 2021 at 4:54 PM <[email protected]> wrote:
>
> This is automated email and please do not reply to this email!
>
> Dear submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=557383
>
> ---Test result---
>
> Test Summary:
> CheckPatch PASS 0.48 seconds
> GitLint PASS 0.28 seconds
> Prep - Setup ELL PASS 43.19 seconds
> Build - Prep PASS 0.21 seconds
> Build - Configure PASS 7.72 seconds
> Build - Make PASS 184.40 seconds
> Make Check PASS 9.19 seconds
> Make Distcheck PASS 220.77 seconds
> Build w/ext ELL - Configure PASS 7.74 seconds
> Build w/ext ELL - Make PASS 179.59 seconds
>
>
>
> ---
> Regards,
> Linux Bluetooth

Applied, thanks.

--
Luiz Augusto von Dentz