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 <jordan@embeint.com>
This commit is contained in:
Jordan Yates 2024-08-28 09:51:09 +10:00 committed by Alberto Escolar
commit ffc46baeb7

View file

@ -25,8 +25,8 @@
#define MEM_BLK_SIZE 16 #define MEM_BLK_SIZE 16
#define MEM_BLK_ALIGN 4 #define MEM_BLK_ALIGN 4
#define SQE_POOL_SIZE 4 #define SQE_POOL_SIZE 5
#define CQE_POOL_SIZE 4 #define CQE_POOL_SIZE 5
/* /*
* Purposefully double the block count and half the block size. This leaves the same size mempool, * 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_DEFINE(r_callback_chaining, SQE_POOL_SIZE, CQE_POOL_SIZE);
RTIO_IODEV_TEST_DEFINE(iodev_test_callback_chaining0); RTIO_IODEV_TEST_DEFINE(iodev_test_callback_chaining0);
static bool cb_no_cqe_run;
/** /**
* Callback for testing with * 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); 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 * @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]); rtio_sqe_prep_nop(sqe, &iodev_test_callback_chaining0, &userdata[2]);
sqe->flags |= RTIO_SQE_CHAINED; 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); sqe = rtio_sqe_acquire(r);
zassert_not_null(sqe, "Expected a valid sqe"); zassert_not_null(sqe, "Expected a valid sqe");
rtio_sqe_prep_callback(sqe, &rtio_callback_chaining_cb, sqe, &userdata[3]); 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)); cq_count, atomic_get(&r->cq_count));
zassert_ok(res, "Should return ok from rtio_execute"); 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_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++) { for (int i = 0; i < 4; i++) {
TC_PRINT("consume %d\n", i); TC_PRINT("consume %d\n", i);