Skip to content

Commit 6233174

Browse files
Emil-JuhlXH-YongbingLiu
authored andcommitted
tests: rtio: test early signalling of RTIO_OP_AWAIT
The brief on the existing test_rtio_await_ function mentioned testing that an await operation would immediately complete ("be skipped") if the SQE were signalled prior to being submitted. The function didn't actually test this, though. Add a new test function for testing this specific case. Remove the misleading part of the brief around the existing test. Rename test_rtio_await_ to be more concise on the test it performs. Signed-off-by: Emil Dahl Juhl <[email protected]>
1 parent 08eb0e9 commit 6233174

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

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

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -882,14 +882,47 @@ RTIO_DEFINE(r_await1, SQE_POOL_SIZE, CQE_POOL_SIZE);
882882
RTIO_IODEV_TEST_DEFINE(iodev_test_await0);
883883

884884
/**
885-
* @brief Test await requests
885+
* @brief Test early signalling on await requests
886+
*
887+
* Ensures that the AWAIT operation will be skipped if rtio_seq_signal() was
888+
* called before the AWAIT SQE is executed.
889+
*/
890+
void test_rtio_await_early_signal_(struct rtio *r)
891+
{
892+
int res;
893+
int32_t userdata = 0;
894+
struct rtio_sqe *sqe;
895+
struct rtio_cqe *cqe;
896+
897+
rtio_iodev_test_init(&iodev_test_await0);
898+
899+
TC_PRINT("Prepare await sqe\n");
900+
sqe = rtio_sqe_acquire(r);
901+
zassert_not_null(sqe, "Expected a valid sqe");
902+
rtio_sqe_prep_await(sqe, &iodev_test_await0, RTIO_PRIO_LOW, &userdata);
903+
sqe->flags = 0;
904+
905+
TC_PRINT("Signal await sqe prior to submission\n");
906+
rtio_sqe_signal(sqe);
907+
908+
TC_PRINT("Submit await sqe\n");
909+
res = rtio_submit(r, 0);
910+
zassert_ok(res, "Submission failed");
911+
912+
TC_PRINT("Ensure await sqe completed\n");
913+
cqe = rtio_cqe_consume_block(r);
914+
zassert_not_null(cqe, "Expected a valid cqe");
915+
zassert_equal(cqe->userdata, &userdata);
916+
rtio_cqe_release(r, cqe);
917+
}
918+
919+
/**
920+
* @brief Test blocking rtio_iodev using await requests
886921
*
887922
* Ensures we can block execution of an RTIO iodev using the AWAIT operation,
888-
* and unblock it by calling rtio_seq_signal(), and that the AWAIT operation
889-
* will be skipped if rtio_seq_signal() was called before the AWAIT SQE is
890-
* executed.
923+
* and unblock it by calling rtio_seq_signal().
891924
*/
892-
void test_rtio_await_(struct rtio *rtio0, struct rtio *rtio1)
925+
void test_rtio_await_iodev_(struct rtio *rtio0, struct rtio *rtio1)
893926
{
894927
int res;
895928
int32_t userdata[3] = {0, 1, 2};
@@ -1040,7 +1073,8 @@ void test_rtio_await_executor_(struct rtio *rtio0, struct rtio *rtio1)
10401073

10411074
ZTEST(rtio_api, test_rtio_await)
10421075
{
1043-
test_rtio_await_(&r_await0, &r_await1);
1076+
test_rtio_await_early_signal_(&r_await0);
1077+
test_rtio_await_iodev_(&r_await0, &r_await1);
10441078
test_rtio_await_executor_(&r_await0, &r_await1);
10451079
}
10461080

0 commit comments

Comments
 (0)