Skip to content

Commit 08eb0e9

Browse files
Emil-JuhlXH-YongbingLiu
authored andcommitted
tests: rtio: use TRANSACTION for iodev await test
The intention behind using an RTIO_OP_AWAIT tied to an rtio_iodev is to get a guarantee that an entire transaction can be handled without interruptions or parallel work taking place on the rtio_iodev. This guarantee can only be met when SQEs are bundled together using RTIO_SQE_TRANSACTION as they will otherwise be considered individual pieces of work, hence allowing some unrelated piece of work to get scheduled in-between the rest. When just using RTIO_SQE_CHAINED, the rtio_iodev would still block during the entire RTIO_OP_AWAIT, but the following SQE in the chain can be preempted by an unrelated SQE. Modify this specific test case to use RTIO_SQE_TRANSACTION as this will match the intention. Signed-off-by: Emil Dahl Juhl <[email protected]>
1 parent 40cfd52 commit 08eb0e9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tests/subsys/rtio/rtio_api/src/test_rtio_api.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ RTIO_IODEV_TEST_DEFINE(iodev_test_await0);
884884
/**
885885
* @brief Test await requests
886886
*
887-
* Ensures we can block execution of an RTIO context using the AWAIT operation,
887+
* Ensures we can block execution of an RTIO iodev using the AWAIT operation,
888888
* and unblock it by calling rtio_seq_signal(), and that the AWAIT operation
889889
* will be skipped if rtio_seq_signal() was called before the AWAIT SQE is
890890
* executed.
@@ -902,7 +902,7 @@ void test_rtio_await_(struct rtio *rtio0, struct rtio *rtio1)
902902
sqe = rtio_sqe_acquire(rtio0);
903903
zassert_not_null(sqe, "Expected a valid sqe");
904904
rtio_sqe_prep_nop(sqe, &iodev_test_await0, &userdata[0]);
905-
sqe->flags = RTIO_SQE_CHAINED;
905+
sqe->flags = RTIO_SQE_TRANSACTION;
906906

907907
await_sqe = rtio_sqe_acquire(rtio0);
908908
zassert_not_null(await_sqe, "Expected a valid sqe");
@@ -919,11 +919,8 @@ void test_rtio_await_(struct rtio *rtio0, struct rtio *rtio1)
919919
res = rtio_submit(rtio0, 0);
920920
zassert_ok(res, "Submission failed");
921921

922-
TC_PRINT("Wait for nop sqe from rtio0 completed\n");
923-
cqe = rtio_cqe_consume_block(rtio0);
924-
zassert_not_null(sqe, "Expected a valid sqe");
925-
zassert_equal(cqe->userdata, &userdata[0]);
926-
rtio_cqe_release(rtio0, cqe);
922+
TC_PRINT("Ensure rtio0 has started execution\n");
923+
k_sleep(K_MSEC(20));
927924

928925
TC_PRINT("Submitting sqe from rtio1\n");
929926
res = rtio_submit(rtio1, 0);
@@ -937,7 +934,11 @@ void test_rtio_await_(struct rtio *rtio0, struct rtio *rtio1)
937934
TC_PRINT("Signal await sqe from rtio0\n");
938935
rtio_sqe_signal(await_sqe);
939936

940-
TC_PRINT("Ensure sqe from rtio0 completed\n");
937+
TC_PRINT("Ensure both sqe from rtio0 completed\n");
938+
cqe = rtio_cqe_consume_block(rtio0);
939+
zassert_not_null(cqe, "Expected a valid cqe");
940+
zassert_equal(cqe->userdata, &userdata[0]);
941+
rtio_cqe_release(rtio0, cqe);
941942
cqe = rtio_cqe_consume_block(rtio0);
942943
zassert_not_null(cqe, "Expected a valid cqe");
943944
zassert_equal(cqe->userdata, &userdata[1]);

0 commit comments

Comments
 (0)