refactor(spm): managed exit tests

Factored out code to enable managed exit interrupt for a given SP, to
reuse it in the context of testing the Schedule Receiver Interrupt
SWd behavior, in the context of notifications feature work.

Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: Idcecd486c7a952f0842ebf90c274adcea9e30152
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c
index 80497bd..73d59bd 100644
--- a/tftf/tests/common/test_helpers.c
+++ b/tftf/tests/common/test_helpers.c
@@ -5,6 +5,7 @@
  */
 
 #include <arch_helpers.h>
+#include <cactus_test_cmds.h>
 #include <plat_topology.h>
 #include <platform.h>
 #include <power_management.h>
@@ -219,3 +220,19 @@
 
 	return TEST_RESULT_SUCCESS;
 }
+
+bool spm_set_managed_exit_int(ffa_id_t sp_id, bool enable)
+{
+	smc_ret_values ret;
+
+	ret = cactus_interrupt_cmd(HYP_ID, sp_id, MANAGED_EXIT_INTERRUPT_ID,
+				   enable, INTERRUPT_TYPE_FIQ);
+
+	if (!is_ffa_direct_response(ret) ||
+	    cactus_get_response(ret) != CACTUS_SUCCESS) {
+		ERROR("Failed to enable Managed exit interrupt\n");
+		return false;
+	}
+
+	return true;
+}
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c b/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c
index 7c70de2..c92d683 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c
@@ -69,15 +69,7 @@
 	CHECK_SPMC_TESTING_SETUP(1, 0, expected_sp_uuids);
 
 	/* Enable managed exit interrupt as FIQ in the secure side. */
-	ret_values = cactus_interrupt_cmd(SENDER, RECEIVER, MANAGED_EXIT_INTERRUPT_ID,
-					  true, INTERRUPT_TYPE_FIQ);
-
-	if (!is_ffa_direct_response(ret_values)) {
-		return TEST_RESULT_FAIL;
-	}
-
-	if (cactus_get_response(ret_values) != CACTUS_SUCCESS) {
-		ERROR("Failed to enable Managed exit interrupt\n");
+	if (!spm_set_managed_exit_int(RECEIVER, true)) {
 		return TEST_RESULT_FAIL;
 	}
 
@@ -134,15 +126,7 @@
 	}
 
 	/* Disable Managed exit interrupt */
-	ret_values = cactus_interrupt_cmd(SENDER, RECEIVER, MANAGED_EXIT_INTERRUPT_ID,
-					  false, 0);
-
-	if (!is_ffa_direct_response(ret_values)) {
-		return TEST_RESULT_FAIL;
-	}
-
-	if (cactus_get_response(ret_values) != CACTUS_SUCCESS) {
-		ERROR("Failed to disable Managed exit interrupt\n");
+	if (!spm_set_managed_exit_int(RECEIVER, false)) {
 		return TEST_RESULT_FAIL;
 	}