From ffc46baeb7ed7f16c10dbe67af8f9e4ea55ba94b Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Wed, 28 Aug 2024 09:51:09 +1000 Subject: [PATCH] tests: rtio: test `rtio_sqe_prep_callback_no_cqe` Test that SQE's created with `rtio_sqe_prep_callback_no_cqe` run, but don't create a completion queue event. Signed-off-by: Jordan Yates --- tests/subsys/rtio/rtio_api/src/test_rtio_api.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/subsys/rtio/rtio_api/src/test_rtio_api.c b/tests/subsys/rtio/rtio_api/src/test_rtio_api.c index d101f3bcc294..3962b4723d0a 100644 --- a/tests/subsys/rtio/rtio_api/src/test_rtio_api.c +++ b/tests/subsys/rtio/rtio_api/src/test_rtio_api.c @@ -25,8 +25,8 @@ #define MEM_BLK_SIZE 16 #define MEM_BLK_ALIGN 4 -#define SQE_POOL_SIZE 4 -#define CQE_POOL_SIZE 4 +#define SQE_POOL_SIZE 5 +#define CQE_POOL_SIZE 5 /* * Purposefully double the block count and half the block size. This leaves the same size mempool, @@ -654,6 +654,7 @@ ZTEST(rtio_api, test_rtio_throughput) RTIO_DEFINE(r_callback_chaining, SQE_POOL_SIZE, CQE_POOL_SIZE); RTIO_IODEV_TEST_DEFINE(iodev_test_callback_chaining0); +static bool cb_no_cqe_run; /** * Callback for testing with @@ -663,6 +664,12 @@ void rtio_callback_chaining_cb(struct rtio *r, const struct rtio_sqe *sqe, void TC_PRINT("chaining callback with userdata %p\n", arg0); } +void rtio_callback_chaining_cb_no_cqe(struct rtio *r, const struct rtio_sqe *sqe, void *arg0) +{ + TC_PRINT("Chaining callback with userdata %p (No CQE)\n", arg0); + cb_no_cqe_run = true; +} + /** * @brief Test callback chaining requests * @@ -696,6 +703,11 @@ void test_rtio_callback_chaining_(struct rtio *r) rtio_sqe_prep_nop(sqe, &iodev_test_callback_chaining0, &userdata[2]); sqe->flags |= RTIO_SQE_CHAINED; + sqe = rtio_sqe_acquire(r); + zassert_not_null(sqe, "Expected a valid sqe"); + rtio_sqe_prep_callback_no_cqe(sqe, &rtio_callback_chaining_cb_no_cqe, sqe, NULL); + sqe->flags |= RTIO_SQE_CHAINED; + sqe = rtio_sqe_acquire(r); zassert_not_null(sqe, "Expected a valid sqe"); rtio_sqe_prep_callback(sqe, &rtio_callback_chaining_cb, sqe, &userdata[3]); @@ -706,6 +718,7 @@ void test_rtio_callback_chaining_(struct rtio *r) cq_count, atomic_get(&r->cq_count)); zassert_ok(res, "Should return ok from rtio_execute"); zassert_equal(atomic_get(&r->cq_count) - cq_count, 4, "Should have 4 pending completions"); + zassert_true(cb_no_cqe_run, "Callback without CQE should have run"); for (int i = 0; i < 4; i++) { TC_PRINT("consume %d\n", i);