summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/mbox.c18
-rw-r--r--test/mbox.h7
2 files changed, 23 insertions, 2 deletions
diff --git a/test/mbox.c b/test/mbox.c
index 3dc1611..6c62ddb 100644
--- a/test/mbox.c
+++ b/test/mbox.c
@@ -87,6 +87,24 @@ int mbox_cmp(struct mbox_context *context, const uint8_t *expected, size_t len)
return rc;
}
+void mbox_rspcpy(struct mbox_context *context, struct mbox_msg *msg)
+{
+ struct stat details;
+ uint8_t *map;
+ int fd;
+
+ fd = context->fds[MBOX_FD].fd;
+ fstat(fd, &details);
+
+ map = mmap(NULL, details.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ assert(map != MAP_FAILED);
+ assert(details.st_size >= (RESPONSE_OFFSET + RESPONSE_SIZE));
+
+ memcpy(msg, &map[RESPONSE_OFFSET], RESPONSE_SIZE);
+
+ munmap(map, details.st_size);
+}
+
int mbox_command_write(struct mbox_context *context, const uint8_t *command,
size_t len)
{
diff --git a/test/mbox.h b/test/mbox.h
index 5b89790..4344622 100644
--- a/test/mbox.h
+++ b/test/mbox.h
@@ -7,8 +7,9 @@
#include <stddef.h>
#include <stdint.h>
-#include "../common.h"
-#include "../mbox.h"
+#include "common.h"
+#include "mbox.h"
+#include "mboxd_msg.h"
#include "tmpf.h"
@@ -19,6 +20,8 @@ int mbox_set_mtd_data(struct mbox_context *context, const void *data,
void mbox_dump(struct mbox_context *context);
+void mbox_rspcpy(struct mbox_context *context, struct mbox_msg *msg);
+
int mbox_cmp(struct mbox_context *context, const uint8_t *expected, size_t len);
int mbox_command_write(struct mbox_context *context, const uint8_t *command,
OpenPOWER on IntegriCloud