ci.jpl: Verify test status after test summary is archived

Test status should be verified after test summary is compelety generated
and archived. If there is any failed test case, an exception will be
thrown and Jenkins will be interrupted to deal with the thrown error. To
avoid test summary being lost when some test cases fail, verify test
status after test summary is archived.

Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: I192bd3caad88ca1bb50afbc977b8395693f5f032
diff --git a/jenkins/ci.jpl b/jenkins/ci.jpl
index 0fc6a62..fd6d9ff 100644
--- a/jenkins/ci.jpl
+++ b/jenkins/ci.jpl
@@ -177,19 +177,6 @@
 }
 
 def parseTestResults(output) {
-  // Verify test status
-  g = new Gerrit()
-  if (output.contains('FAILURE')) {
-    score = -1
-  } else {
-    score = 1
-  }
-  g.verifyStatus(score, "lava_test", "test")
-  if (score < 0) {
-    error("Marking job as failed due to failed tests.")
-  }
-
-  // Generate test results summary
   def test_results = [:]
   records = output.split('\nLAVA Test Config:\n')
   if (records.size() < 2) {
@@ -215,6 +202,19 @@
   return test_results
 }
 
+def verifyTestStatus(output) {
+  g = new Gerrit()
+  if (output.contains('FAILURE')) {
+    score = -1
+  } else {
+    score = 1
+  }
+  g.verifyStatus(score, "lava_test", "test")
+  if (score < 0) {
+    error("Marking job as failed due to failed tests.")
+  }
+}
+
 def generateCsvContent(results) {
   // Results format: [CONFIG_NAME: [URL: "", RESULT: "", ...]]
   // CSV format: CONFIG_NAME, RESULT
@@ -369,6 +369,7 @@
               println("--- end of output from lava_wait_jobs.py ---")
               test_results = parseTestResults(output)
               archiveArtifacts artifacts: 'test_summary.*', allowEmptyArchive: true
+              verifyTestStatus(output)
               if (env.CODE_COVERAGE_EN == "TRUE") {
                 println("Producing merged report")
                 sh(script: """./tf-m-ci-scripts/lava_helper/codecov_merge.sh""")