summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2019-03-14 16:42:15 +1030
committerAndrew Jeffery <andrew@aj.id.au>2019-03-15 22:42:12 +1030
commit2dfc2a22a26b8726b1da336e952c3d05ebe02aed (patch)
tree380429f9db1fd6648538cdbc003a2c3fee335d65
parent7c1588aad84b8aa680e1cdf32c10092221a067fe (diff)
downloadphosphor-mboxbridge-2dfc2a22a26b8726b1da336e952c3d05ebe02aed.tar.gz
phosphor-mboxbridge-2dfc2a22a26b8726b1da336e952c3d05ebe02aed.zip
test/flash_copy: Configure MTD device to avoid undefined behaviour
Otherwise we observe invalid memory accesses due to uninitialised variables. Change-Id: I8b9063ccc9a25b225a562ebe120f2a99a28788ca Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--test/Makefile.am.include3
-rw-r--r--test/flash_copy.c5
2 files changed, 6 insertions, 2 deletions
diff --git a/test/Makefile.am.include b/test/Makefile.am.include
index 845c13a..de1bfce 100644
--- a/test/Makefile.am.include
+++ b/test/Makefile.am.include
@@ -4,7 +4,8 @@ test_flash_copy_SOURCES = \
%reldir%/flash_copy.c \
flash.c \
common.c mtd.c \
- %reldir%/tmpf.c
+ %reldir%/tmpf.c \
+ %reldir%/system.c
test_flash_erase_SOURCES = \
%reldir%/flash_erase.c \
diff --git a/test/flash_copy.c b/test/flash_copy.c
index 08dfc1a..3b88b76 100644
--- a/test/flash_copy.c
+++ b/test/flash_copy.c
@@ -13,6 +13,7 @@
#include "mboxd.h"
#include "flash.h"
+#include "test/system.h"
#include "test/tmpf.h"
#define TEST_SIZE 4096
@@ -26,7 +27,7 @@ void cleanup(void)
int main(void)
{
- struct mbox_context context;
+ struct mbox_context context = {0};
ssize_t processed;
int rand_fd;
char *src;
@@ -35,6 +36,8 @@ int main(void)
atexit(cleanup);
+ system_set_mtd_sizes(TEST_SIZE, TEST_SIZE);
+
mbox_vlog = &mbox_log_console;
src = malloc(TEST_SIZE);
OpenPOWER on IntegriCloud