Unit-test FFA_YIELD ABI

Change-Id: I068c18f25514c777c3480fbad5b2424ae99aee53
Signed-off-by: Gabor Toth <gabor.toth2@arm.com>
diff --git a/components/messaging/ffa/libsp/mock/mock_ffa_api.cpp b/components/messaging/ffa/libsp/mock/mock_ffa_api.cpp
index f3cd0f5..b18731d 100644
--- a/components/messaging/ffa/libsp/mock/mock_ffa_api.cpp
+++ b/components/messaging/ffa/libsp/mock/mock_ffa_api.cpp
@@ -166,6 +166,19 @@
 		.returnIntValue();
 }
 
+void expect_ffa_yield(ffa_result result)
+{
+	mock().expectOneCall("ffa_yield")
+		.andReturnValue(result);
+}
+
+ffa_result ffa_yield(void)
+{
+	return mock()
+		.actualCall("ffa_yield")
+		.returnIntValue();
+}
+
 void expect_ffa_msg_send_direct_req_32(uint16_t source, uint16_t dest,
 				       uint32_t a0, uint32_t a1, uint32_t a2,
 				       uint32_t a3, uint32_t a4,
diff --git a/components/messaging/ffa/libsp/mock/mock_ffa_api.h b/components/messaging/ffa/libsp/mock/mock_ffa_api.h
index 10dafcd..9e43c13 100644
--- a/components/messaging/ffa/libsp/mock/mock_ffa_api.h
+++ b/components/messaging/ffa/libsp/mock/mock_ffa_api.h
@@ -36,6 +36,8 @@
 
 void expect_ffa_msg_wait(const struct ffa_direct_msg *msg, ffa_result result);
 
+void expect_ffa_yield(ffa_result result);
+
 void expect_ffa_msg_send_direct_req_32(uint16_t source, uint16_t dest,
 				       uint32_t a0, uint32_t a1, uint32_t a2,
 				       uint32_t a3, uint32_t a4,
diff --git a/components/messaging/ffa/libsp/mock/mock_sp_messaging.cpp b/components/messaging/ffa/libsp/mock/mock_sp_messaging.cpp
index 522abb3..d497cc6 100644
--- a/components/messaging/ffa/libsp/mock/mock_sp_messaging.cpp
+++ b/components/messaging/ffa/libsp/mock/mock_sp_messaging.cpp
@@ -22,6 +22,20 @@
 		.returnIntValue();
 }
 
+void expect_sp_yield(sp_result result)
+{
+	mock()
+		.expectOneCall("sp_yield")
+		.andReturnValue(result);
+}
+
+sp_result sp_yield(void)
+{
+	return mock()
+		.actualCall("sp_yield")
+		.returnIntValue();
+}
+
 void expect_sp_msg_send_direct_req(const struct sp_msg *req,
 				   const struct sp_msg *resp,
 				   sp_result result)
diff --git a/components/messaging/ffa/libsp/mock/mock_sp_messaging.h b/components/messaging/ffa/libsp/mock/mock_sp_messaging.h
index 8183012..35bd390 100644
--- a/components/messaging/ffa/libsp/mock/mock_sp_messaging.h
+++ b/components/messaging/ffa/libsp/mock/mock_sp_messaging.h
@@ -16,6 +16,7 @@
 
 void expect_sp_msg_wait(const struct sp_msg *msg, sp_result result);
 
+void expect_sp_yield(sp_result result);
 
 void expect_sp_msg_send_direct_req(const struct sp_msg *req,
 				   const struct sp_msg *resp,
diff --git a/components/messaging/ffa/libsp/mock/test/test_mock_ffa_api.cpp b/components/messaging/ffa/libsp/mock/test/test_mock_ffa_api.cpp
index f85c816..4405712 100644
--- a/components/messaging/ffa/libsp/mock/test/test_mock_ffa_api.cpp
+++ b/components/messaging/ffa/libsp/mock/test/test_mock_ffa_api.cpp
@@ -124,6 +124,12 @@
 	MEMCMP_EQUAL(&expected_msg, &msg, sizeof(expected_msg));
 }
 
+TEST(mock_ffa_api, ffa_yield)
+{
+	expect_ffa_yield(result);
+	LONGS_EQUAL(result, ffa_yield());
+}
+
 TEST(mock_ffa_api, ffa_msg_send_direct_req_32)
 {
 	const uint16_t source = 0x1122;
diff --git a/components/messaging/ffa/libsp/mock/test/test_mock_sp_messaging.cpp b/components/messaging/ffa/libsp/mock/test/test_mock_sp_messaging.cpp
index 02d12a6..7081414 100644
--- a/components/messaging/ffa/libsp/mock/test/test_mock_sp_messaging.cpp
+++ b/components/messaging/ffa/libsp/mock/test/test_mock_sp_messaging.cpp
@@ -49,6 +49,12 @@
 	MEMCMP_EQUAL(&expected_req, &req, sizeof(expected_req));
 }
 
+TEST(mock_sp_messaging, sp_yield)
+{
+	expect_sp_yield(result);
+	LONGS_EQUAL(result, sp_yield());
+}
+
 TEST(mock_sp_messaging, sp_msg_send_direct_req)
 {
 	req = expected_req;
diff --git a/components/messaging/ffa/libsp/test/test_ffa_api.cpp b/components/messaging/ffa/libsp/test/test_ffa_api.cpp
index 290bed4..c7c26fe 100644
--- a/components/messaging/ffa/libsp/test/test_ffa_api.cpp
+++ b/components/messaging/ffa/libsp/test/test_ffa_api.cpp
@@ -494,6 +494,22 @@
 	msg_equal_32(0, 0, 0, 0, 0, 0, 0, 0);
 }
 
+TEST(ffa_api, ffa_yield_success)
+{
+	svc_result.a0 = 0x8400006D;
+	expect_ffa_svc(0x8400006C, 0, 0, 0, 0, 0, 0, 0, &svc_result);
+	ffa_result result = ffa_yield();
+	LONGS_EQUAL(0, result);
+}
+
+TEST(ffa_api, ffa_yield_error)
+{
+	setup_error_response(-1);
+	expect_ffa_svc(0x8400006C, 0, 0, 0, 0, 0, 0, 0, &svc_result);
+	ffa_result result = ffa_yield();
+	LONGS_EQUAL(-1, result);
+}
+
 TEST(ffa_api, ffa_msg_wait_direct_req_32)
 {
 	const uint16_t source_id = 0x1122;
diff --git a/components/messaging/ffa/libsp/test/test_sp_messaging.cpp b/components/messaging/ffa/libsp/test/test_sp_messaging.cpp
index 15aba01..e3cd3b9 100644
--- a/components/messaging/ffa/libsp/test/test_sp_messaging.cpp
+++ b/components/messaging/ffa/libsp/test/test_sp_messaging.cpp
@@ -177,6 +177,22 @@
 	ffa_and_sp_msg_equal(&ffa_msg, &req);
 }
 
+TEST(sp_messaging, sp_yield_ffa_error)
+{
+	ffa_result result = FFA_ABORTED;
+
+	expect_ffa_yield(result);
+
+	LONGS_EQUAL(SP_RESULT_FFA(result), sp_yield());
+}
+
+TEST(sp_messaging, sp_yield)
+{
+	expect_ffa_yield(FFA_OK);
+
+	LONGS_EQUAL(SP_RESULT_OK, sp_yield());
+}
+
 #if FFA_DIRECT_MSG_ROUTING_EXTENSION
 TEST(sp_messaging, sp_msg_wait_deny_rc_failure)
 {