Fix assert abstraction in sim
Assertions that are expected to fail under sim test, are now marked as such
using the macro ASSERT which allows to programmatically switch between normal
assert() behavior and captured assertion.
Assertion changes were moved to more appropriate owners and code duplication
was removed.
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/sim/mcuboot-sys/build.rs b/sim/mcuboot-sys/build.rs
index 5f5eeac..ebff3c5 100644
--- a/sim/mcuboot-sys/build.rs
+++ b/sim/mcuboot-sys/build.rs
@@ -81,6 +81,7 @@
conf.file("csupport/run.c");
conf.include("../../boot/bootutil/include");
conf.include("../../boot/zephyr/include");
+ conf.include("csupport");
conf.debug(true);
conf.flag("-Wall");
conf.flag("-Werror");
diff --git a/sim/mcuboot-sys/csupport/bootsim.h b/sim/mcuboot-sys/csupport/bootsim.h
new file mode 100644
index 0000000..f3fc5e4
--- /dev/null
+++ b/sim/mcuboot-sys/csupport/bootsim.h
@@ -0,0 +1,7 @@
+#ifndef H_BOOTSIM_
+#define H_BOOTSIM_
+
+void sim_assert(int, const char *test, const char *, unsigned int, const char *);
+#define ASSERT(x) sim_assert((x), #x, __FILE__, __LINE__, __func__)
+
+#endif
diff --git a/sim/mcuboot-sys/csupport/run.c b/sim/mcuboot-sys/csupport/run.c
index 91d779a..9b5e36e 100644
--- a/sim/mcuboot-sys/csupport/run.c
+++ b/sim/mcuboot-sys/csupport/run.c
@@ -10,6 +10,7 @@
#include "flash_map/flash_map.h"
#include "../../../boot/bootutil/src/bootutil_priv.h"
+#include "bootsim.h"
#ifdef MCUBOOT_SIGN_EC256
#include "../../../ext/tinycrypt/lib/include/tinycrypt/ecc_dsa.h"