test: bmc_event_ack_v2 must negotiate v2
The test checks for a v2-specific masking behaviour of the BMC status
byte. Ensure we have v2 before assuming v2 semantics.
Change-Id: I9791b000b8f11db4ccc34af6da554aea2139a732
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/test/bmc_event_ack_v2.c b/test/bmc_event_ack_v2.c
index 3d4cffd..627309c 100644
--- a/test/bmc_event_ack_v2.c
+++ b/test/bmc_event_ack_v2.c
@@ -15,11 +15,18 @@
#define FLAGS 0xc3
+static const uint8_t get_info[] = {
+ 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
static const uint8_t command[] = {
0x09, 0xaa, FLAGS, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, FLAGS
};
+uint8_t data[3] = { 0xaa, 0x55, 0xaa };
+
#define MEM_SIZE 3
#define ERASE_SIZE 1
#define N_WINDOWS 1
@@ -36,6 +43,11 @@
system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
+ rc = mbox_set_mtd_data(ctx, data, sizeof(data));
+ assert(rc == 0);
+
+ rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
+ assert(rc == 1);
set_bmc_events(ctx, FLAGS, SET_BMC_EVENT);
@@ -45,14 +57,12 @@
rc = fstat(ctx->fds[MBOX_FD].fd, &details);
assert(rc == 0);
- assert(details.st_size == 16);
-
map = mmap(NULL, details.st_size, PROT_READ, MAP_PRIVATE,
ctx->fds[MBOX_FD].fd, 0);
assert(map != MAP_FAILED);
- if (map[15] != 0xc0)
- return -1;
+ assert(details.st_size >= 16);
+ assert(map[15] == 0xc0);
- return rc;
+ return 0;
}