BL2: Add BL2 test code
Change-Id: I96f781b5de80e4a20121c596b1790259e98173f3
Signed-off-by: Raef Coles <raef.coles@arm.com>
diff --git a/bl2/ext/mcuboot/bl2_main.c b/bl2/ext/mcuboot/bl2_main.c
index 1674e13..aa347a0 100644
--- a/bl2/ext/mcuboot/bl2_main.c
+++ b/bl2/ext/mcuboot/bl2_main.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
- * Copyright (c) 2017-2021 Arm Limited.
+ * Copyright (c) 2017-2022 Arm Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,9 @@
#include "uart_stdout.h"
#include "tfm_plat_otp.h"
#include "tfm_plat_provisioning.h"
+#ifdef TEST_BL2
+#include "mcuboot_suites.h"
+#endif /* TEST_BL2 */
/* Avoids the semihosting issue */
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
@@ -73,7 +76,7 @@
rsp->br_hdr->ih_hdr_size);
}
-#if MCUBOOT_LOG_LEVEL > MCUBOOT_LOG_LEVEL_OFF
+#if MCUBOOT_LOG_LEVEL > MCUBOOT_LOG_LEVEL_OFF || TEST_BL2
stdio_uninit();
#endif
@@ -94,7 +97,7 @@
*/
mbedtls_memory_buffer_alloc_init(mbedtls_mem_buf, BL2_MBEDTLS_MEM_BUF_LEN);
-#if MCUBOOT_LOG_LEVEL > MCUBOOT_LOG_LEVEL_OFF
+#if MCUBOOT_LOG_LEVEL > MCUBOOT_LOG_LEVEL_OFF || TEST_BL2
stdio_init();
#endif
@@ -128,6 +131,12 @@
FIH_PANIC;
}
+#ifdef TEST_BL2
+ if (run_mcuboot_testsuite() != TEST_SUITE_ERR_NO_ERROR) {
+ FIH_PANIC;
+ }
+#endif /* TEST_BL2 */
+
FIH_CALL(boot_go, fih_rc, &rsp);
if (fih_not_eq(fih_rc, FIH_SUCCESS)) {
BOOT_LOG_ERR("Unable to find bootable image");