test(interrupts): check if last service interrupt is Trusted Wdog timer

This patch adds checks to ensure the secure virtual interrupt signaled
to the SP by SPMC, when a trusted watchdog timer fired, was indeed
handled by Cactus SP.

It leverages the helper API introduced in the previous patches. The
robust checks done at the end of each test are no longer needed.

Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: Ib0d6b63f8fdd180ef82c75c6d73a39883909e69e
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_secure_interrupts.c b/tftf/tests/runtime_services/secure_service/test_ffa_secure_interrupts.c
index ce9c809..8ed590a 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_secure_interrupts.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_secure_interrupts.c
@@ -83,11 +83,11 @@
  * 9. We make sure the time elapsed in the sleep routine by SP is not less than
  *    the requested value.
  *
- * 10. For robustness of state transition checks, TFTF sends echo command using
- *    a direct request message.
+ * 10. TFTF sends a direct request message to SP to query the ID of last serviced
+ *     secure virtual interrupt.
  *
- * 11. Further, TFTF expects SP to return with a success value through a direct
- *    response message.
+ * 11. Further, TFTF expects SP to return the ID of Trusted Watchdog timer
+ *     interrupt through a direct response message.
  *
  * 12. Test finishes successfully once the TFTF disables the trusted watchdog
  *     interrupt through a direct message request command.
@@ -124,7 +124,7 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	INFO("Secure interrupt has preempted execution: %u\n",
+	VERBOSE("Secure interrupt has preempted execution: %u\n",
 					cactus_get_response(ret_values));
 
 	/* Make sure elapsed time not less than sleep time */
@@ -133,16 +133,18 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	ret_values = cactus_echo_send_cmd(SENDER, RECEIVER, ECHO_VAL1);
+	/* Check for the last serviced secure virtual interrupt. */
+	ret_values = cactus_get_last_interrupt_cmd(SENDER, RECEIVER);
 
 	if (!is_ffa_direct_response(ret_values)) {
-		ERROR("Expected direct response for echo command\n");
+		ERROR("Expected a direct response for last serviced interrupt"
+			" command\n");
 		return TEST_RESULT_FAIL;
 	}
 
-	if (cactus_get_response(ret_values) != CACTUS_SUCCESS ||
-	    cactus_echo_get_val(ret_values) != ECHO_VAL1) {
-		ERROR("Echo Failed!\n");
+	/* Make sure Trusted Watchdog timer interrupt was serviced*/
+	if (cactus_get_response(ret_values) != IRQ_TWDOG_INTID) {
+		ERROR("Trusted watchdog timer interrupt not serviced by SP\n");
 		return TEST_RESULT_FAIL;
 	}
 
@@ -183,11 +185,11 @@
  * 9. We make sure the time elapsed in the sleep routine is not less than
  *    the requested value.
  *
- * 10. For robustness of state transition checks, TFTF sends echo command using
- *    a direct request message.
+ * 10. TFTF sends a direct request message to SP to query the ID of last serviced
+ *     secure virtual interrupt.
  *
- * 11. Further, TFTF expects SP to return with a success value through a direct
- *    response message.
+ * 11. Further, TFTF expects SP to return the ID of Trusted Watchdog timer
+ *     interrupt through a direct response message.
  *
  * 12. Test finishes successfully once the TFTF disables the trusted watchdog
  *     interrupt through a direct message request command.
@@ -235,16 +237,18 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	ret_values = cactus_echo_send_cmd(SENDER, RECEIVER, ECHO_VAL1);
+	/* Check for the last serviced secure virtual interrupt. */
+	ret_values = cactus_get_last_interrupt_cmd(SENDER, RECEIVER);
 
 	if (!is_ffa_direct_response(ret_values)) {
-		ERROR("Expected direct response for echo command\n");
+		ERROR("Expected a direct response for last serviced interrupt"
+			" command\n");
 		return TEST_RESULT_FAIL;
 	}
 
-	if (cactus_get_response(ret_values) != CACTUS_SUCCESS ||
-	    cactus_echo_get_val(ret_values) != ECHO_VAL1) {
-		ERROR("Echo Failed!\n");
+	/* Make sure Trusted Watchdog timer interrupt was serviced*/
+	if (cactus_get_response(ret_values) != IRQ_TWDOG_INTID) {
+		ERROR("Trusted watchdog timer interrupt not serviced by SP\n");
 		return TEST_RESULT_FAIL;
 	}
 
@@ -284,11 +288,11 @@
  * 8. First SP checks for the elapsed time and sends a direct response with
  *    a SUCCESS value back to tftf.
  *
- * 9. For robustness of state transition checks, TFTF sends echo command using
- *    a direct request message to first SP.
+ * 9. TFTF sends a direct request message to SP to query the ID of last serviced
+ *    secure virtual interrupt.
  *
- * 10. Further, TFTF expects SP to return with a success value through a direct
- *    response message.
+ * 10. Further, TFTF expects SP to return the ID of Trusted Watchdog timer
+ *     interrupt through a direct response message.
  *
  * 11. Test finishes successfully once the TFTF disables the trusted watchdog
  *     interrupt through a direct message request command.
@@ -331,16 +335,18 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	ret_values = cactus_echo_send_cmd(SENDER, RECEIVER, ECHO_VAL1);
+	/* Check for the last serviced secure virtual interrupt. */
+	ret_values = cactus_get_last_interrupt_cmd(SENDER, RECEIVER);
 
 	if (!is_ffa_direct_response(ret_values)) {
-		ERROR("Expected direct response for echo command\n");
+		ERROR("Expected a direct response for last serviced interrupt"
+			" command\n");
 		return TEST_RESULT_FAIL;
 	}
 
-	if (cactus_get_response(ret_values) != CACTUS_SUCCESS ||
-	    cactus_echo_get_val(ret_values) != ECHO_VAL1) {
-		ERROR("Echo Failed!\n");
+	/* Make sure Trusted Watchdog timer interrupt was serviced*/
+	if (cactus_get_response(ret_values) != IRQ_TWDOG_INTID) {
+		ERROR("Trusted watchdog timer interrupt not serviced by SP\n");
 		return TEST_RESULT_FAIL;
 	}
 
@@ -382,11 +388,11 @@
  * 9. We make sure the time elapsed in the sleep routine by SP is not less than
  *    the requested value.
  *
- * 10. For robustness of state transition checks, TFTF sends echo command using
- *    a direct request message to both SPs.
+ * 10. TFTF sends a direct request message to SP to query the ID of last serviced
+ *     secure virtual interrupt.
  *
- * 11. Further, TFTF expects SP to return with a success value through a direct
- *    response message.
+ * 11. Further, TFTF expects SP to return the ID of Trusted Watchdog timer
+ *     interrupt through a direct response message.
  *
  * 12. Test finishes successfully once the TFTF disables the trusted watchdog
  *     interrupt through a direct message request command.
@@ -426,29 +432,18 @@
 		ERROR("Lapsed time less than requested sleep time\n");
 	}
 
-	ret_values = cactus_echo_send_cmd(SENDER, RECEIVER, ECHO_VAL1);
+	/* Check for the last serviced secure virtual interrupt. */
+	ret_values = cactus_get_last_interrupt_cmd(SENDER, RECEIVER);
 
 	if (!is_ffa_direct_response(ret_values)) {
-		ERROR("Echo to SP1 Failed no response!\n");
+		ERROR("Expected a direct response for last serviced interrupt"
+			" command\n");
 		return TEST_RESULT_FAIL;
 	}
 
-	if (cactus_get_response(ret_values) != CACTUS_SUCCESS ||
-	    cactus_echo_get_val(ret_values) != ECHO_VAL1) {
-		ERROR("Echo to SP1 Failed!\n");
-		return TEST_RESULT_FAIL;
-	}
-
-	ret_values = cactus_echo_send_cmd(SENDER, RECEIVER_2, ECHO_VAL1);
-
-	if (!is_ffa_direct_response(ret_values)) {
-		ERROR("Echo to SP2 Failed no response!\n");
-		return TEST_RESULT_FAIL;
-	}
-
-	if (cactus_get_response(ret_values) != CACTUS_SUCCESS ||
-	    cactus_echo_get_val(ret_values) != ECHO_VAL1) {
-		ERROR("Echo to SP2 Failed!\n");
+	/* Make sure Trusted Watchdog timer interrupt was serviced*/
+	if (cactus_get_response(ret_values) != IRQ_TWDOG_INTID) {
+		ERROR("Trusted watchdog timer interrupt not serviced by SP\n");
 		return TEST_RESULT_FAIL;
 	}