feat: print file and line number if `expect` fails
This makes debugging a failed expect easier.
Change-Id: I53a2b3cd1866c14f3983a2e36b94707a94f12ef3
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/spm/common/sp_helpers.h b/spm/common/sp_helpers.h
index a82924b..e0e749d 100644
--- a/spm/common/sp_helpers.h
+++ b/spm/common/sp_helpers.h
@@ -51,7 +51,20 @@
* Check that expr == expected.
* If not, loop forever.
*/
-void expect(int expr, int expected);
+#define EXPECT(lhs, rhs) \
+ do { \
+ int lhs_value = (lhs); \
+ int rhs_value = (rhs); \
+ if (lhs_value != rhs_value) { \
+ ERROR("%s:%d: Assertion failed: `%s == %s`\n", \
+ __FILE__, __LINE__, #lhs, #rhs); \
+ ERROR("lhs = %d (0x%x)\n", lhs_value, lhs_value); \
+ ERROR("rhs = %d (0x%x)\n", rhs_value, rhs_value); \
+ while (1) { \
+ continue; \
+ } \
+ } \
+ } while (0)
/*
* Test framework functions