libsp: Add mock assert implementation

Assertion failures can be expected from tests and an exception-like
behavior is implemented to prevent executing code after a failed
assert.

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I0ed0951baab40a449018d61926daded2f6a970ed
diff --git a/components/messaging/ffa/libsp/test/mock_assert.cpp b/components/messaging/ffa/libsp/test/mock_assert.cpp
new file mode 100644
index 0000000..f79021a
--- /dev/null
+++ b/components/messaging/ffa/libsp/test/mock_assert.cpp
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+ */
+
+#include "mock_assert.h"
+#include <assert.h>
+#include <CppUTest/TestHarness.h>
+#include <CppUTestExt/MockSupport.h>
+
+int expect_assert(assert_environment_t *env)
+{
+	mock().expectOneCall("__assert_fail").andReturnValue(env);
+	return 0;
+}
+
+void __assert_fail(const char *assertion, const char *file, unsigned int line,
+		   const char *function)
+{
+	(void)assertion;
+	(void)file;
+	(void)line;
+	(void)function;
+
+	assert_environment_t *env = (assert_environment_t *)mock()
+					    .actualCall("__assert_fail")
+					    .returnPointerValue();
+	longjmp(*env, 1);
+}