LAVA: Enable LAVA test job submission for NXP lpcxpresso55s69 platform

Enable LAVA test job submission for NXP lpcxpresso55s69 platform

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: I38091028bdfd258fc4d8febf4828fc3e91e4ab3b
diff --git a/build_helper/build_helper_configs.py b/build_helper/build_helper_configs.py
index 6e76fd4..ab9c722 100755
--- a/build_helper/build_helper_configs.py
+++ b/build_helper/build_helper_configs.py
@@ -105,7 +105,17 @@
                                           "pushd %(_tbm_build_dir_)s;"
                                           "BIN_FILES=$(grep -o '\/.*\.bin' TFM_UPDATE.sh | sed 's/^/bin/');"
                                           "tar jcf ./bin/stm32l562e-dk-tfm.tar.bz2 regression.sh TFM_UPDATE.sh ${BIN_FILES};"
-                                          "popd")]
+                                          "popd")],
+                   "nxp/lpcxpresso55s69": [("echo 'LPCXpresso55S69 board post process\n';"
+                                            "if [ -f \"%(_tbm_build_dir_)s/bin/bl2.hex\" ]; then FLASH_FILE='flash_bl2_JLink.py'; else FLASH_FILE='flash_JLink.py'; fi;"
+                                            "pushd %(_tbm_build_dir_)s/../platform/ext/target/nxp/lpcxpresso55s69/scripts;"
+                                            "LN=$(grep -n 'JLinkExe' ${FLASH_FILE}|awk -F: '{print $1}');"
+                                            "sed -i \"${LN}s/.*/    print('flash.jlink generated')/\" ${FLASH_FILE};"
+                                            "python3 ./${FLASH_FILE};"
+                                            "cd %(_tbm_build_dir_)s/bin;"
+                                            "BIN_FILES=$(grep loadfile flash.jlink | awk '{print $2}');"
+                                            "tar jcf lpcxpresso55s69-tfm.tar.bz2 flash.jlink ${BIN_FILES};"
+                                            "popd")]
                    },
 
     # (Optional) If set will fail if those artefacts are missing post build
diff --git a/jenkins/ci.jpl b/jenkins/ci.jpl
index 4a601af..836b99b 100644
--- a/jenkins/ci.jpl
+++ b/jenkins/ci.jpl
@@ -216,36 +216,39 @@
     // Configs with build failure do not need LAVA tests
     if (build_res.result in failure_states) {
       error("Build failed at ${build_url}")
-    }
-    // Configs without BL2 do not need LAVA tests
-    else if (params_collection["BL2"] == "False") {
-      print("LAVA is not needed for ${build_url}")
-    }
-    // Configs without building NS app do not need LAVA tests
-    else if (params_collection["NS"] == "False") {
-      print("LAVA is not needed for ${build_url}")
-    }
-    // LAVA tests on MUSCA_B1 are not needed in per-patch job
-    else if (params_collection["TFM_PLATFORM"].contains("musca_b1") && \
-             env.JOB_NAME.equals("tf-m-build-and-test")) {
-      print("LAVA is not needed for ${build_url}")
-    }
-    // Only submit LAVA test for a specified OTP enabled config in nightly or release job
-    else if (params_collection["OTP"] == "ENABLED" && \
-             params_collection["CONFIG_NAME"] != "MUSCA_B1_GNUARM_PSA_3_REG_Debug_OTP_BL2_NS") {
-      print("LAVA is not needed for ${build_url}")
-    }
-    else if (params_collection["CONFIG_NAME"] == "MUSCA_B1_GNUARM_PSA_3_REG_Debug_OTP_BL2_NS" && \
-             !(env.JOB_NAME.equals("tf-m-nightly") || env.JOB_NAME.equals("tf-m-release"))) {
-      print("LAVA is not needed for ${build_url}")
-    }
-    else if (env.JOB_NAME.equals("tf-m-extra-build")) {
-      print("LAVA is not needed in tf-m-extra-build job.")
-    }
-
-    // Submit LAVA tests
-    else {
-      submit_lava_tests(config, results, build_res, params, params_collection)
+    } else {
+        // Build successful
+        // Submit test job for NXP LPCXpresso55S69
+        if (params_collection["TFM_PLATFORM"].contains("lpcxpresso55s69")) {
+          submit_lava_tests(config, results, build_res, params, params_collection)
+        } else {
+            // Configs without BL2 do not need LAVA tests
+            if (params_collection["BL2"] == "False") {
+              print("LAVA is not needed for ${build_url}")
+            }
+            // Configs without building NS app do not need LAVA tests
+            else if (params_collection["NS"] == "False") {
+              print("LAVA is not needed for ${build_url}")
+            }
+            // LAVA tests on MUSCA_B1 are not needed in per-patch job
+            else if (params_collection["TFM_PLATFORM"].contains("musca_b1") && \
+                     env.JOB_NAME.equals("tf-m-build-and-test")) {
+              print("LAVA is not needed for ${build_url}")
+            }
+            // Only submit LAVA test for a specified OTP enabled config in nightly or release job
+            else if (params_collection["OTP"] == "ENABLED" && \
+                     params_collection["CONFIG_NAME"] != "MUSCA_B1_GNUARM_PSA_3_REG_Debug_OTP_BL2_NS") {
+              print("LAVA is not needed for ${build_url}")
+            }
+            else if (params_collection["CONFIG_NAME"] == "MUSCA_B1_GNUARM_PSA_3_REG_Debug_OTP_BL2_NS" && \
+                     !(env.JOB_NAME.equals("tf-m-nightly") || env.JOB_NAME.equals("tf-m-release"))) {
+              print("LAVA is not needed for ${build_url}")
+            }
+            // Submit LAVA tests
+            else {
+              submit_lava_tests(config, results, build_res, params, params_collection)
+            }
+        }
     }
   }
 }
diff --git a/lava_helper/jinja2_templates/lpcxpresso55s69.jinja2 b/lava_helper/jinja2_templates/lpcxpresso55s69.jinja2
new file mode 100644
index 0000000..f7f6a03
--- /dev/null
+++ b/lava_helper/jinja2_templates/lpcxpresso55s69.jinja2
@@ -0,0 +1,44 @@
+{#------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-----------------------------------------------------------------------------#}
+{% extends 'jinja2_templates/base.jinja2' %}
+{% block actions %}
+actions:
+    - deploy:
+        timeout:
+          minutes: 12
+        to: flasher
+        images:
+          tarball:
+            url: {{ tarball_url }}
+
+    - boot:
+        method: minimal
+
+    - test:
+        monitors:
+        {%- for monitor in test.monitors %}
+        - name: "{{monitor.name}}"
+          start: "{{monitor.start}}"
+          end: "{{monitor.end}}"
+          pattern: "{{monitor.pattern}}"
+          fixupdict:
+              '{{monitor.fixup.pass}}': pass
+              '{{monitor.fixup.fail}}': fail
+        {% endfor %}
+{% endblock %}
+
+{% block metadata %}
+metadata:
+  build_no: {{ build_no }}
+  compiler: {{ compiler }}
+  build_type: {{ build_type }}
+  boot_type: {{ boot_type }}
+  name: {{ name }}
+  platform: {{ platform }}
+  build_name: {{ build_name }}
+  build_job_url: {{ build_job_url }}
+{% endblock %}
diff --git a/lava_helper/lava_helper_configs.py b/lava_helper/lava_helper_configs.py
index 58dcde7..0e97786 100644
--- a/lava_helper/lava_helper_configs.py
+++ b/lava_helper/lava_helper_configs.py
@@ -3373,6 +3373,64 @@
     },
 }
 
+# LPCxpresso55S69
+lpcxpresso55s69 = {
+    "templ": "lpcxpresso55s69.jinja2",
+    "job_name": "lpcxpresso55s69",
+    "device_type": "lpcxpresso55s69",
+    "job_timeout": 24,
+    "action_timeout": 15,
+    "monitor_timeout": 15,
+    "poweroff_timeout": 5,
+    "platforms": {"lpcxpresso55s69": ""},
+    "compilers": ["GNUARM"],
+    "build_types": ["Relwithdebinfo"],
+    "boot_types": ["NOBL2"],
+    "tests": {
+        "DefaultProfileM": {
+            "binaries": {
+                "tarball": "lpcxpresso55s69-tfm.tar.bz2",
+            },
+            "monitors": [
+                {
+                    'name': 'Secure_Test_Suites_Summary',
+                    'start': 'Non-Secure system',
+                    'end': r'starting\\.{3}',
+                    'pattern': r'Non-Secure system starting\\.{3}',
+                    'fixup': {"pass": "!", "fail": ""},
+                }
+            ]  # Monitors
+        },
+        "RegressionProfileM": {
+            "binaries": {
+                "tarball": "lpcxpresso55s69-tfm.tar.bz2",
+            },
+            "monitors": [
+                {
+                    'name': 'Secure_Test_Suites_Summary',
+                    'start': 'Secure test suites summary',
+                    'end': 'End of Secure test suites',
+                    'pattern': r"Test suite '(?P<"
+                               r"test_case_id>[^\n]+)' has(.*) "
+                               r"(?P<result>PASSED|FAILED)",
+                    'fixup': {"pass": "PASSED", "fail": "FAILED"},
+                    'required': ["secure_image_initializing"]
+                },
+                {
+                    'name': 'Non_Secure_Test_Suites_Summary',
+                    'start': 'Non-secure test suites summary',
+                    'end': 'End of Non-secure test suites',
+                    'pattern': r"Test suite '(?P<"
+                               r"test_case_id>[^\n]+)' has(.*) "
+                               r"(?P<result>PASSED|FAILED)",
+                    'fixup': {"pass": "PASSED", "fail": "FAILED"},
+                    'required': ["secure_image_initializing"]
+                }
+            ]  # Monitors
+        },
+    }
+}
+
 # All configurations should be mapped here
 lava_gen_config_map = {
     "mps2_an521_bl2": tfm_mps2_sse_200,
@@ -3384,6 +3442,7 @@
     "musca_b1": musca_b1_bl2,
     "musca_b1_otp": musca_b1_otp_bl2,
     "stm32l562e_dk": stm32l562e_dk,
+    "lpcxpresso55s69": lpcxpresso55s69,
 }
 
 lavagen_config_sort_order = [