Skip to content

Commit 9f41e5e

Browse files
committed
tests: drivers: uart: async_dual: Add progress report
Add reporting about the test progress. Test lasts few seconds and progress report helps to see if test stuck or how it is progressing. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
1 parent bc4c0e6 commit 9f41e5e

File tree

1 file changed

+26
-0
lines changed
  • tests/drivers/uart/uart_async_dual/src

1 file changed

+26
-0
lines changed

tests/drivers/uart/uart_async_dual/src/main.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,26 @@ static void config_baudrate(uint32_t rate)
365365
}
366366
}
367367

368+
static void report_progress(uint32_t start)
369+
{
370+
static const uint32_t inc = CONFIG_UART_ASYNC_DUAL_TEST_TIMEOUT / 20;
371+
static uint32_t next;
372+
static uint32_t progress;
373+
374+
if ((k_uptime_get_32() - start < inc) && progress) {
375+
/* Reset state. */
376+
next = inc;
377+
progress = 0;
378+
}
379+
380+
if (k_uptime_get_32() > (start + next)) {
381+
progress += 5;
382+
TC_PRINT("\r%d%%", progress);
383+
next += inc;
384+
}
385+
}
386+
387+
368388
/* Test is running following scenario. Transmitter is sending packets which
369389
* has 1 byte header with length followed by the payload. Transmitter can send
370390
* packets in two modes: bulk where data is send in chunks without gaps between
@@ -380,6 +400,7 @@ static void var_packet_hwfc(uint32_t baudrate, bool tx_packets, bool cont)
380400
{
381401
int err;
382402
uint32_t load = 0;
403+
uint32_t start = k_uptime_get_32();
383404

384405
config_baudrate(baudrate);
385406

@@ -420,8 +441,10 @@ static void var_packet_hwfc(uint32_t baudrate, bool tx_packets, bool cont)
420441
while (tx_data.cont || rx_data.cont) {
421442
fill_tx(&tx_data);
422443
k_msleep(1);
444+
report_progress(start);
423445
try_tx(tx_dev, false);
424446
}
447+
TC_PRINT("\n");
425448

426449
if (IS_ENABLED(CONFIG_CPU_LOAD)) {
427450
load = cpu_load_get(true);
@@ -653,6 +676,7 @@ static void hci_like_rx(void)
653676
uint8_t len;
654677
bool cont;
655678
bool explicit_pm = IS_ENABLED(CONFIG_PM_RUNTIME_IN_TEST);
679+
uint32_t start = k_uptime_get_32();
656680

657681
while (1) {
658682
if (explicit_pm) {
@@ -704,7 +728,9 @@ static void hci_like_rx(void)
704728
PM_CHECK(rx_dev, tx_dev, false);
705729

706730
check_payload(rx_data.buf, len);
731+
report_progress(start);
707732
}
733+
TC_PRINT("\n");
708734
}
709735

710736
#define HCI_LIKE_TX_STACK_SIZE 2048

0 commit comments

Comments
 (0)