Skip to content

Commit f2ef51b

Browse files
nordic-krchanangl
authored andcommitted
[nrf fromlist] tests: drivers: uart: uart_mix_fifo_poll: Move counter handling
Move enabling of counter to the test instead of test setup. Test may be skipped in some configurations and in that case counter shall not be started so by moving setup to the test code allows skipping test before counter is started. Upstream PR #: 84240 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent ada595a commit f2ef51b

File tree

1 file changed

+21
-20
lines changed
  • tests/drivers/uart/uart_mix_fifo_poll/src

1 file changed

+21
-20
lines changed

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

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@ static void counter_top_handler(const struct device *dev, void *user_data)
147147

148148
static void init_test(int idx)
149149
{
150-
int err;
151-
struct counter_top_cfg top_cfg = {
152-
.callback = counter_top_handler,
153-
.user_data = NULL,
154-
.flags = 0
155-
};
156-
157150
memset(source, 0, sizeof(source));
158151
async_rx_enabled = false;
159152
uart_dev = duts[idx].dev;
@@ -170,19 +163,6 @@ static void init_test(int idx)
170163
uart_irq_callback_set(uart_dev, int_driven_callback);
171164
}
172165
}
173-
174-
/* Setup counter which will periodically enable/disable UART RX,
175-
* Disabling RX should lead to flow control being activated.
176-
*/
177-
zassert_true(device_is_ready(counter_dev));
178-
179-
top_cfg.ticks = counter_us_to_ticks(counter_dev, 1000);
180-
181-
err = counter_set_top_value(counter_dev, &top_cfg);
182-
zassert_true(err >= 0);
183-
184-
err = counter_start(counter_dev);
185-
zassert_true(err >= 0);
186166
}
187167

188168
static void rx_isr(void)
@@ -343,6 +323,24 @@ ZTEST(uart_mix_fifo_poll, test_mixed_uart_access)
343323
int repeat = CONFIG_STRESS_TEST_REPS;
344324
int err;
345325
int num_of_contexts = ARRAY_SIZE(test_data);
326+
struct counter_top_cfg top_cfg = {
327+
.callback = counter_top_handler,
328+
.user_data = NULL,
329+
.flags = 0
330+
};
331+
332+
/* Setup counter which will periodically enable/disable UART RX,
333+
* Disabling RX should lead to flow control being activated.
334+
*/
335+
zassert_true(device_is_ready(counter_dev));
336+
337+
top_cfg.ticks = counter_us_to_ticks(counter_dev, 1000);
338+
339+
err = counter_set_top_value(counter_dev, &top_cfg);
340+
zassert_true(err >= 0);
341+
342+
err = counter_start(counter_dev);
343+
zassert_true(err >= 0);
346344

347345
for (int i = 0; i < ARRAY_SIZE(test_data); i++) {
348346
init_buf(txbuf[i], sizeof(txbuf[i]), i);
@@ -387,6 +385,9 @@ ZTEST(uart_mix_fifo_poll, test_mixed_uart_access)
387385
"%d: Unexpected rx bytes count (%d/%d)",
388386
i, source[i].cnt, repeat);
389387
}
388+
389+
err = counter_stop(counter_dev);
390+
zassert_true(err >= 0);
390391
}
391392

392393
void *uart_mix_setup(void)

0 commit comments

Comments
 (0)