Skip to content

Commit

Permalink
test-ipmi-hiomap: Add ack-malformed tests
Browse files Browse the repository at this point in the history
[ Upstream commit 4642a6c ]

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 5, 2019
1 parent 634a61d commit 4d90d02
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions libflash/test/test-ipmi-hiomap.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct scenario_cmd {
struct scenario_cmd_data req;
struct scenario_cmd_data resp;
uint8_t cc;
size_t resp_size;
};

struct scenario_sel {
Expand Down Expand Up @@ -177,6 +178,9 @@ void ipmi_queue_msg_sync(struct ipmi_msg *msg)
msg->cc = cmd->cc;
memcpy(msg->data, &cmd->resp, msg->resp_size);

if (cmd->resp_size)
msg->resp_size = cmd->resp_size;

msg->complete(msg);

ctx->cursor++;
Expand Down Expand Up @@ -1698,6 +1702,60 @@ static void test_hiomap_erase_error(void)
scenario_exit();
}

static const struct scenario_event scenario_hiomap_ack_malformed_small[] = {
{
.type = scenario_cmd,
.c = {
.req = {
.cmd = HIOMAP_C_ACK,
.seq = 1,
.args = { [0] = 0x3 },
},
.cc = IPMI_CC_NO_ERROR,
.resp_size = 1
},
},
SCENARIO_SENTINEL,
};

static void test_hiomap_ack_malformed_small(void)
{
struct blocklevel_device *bl;

scenario_enter(scenario_hiomap_ack_malformed_small);
assert(ipmi_hiomap_init(&bl) > 0);
scenario_exit();
}

static const struct scenario_event scenario_hiomap_ack_malformed_large[] = {
{
.type = scenario_cmd,
.c = {
.req = {
.cmd = HIOMAP_C_ACK,
.seq = 1,
.args = { [0] = 0x3 },
},
.cc = IPMI_CC_NO_ERROR,
.resp_size = 3,
.resp = {
.cmd = HIOMAP_C_ACK,
.seq = 1,
},
},
},
SCENARIO_SENTINEL,
};

static void test_hiomap_ack_malformed_large(void)
{
struct blocklevel_device *bl;

scenario_enter(scenario_hiomap_ack_malformed_large);
assert(ipmi_hiomap_init(&bl) > 0);
scenario_exit();
}

struct test_case {
const char *name;
void (*fn)(void);
Expand Down Expand Up @@ -1737,6 +1795,8 @@ struct test_case test_cases[] = {
TEST_CASE(test_hiomap_flush_error),
TEST_CASE(test_hiomap_ack_error),
TEST_CASE(test_hiomap_erase_error),
TEST_CASE(test_hiomap_ack_malformed_small),
TEST_CASE(test_hiomap_ack_malformed_large),
{ NULL, NULL },
};

Expand Down

0 comments on commit 4d90d02

Please sign in to comment.