Skip to content

Commit

Permalink
tests: rtio: test rtio_sqe_prep_callback_no_cqe
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
JordanYates authored and aescolar committed Aug 30, 2024
1 parent 559f58b commit ffc46ba
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tests/subsys/rtio/rtio_api/src/test_rtio_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
*
Expand Down Expand Up @@ -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]);
Expand All @@ -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);
Expand Down

0 comments on commit ffc46ba

Please sign in to comment.