From 43ca6a2e5b1237f7bf2efb70333c13d145ae62cd Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Thu, 21 Feb 2019 16:58:05 +1030 Subject: test-ipmi-hiomap: Add ability to delay some IPMI messages The initial implementation delivered all BMC-initiated SELs immediately after the delivery of the last response to the host. In some circumstances we want slightly more control over how this works, so introduce a means to manually advance the scenario in the test case. Cc: stable Signed-off-by: Andrew Jeffery Signed-off-by: Stewart Smith --- libflash/test/test-ipmi-hiomap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'libflash') diff --git a/libflash/test/test-ipmi-hiomap.c b/libflash/test/test-ipmi-hiomap.c index 0ad08b4c..19e0cbf5 100644 --- a/libflash/test/test-ipmi-hiomap.c +++ b/libflash/test/test-ipmi-hiomap.c @@ -25,7 +25,8 @@ enum scenario_event_type { scenario_sentinel = 0, scenario_event_p, scenario_cmd, - scenario_sel + scenario_sel, + scenario_delay, }; struct scenario_cmd_data { @@ -79,6 +80,20 @@ static void scenario_enter(const struct scenario_event *scenario) ipmi_msg_ctx.cursor = scenario; } +static void scenario_advance(void) +{ + struct ipmi_msg_ctx *ctx = &ipmi_msg_ctx; + + assert(ctx->cursor->type == scenario_delay); + ctx->cursor++; + + /* Deliver all the undelayed, scheduled SELs */ + while (ctx->cursor->type == scenario_sel) { + ctx->sel.fn(ctx->cursor->s.bmc_state, ctx->sel.context); + ctx->cursor++; + } +} + static void scenario_exit(void) { assert(ipmi_msg_ctx.cursor->type == scenario_sentinel); @@ -393,6 +408,9 @@ scenario_hiomap_event_daemon_regained_flash_control_dirty[] = { }, }, }, + { + .type = scenario_delay + }, { .type = scenario_sel, .s = { @@ -460,6 +478,7 @@ static void test_hiomap_event_daemon_regained_flash_control_dirty(void) scenario_enter(scenario_hiomap_event_daemon_regained_flash_control_dirty); assert(!ipmi_hiomap_init(&bl)); assert(!bl->read(bl, 0, buf, len)); + scenario_advance(); assert(!bl->read(bl, 0, buf, len)); ipmi_hiomap_exit(bl); scenario_exit(); @@ -495,6 +514,9 @@ static const struct scenario_event scenario_hiomap_protocol_reset_recovery[] = { }, }, }, + { + .type = scenario_delay + }, { .type = scenario_sel, .s = { .bmc_state = HIOMAP_E_PROTOCOL_RESET, } @@ -598,6 +620,7 @@ static void test_hiomap_protocol_reset_recovery(void) scenario_enter(scenario_hiomap_protocol_reset_recovery); assert(!ipmi_hiomap_init(&bl)); assert(!bl->read(bl, 0, buf, len)); + scenario_advance(); assert(!bl->read(bl, 0, buf, len)); ipmi_hiomap_exit(bl); scenario_exit(); -- cgit v1.2.1