summaryrefslogtreecommitdiff
path: root/cesar/mac/pbproc/test/int/src/test_pbproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/mac/pbproc/test/int/src/test_pbproc.c')
-rw-r--r--cesar/mac/pbproc/test/int/src/test_pbproc.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/cesar/mac/pbproc/test/int/src/test_pbproc.c b/cesar/mac/pbproc/test/int/src/test_pbproc.c
index 624c71d0c4..c661f361cc 100644
--- a/cesar/mac/pbproc/test/int/src/test_pbproc.c
+++ b/cesar/mac/pbproc/test/int/src/test_pbproc.c
@@ -153,15 +153,49 @@ test_pbproc_activate_fcall (fcall_ctx_t *fcall, fcall_param_t **param,
dbg_assert (msg && *msg);
test_pbproc_t *ctx = (void *) data;
dbg_assert (ctx);
+ /* Only one message at a time. */
+ if (ctx->static_msg.id != TEST_PBPROC_MSG_ID_NONE)
+ return -1;
+ ctx->static_msg.id = TEST_PBPROC_MSG_ID_ACTIVATE;
/* Read message. */
- bool activate;
- if (!fcall_param_bind_helper ("activate", activate))
- activate = true;
+ test_pbproc_msg_activate_t *m = &ctx->static_msg.msg.activate;
+ if (!fcall_param_bind_helper ("activate", m->activate))
+ m->activate = true;
+ /* Message accepted, will return later. */
+ fcall_param_set_async (*param, 1);
+ dbg_assert (ctx->fcall == NULL);
+ ctx->fcall = fcall;
+ ctx->fcall_msg_id = fcall_param_get_msg_id (*param);
+ /* Post message. */
+ dbg_check (cyg_mbox_put (ctx->mbox, &ctx->static_msg));
+ return 0;
+}
+
+static void
+test_pbproc_activate_fcall_return (test_pbproc_t *ctx)
+{
+ fcall_param_t param;
+ sci_msg_t msg;
+ u8 buffer[64];
+ dbg_assert (ctx);
+ dbg_assert (ctx->fcall);
+ fcall_param_init (&param, "activate", ctx->fcall_msg_id);
+ sci_msg_init (&msg, buffer, sizeof (buffer));
+ fcall_param_reset (&param);
+ dbg_check (fcall_return (ctx->fcall, &param, &msg) != -1);
+ ctx->fcall = NULL;
+}
+
+static void
+test_pbproc_activate_handler (test_pbproc_t *ctx, test_pbproc_msg_t *msg)
+{
+ dbg_assert (ctx);
+ dbg_assert (msg->id == TEST_PBPROC_MSG_ID_ACTIVATE);
+ test_pbproc_msg_activate_t *m = &msg->msg.activate;
/* Activate. */
- pbproc_activate (ctx->pbproc, activate);
+ pbproc_activate (ctx->pbproc, m->activate);
/* Return. */
- fcall_param_reset (*param);
- return 0;
+ test_pbproc_activate_fcall_return (ctx);
}
static int
@@ -374,6 +408,8 @@ test_pbproc_init (test_pbproc_t *ctx, fcall_ctx_t *fcall)
fcall_register (fcall, "rx_seg_refill", test_pbproc_rx_seg_refill_fcall,
ctx);
fcall_register (fcall, "trace_dump", test_pbproc_trace_dump_fcall, ctx);
+ ctx->msg_handlers[TEST_PBPROC_MSG_ID_ACTIVATE] =
+ test_pbproc_activate_handler;
ctx->msg_handlers[TEST_PBPROC_MSG_ID_TRACE_DUMP] =
test_pbproc_trace_dump_handler;
ctx->fcall = NULL;