Skip to content

Commit ccb0e20

Browse files
committed
[nrf fromtree] tests: drivers: spi: spi_loopback: configure spi latency expectation
Allow to customize scaling factor used to compare ideal spi transfer and measured one. Signed-off-by: Piotr Kosycarz <[email protected]> (cherry picked from commit d700619)
1 parent 8fc5484 commit ccb0e20

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

tests/drivers/spi/spi_loopback/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ config SPI_LARGE_BUFFER_SIZE
1111
int "Large buffer size"
1212
default 8192
1313

14+
config SPI_IDEAL_TRANSFER_DURATION_SCALING
15+
int "Scaling factor to compare ideal and measured SPI transfer duration"
16+
default 8
17+
1418
if SOC_SERIES_STM32H7X
1519

1620
config SPI_LOOPBACK_16BITS_FRAMES
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_SPI_IDEAL_TRANSFER_DURATION_SCALING=12
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_SPI_IDEAL_TRANSFER_DURATION_SCALING=12

tests/drivers/spi/spi_loopback/src/spi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ ZTEST(spi_loopback, test_spi_complete_multiple_timed)
327327

328328
/* Fail if transfer is faster than theoretically possible */
329329
zassert_true(time_spent_us >= minimum_transfer_time_us,
330-
"Transfer faster than theoretically possible");
330+
"Transfer faster than theoretically possible");
331331

332332
/* handle overflow for print statement */
333333
latency_measurement = time_spent_us - expected_transfer_time_us;
@@ -337,7 +337,9 @@ ZTEST(spi_loopback, test_spi_complete_multiple_timed)
337337
TC_PRINT("Latency measurement: %llu us\n", latency_measurement);
338338

339339
/* Allow some overhead, but not too much */
340-
zassert_true(time_spent_us <= expected_transfer_time_us * 8, "Very high latency");
340+
zassert_true(time_spent_us <=
341+
expected_transfer_time_us * CONFIG_SPI_IDEAL_TRANSFER_DURATION_SCALING,
342+
"Very high latency");
341343

342344
spi_loopback_compare_bufs(buffer_tx, buffer_rx, BUF_SIZE,
343345
buffer_print_tx, buffer_print_rx);

0 commit comments

Comments
 (0)