Skip to content

Commit

Permalink
test-ipmi-hiomap: Add ability to delay some IPMI messages
Browse files Browse the repository at this point in the history
[ Upstream commit 43ca6a2 ]

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 <andrew@aj.id.au>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
  • Loading branch information
amboar authored and Vasant Hegde committed Mar 4, 2019
1 parent d565ef8 commit ef7e137
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion libflash/test/test-ipmi-hiomap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -393,6 +408,9 @@ scenario_hiomap_event_daemon_regained_flash_control_dirty[] = {
},
},
},
{
.type = scenario_delay
},
{
.type = scenario_sel,
.s = {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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, }
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ef7e137

Please sign in to comment.