szymon-czapracki commented on code in PR #1731:
URL: https://github.com/apache/mynewt-nimble/pull/1731#discussion_r1560980616
##########
apps/blestress/src/rx_stress.h:
##########
@@ -44,10 +44,12 @@ extern "C" {
/*
* Executes stress tests one by one.
*/
+void rx_stress_task();
+void rx_stress_main_task_fn(void *arg);
void rx_stress_start_auto();
#ifdef __cplusplus
}
#endif
-#endif //_BLE_STRESS_RX_H
+#endif /*_BLE_STRESS_RX_H */
Review Comment:
nitpick
```suggestion
#endif /* _BLE_STRESS_RX_H */
```
##########
apps/blestress/src/cmd_rx.c:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <assert.h>
+#include <inttypes.h>
+#include <string.h>
+#include "os/mynewt.h"
+
+#include "console/console.h"
+#include "shell/shell.h"
+
+#include "cmd.h"
+
+int test_case_num;
+struct os_sem rx_stress_test_sem;
+
+static int
+start_test_case(int argc, char **argv)
+{
+ uint8_t test_num;
+ uint8_t min = 1;
+ uint8_t max = 15;
+ uint8_t dflt = 0;
+ int rc;
+
+ rc = parse_arg_init(argc - 1, argv +1);
Review Comment:
```suggestion
rc = parse_arg_init(argc - 1, argv + 1);
```
##########
apps/blestress/src/rx_stress.c:
##########
@@ -777,8 +791,8 @@ rx_stress_10_l2cap_event(struct ble_l2cap_event *event,
void *arg)
chan_info.peer_l2cap_mtu);
struct ble_l2cap_sig_update_params params = {
- .itvl_min = 0x0006,//BLE_GAP_INITIAL_CONN_ITVL_MIN
- .itvl_max = 0x0006,//BLE_GAP_INITIAL_CONN_ITVL_MIN
+ .itvl_min = 0x0006,/*BLE_GAP_INITIAL_CONN_ITVL_MIN */
+ .itvl_max = 0x0006,/*BLE_GAP_INITIAL_CONN_ITVL_MIN */
Review Comment:
```suggestion
.itvl_min = 0x0006,/* BLE_GAP_INITIAL_CONN_ITVL_MIN */
.itvl_max = 0x0006,/* BLE_GAP_INITIAL_CONN_ITVL_MIN */
```
nitpick
##########
apps/blestress/src/stress.c:
##########
@@ -22,75 +22,109 @@
static struct os_callout stress_timer_callout;
void
-com_stress_print_report(const struct com_stress_test_ctx *test_ctxs)
+com_stress_print_report(const struct com_stress_test_ctx *test_ctxs,
+ int test_num)
{
- console_printf("\033[0;32mAll tests completed\033[0m\n");
- console_printf("Tests results:\n");
-
- console_printf(
- "\033[0;33mUse case 1 - Stress Connect -> Connect Cancel: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[1].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[1].num);
-
- console_printf(
- "\033[0;33mUse case 2 - Stress Connect/Disconnect legacy: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[2].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[2].num);
-
- console_printf(
- "\033[0;33mUse case 3 - Stress Connect/Disconnect ext adv: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[3].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[3].num);
-
- console_printf(
- "\033[0;33mUse case 4 - Stress connection params update (TX):
\n\033[0m");
- console_printf("Params updates = %d\n",
- test_ctxs->con_stat[4].prms_upd_num);
-
- console_printf(
- "\033[0;33mUse case 5 - Stress connection params update (RX):
\n\033[0m");
- console_printf("Params updates = %d\n",
- test_ctxs->con_stat[5].prms_upd_num);
-
- console_printf("\033[0;33mUse case 6 - Stress Scan: \n\033[0m");
- console_printf("Received first packets = %d\n",
- test_ctxs->s6_rcv_adv_first);
- console_printf("Received all packets = %d\n", test_ctxs->s6_rcv_adv_suc);
-
- console_printf("\033[0;33mUse case 7 - Stress PHY Update (TX): \n\033[0m");
- console_printf("PHY updates = %d\n", test_ctxs->con_stat[7].phy_upd_num);
-
- console_printf("\033[0;33mUse case 8 - Stress PHY Update (RX): \n\033[0m");
- console_printf("PHY updates = %d\n", test_ctxs->con_stat[8].phy_upd_num);
-
- console_printf(
- "\033[0;33mUse case 9 - Stress multi connection: \n\033[0m");
- console_printf("Max reached num of connections = %d\n",
- test_ctxs->con_stat[9].max_num);
-
- console_printf("\033[0;33mUse case 10 - Stress L2CAP send: \n\033[0m");
- console_printf("Average bit rate = %d\n", test_ctxs->s10_bit_rate);
- console_printf("Max received MTU = %lld\n", test_ctxs->s10_max_mtu);
-
- console_printf("\033[0;33mUse case 11 - "
- "Stress Advertise/Connect/Continue adv \n\033[0m");
-// console_printf(" = %d\n",);
-
- console_printf("\033[0;33mUse case 12 - "
- "Stress GATT indication: \n\033[0m");
- console_printf("Average bit rate = %d\n", test_ctxs->s12_notif_time);
-
- console_printf("\033[0;33mUse case 13 - "
- "Stress GATT notification: \n\033[0m");
- console_printf("Average time = %d\n", test_ctxs->s13_notif_time);
-
- console_printf("\033[0;33mUse case 14 - "
- "Stress GATT Subscribe/Notify/Unsubscribe: \n\033[0m");
- console_printf("Average time = %d\n", test_ctxs->s14_notif_time);
-
- console_printf("\033[0;33mUse case 15 - "
- "Stress Connect/Send/Disconnect: \n\033[0m");
- console_printf("Con num = %d\n", test_ctxs->con_stat[15].num);
+ console_printf("Tests result:\n");
+
+ switch (test_num) {
+ case 1:
+ console_printf(
+ "\033[0;33mUse case 1 - "
+ "Stress Connect -> Connect Cancel: \n\033[0m");
+ console_printf("Con attempts = %d\n",
+ test_ctxs->con_stat[1].attempts_num);
Review Comment:
```suggestion
console_printf("Con attempts = %d\n",
test_ctxs->con_stat[1].attempts_num);
```
##########
apps/blestress/src/stress.c:
##########
@@ -22,75 +22,109 @@
static struct os_callout stress_timer_callout;
void
-com_stress_print_report(const struct com_stress_test_ctx *test_ctxs)
+com_stress_print_report(const struct com_stress_test_ctx *test_ctxs,
+ int test_num)
{
- console_printf("\033[0;32mAll tests completed\033[0m\n");
- console_printf("Tests results:\n");
-
- console_printf(
- "\033[0;33mUse case 1 - Stress Connect -> Connect Cancel: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[1].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[1].num);
-
- console_printf(
- "\033[0;33mUse case 2 - Stress Connect/Disconnect legacy: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[2].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[2].num);
-
- console_printf(
- "\033[0;33mUse case 3 - Stress Connect/Disconnect ext adv: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[3].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[3].num);
-
- console_printf(
- "\033[0;33mUse case 4 - Stress connection params update (TX):
\n\033[0m");
- console_printf("Params updates = %d\n",
- test_ctxs->con_stat[4].prms_upd_num);
-
- console_printf(
- "\033[0;33mUse case 5 - Stress connection params update (RX):
\n\033[0m");
- console_printf("Params updates = %d\n",
- test_ctxs->con_stat[5].prms_upd_num);
-
- console_printf("\033[0;33mUse case 6 - Stress Scan: \n\033[0m");
- console_printf("Received first packets = %d\n",
- test_ctxs->s6_rcv_adv_first);
- console_printf("Received all packets = %d\n", test_ctxs->s6_rcv_adv_suc);
-
- console_printf("\033[0;33mUse case 7 - Stress PHY Update (TX): \n\033[0m");
- console_printf("PHY updates = %d\n", test_ctxs->con_stat[7].phy_upd_num);
-
- console_printf("\033[0;33mUse case 8 - Stress PHY Update (RX): \n\033[0m");
- console_printf("PHY updates = %d\n", test_ctxs->con_stat[8].phy_upd_num);
-
- console_printf(
- "\033[0;33mUse case 9 - Stress multi connection: \n\033[0m");
- console_printf("Max reached num of connections = %d\n",
- test_ctxs->con_stat[9].max_num);
-
- console_printf("\033[0;33mUse case 10 - Stress L2CAP send: \n\033[0m");
- console_printf("Average bit rate = %d\n", test_ctxs->s10_bit_rate);
- console_printf("Max received MTU = %lld\n", test_ctxs->s10_max_mtu);
-
- console_printf("\033[0;33mUse case 11 - "
- "Stress Advertise/Connect/Continue adv \n\033[0m");
-// console_printf(" = %d\n",);
-
- console_printf("\033[0;33mUse case 12 - "
- "Stress GATT indication: \n\033[0m");
- console_printf("Average bit rate = %d\n", test_ctxs->s12_notif_time);
-
- console_printf("\033[0;33mUse case 13 - "
- "Stress GATT notification: \n\033[0m");
- console_printf("Average time = %d\n", test_ctxs->s13_notif_time);
-
- console_printf("\033[0;33mUse case 14 - "
- "Stress GATT Subscribe/Notify/Unsubscribe: \n\033[0m");
- console_printf("Average time = %d\n", test_ctxs->s14_notif_time);
-
- console_printf("\033[0;33mUse case 15 - "
- "Stress Connect/Send/Disconnect: \n\033[0m");
- console_printf("Con num = %d\n", test_ctxs->con_stat[15].num);
+ console_printf("Tests result:\n");
+
+ switch (test_num) {
+ case 1:
+ console_printf(
+ "\033[0;33mUse case 1 - "
+ "Stress Connect -> Connect Cancel: \n\033[0m");
Review Comment:
```suggestion
console_printf("\033[0;33mUse case 1 - "
"Stress Connect -> Connect Cancel:
\n\033[0m");
```
##########
apps/blestress/src/rx_stress.c:
##########
@@ -1439,43 +1453,36 @@ stress_uuid_init()
}
}
-static void
-rx_stress_read_command_cb(void)
-{
- console_printf("Start testing\n");
- os_sem_release(&rx_stress_main_sem);
-}
-
-static void
+void
rx_stress_main_task_fn(void *arg)
{
int i;
stress_uuid_init();
- console_printf("\033[1;36mRX device\033[0m\n");
- console_printf("Press ENTER to start: \n");
- console_init(&rx_stress_read_command_cb);
-
- /* Waite for pressing ENTER in console */
- os_sem_pend(&rx_stress_main_sem, OS_TIMEOUT_NEVER);
-
- /* Standard tests perform */
- for (i = 1; i < STRESS_UUIDS_NUM; ++i) {
- /* Start test. */
- rx_stress_start(i);
- }
-
- /* Print tests results */
- com_stress_print_report(rx_stress_ctx);
-
- /* Task should never return */
while (1) {
+ /* Waite for pressing ENTER in console */
+ os_sem_pend(&rx_stress_test_sem, OS_TIMEOUT_NEVER);
+
+ if (test_case_num == 0) {
+ for (i = 1; i < STRESS_UUIDS_NUM; ++i) {
+ /* Run all tests. */
+ rx_stress_start(i);
+ }
+ all_test_run = 1;
+ console_printf("\033[0;32mAll tests completed\033[0m\n");
+ for (i = 1; i < STRESS_UUIDS_NUM; ++i) {
+ /* Print test results of all tests */
+ com_stress_print_report(rx_stress_ctx, i);
+ }
+ } else {
+ rx_stress_start(test_case_num);
Review Comment:
Is else here necessary? If `test_case_num == 0` run those loops, otherwise
just run `rx_stress_start(test_case_num)`, or am I missing something?
```suggestion
}
rx_stress_start(test_case_num);
```
##########
apps/blestress/src/tx_stress.c:
##########
@@ -1640,13 +1647,13 @@ tx_stress_main_task_fn(void *arg)
assert(rc == 0);
/* Start test 1 - Connect/Connect cancel */
- //tx_stress_test_perform(1);
+ /*tx_stress_test_perform(1); */
Review Comment:
nitpick
```suggestion
/* tx_stress_test_perform(1); */
```
##########
apps/blestress/src/stress.c:
##########
@@ -22,75 +22,109 @@
static struct os_callout stress_timer_callout;
void
-com_stress_print_report(const struct com_stress_test_ctx *test_ctxs)
+com_stress_print_report(const struct com_stress_test_ctx *test_ctxs,
+ int test_num)
{
- console_printf("\033[0;32mAll tests completed\033[0m\n");
- console_printf("Tests results:\n");
-
- console_printf(
- "\033[0;33mUse case 1 - Stress Connect -> Connect Cancel: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[1].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[1].num);
-
- console_printf(
- "\033[0;33mUse case 2 - Stress Connect/Disconnect legacy: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[2].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[2].num);
-
- console_printf(
- "\033[0;33mUse case 3 - Stress Connect/Disconnect ext adv: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[3].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[3].num);
-
- console_printf(
- "\033[0;33mUse case 4 - Stress connection params update (TX):
\n\033[0m");
- console_printf("Params updates = %d\n",
- test_ctxs->con_stat[4].prms_upd_num);
-
- console_printf(
- "\033[0;33mUse case 5 - Stress connection params update (RX):
\n\033[0m");
- console_printf("Params updates = %d\n",
- test_ctxs->con_stat[5].prms_upd_num);
-
- console_printf("\033[0;33mUse case 6 - Stress Scan: \n\033[0m");
- console_printf("Received first packets = %d\n",
- test_ctxs->s6_rcv_adv_first);
- console_printf("Received all packets = %d\n", test_ctxs->s6_rcv_adv_suc);
-
- console_printf("\033[0;33mUse case 7 - Stress PHY Update (TX): \n\033[0m");
- console_printf("PHY updates = %d\n", test_ctxs->con_stat[7].phy_upd_num);
-
- console_printf("\033[0;33mUse case 8 - Stress PHY Update (RX): \n\033[0m");
- console_printf("PHY updates = %d\n", test_ctxs->con_stat[8].phy_upd_num);
-
- console_printf(
- "\033[0;33mUse case 9 - Stress multi connection: \n\033[0m");
- console_printf("Max reached num of connections = %d\n",
- test_ctxs->con_stat[9].max_num);
-
- console_printf("\033[0;33mUse case 10 - Stress L2CAP send: \n\033[0m");
- console_printf("Average bit rate = %d\n", test_ctxs->s10_bit_rate);
- console_printf("Max received MTU = %lld\n", test_ctxs->s10_max_mtu);
-
- console_printf("\033[0;33mUse case 11 - "
- "Stress Advertise/Connect/Continue adv \n\033[0m");
-// console_printf(" = %d\n",);
-
- console_printf("\033[0;33mUse case 12 - "
- "Stress GATT indication: \n\033[0m");
- console_printf("Average bit rate = %d\n", test_ctxs->s12_notif_time);
-
- console_printf("\033[0;33mUse case 13 - "
- "Stress GATT notification: \n\033[0m");
- console_printf("Average time = %d\n", test_ctxs->s13_notif_time);
-
- console_printf("\033[0;33mUse case 14 - "
- "Stress GATT Subscribe/Notify/Unsubscribe: \n\033[0m");
- console_printf("Average time = %d\n", test_ctxs->s14_notif_time);
-
- console_printf("\033[0;33mUse case 15 - "
- "Stress Connect/Send/Disconnect: \n\033[0m");
- console_printf("Con num = %d\n", test_ctxs->con_stat[15].num);
+ console_printf("Tests result:\n");
+
+ switch (test_num) {
+ case 1:
+ console_printf(
+ "\033[0;33mUse case 1 - "
+ "Stress Connect -> Connect Cancel: \n\033[0m");
Review Comment:
Applies also in some places below.
##########
apps/blestress/src/stress.c:
##########
@@ -22,75 +22,109 @@
static struct os_callout stress_timer_callout;
void
-com_stress_print_report(const struct com_stress_test_ctx *test_ctxs)
+com_stress_print_report(const struct com_stress_test_ctx *test_ctxs,
+ int test_num)
{
- console_printf("\033[0;32mAll tests completed\033[0m\n");
- console_printf("Tests results:\n");
-
- console_printf(
- "\033[0;33mUse case 1 - Stress Connect -> Connect Cancel: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[1].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[1].num);
-
- console_printf(
- "\033[0;33mUse case 2 - Stress Connect/Disconnect legacy: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[2].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[2].num);
-
- console_printf(
- "\033[0;33mUse case 3 - Stress Connect/Disconnect ext adv: \n\033[0m");
- console_printf("Con attempts = %d\n", test_ctxs->con_stat[3].attempts_num);
- console_printf("Con success = %d\n", test_ctxs->con_stat[3].num);
-
- console_printf(
- "\033[0;33mUse case 4 - Stress connection params update (TX):
\n\033[0m");
- console_printf("Params updates = %d\n",
- test_ctxs->con_stat[4].prms_upd_num);
-
- console_printf(
- "\033[0;33mUse case 5 - Stress connection params update (RX):
\n\033[0m");
- console_printf("Params updates = %d\n",
- test_ctxs->con_stat[5].prms_upd_num);
-
- console_printf("\033[0;33mUse case 6 - Stress Scan: \n\033[0m");
- console_printf("Received first packets = %d\n",
- test_ctxs->s6_rcv_adv_first);
- console_printf("Received all packets = %d\n", test_ctxs->s6_rcv_adv_suc);
-
- console_printf("\033[0;33mUse case 7 - Stress PHY Update (TX): \n\033[0m");
- console_printf("PHY updates = %d\n", test_ctxs->con_stat[7].phy_upd_num);
-
- console_printf("\033[0;33mUse case 8 - Stress PHY Update (RX): \n\033[0m");
- console_printf("PHY updates = %d\n", test_ctxs->con_stat[8].phy_upd_num);
-
- console_printf(
- "\033[0;33mUse case 9 - Stress multi connection: \n\033[0m");
- console_printf("Max reached num of connections = %d\n",
- test_ctxs->con_stat[9].max_num);
-
- console_printf("\033[0;33mUse case 10 - Stress L2CAP send: \n\033[0m");
- console_printf("Average bit rate = %d\n", test_ctxs->s10_bit_rate);
- console_printf("Max received MTU = %lld\n", test_ctxs->s10_max_mtu);
-
- console_printf("\033[0;33mUse case 11 - "
- "Stress Advertise/Connect/Continue adv \n\033[0m");
-// console_printf(" = %d\n",);
-
- console_printf("\033[0;33mUse case 12 - "
- "Stress GATT indication: \n\033[0m");
- console_printf("Average bit rate = %d\n", test_ctxs->s12_notif_time);
-
- console_printf("\033[0;33mUse case 13 - "
- "Stress GATT notification: \n\033[0m");
- console_printf("Average time = %d\n", test_ctxs->s13_notif_time);
-
- console_printf("\033[0;33mUse case 14 - "
- "Stress GATT Subscribe/Notify/Unsubscribe: \n\033[0m");
- console_printf("Average time = %d\n", test_ctxs->s14_notif_time);
-
- console_printf("\033[0;33mUse case 15 - "
- "Stress Connect/Send/Disconnect: \n\033[0m");
- console_printf("Con num = %d\n", test_ctxs->con_stat[15].num);
+ console_printf("Tests result:\n");
+
+ switch (test_num) {
+ case 1:
+ console_printf(
+ "\033[0;33mUse case 1 - "
+ "Stress Connect -> Connect Cancel: \n\033[0m");
+ console_printf("Con attempts = %d\n",
+ test_ctxs->con_stat[1].attempts_num);
Review Comment:
Applies also in some places below.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]