Enable LAVA test jobs submission for STM32L562E-DK board

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: I317d87c6b0787b03f203f09d7ac20bfea71e2218
diff --git a/build_helper/build_helper_configs.py b/build_helper/build_helper_configs.py
index 0b617b1..8b69480 100755
--- a/build_helper/build_helper_configs.py
+++ b/build_helper/build_helper_configs.py
@@ -99,10 +99,9 @@
                    "stm/stm32l562e_dk": [("echo 'STM32L562E-DK board post process';"
                                           "%(_tbm_build_dir_)s/postbuild.sh;"
                                           "pushd %(_tbm_build_dir_)s;"
-                                          "sed 's/^echo/#echo/; s/.*\$BINPATH/echo $BINPATH/; s/ -v//' TFM_UPDATE.sh > fwlayout.sh;"
-                                          "chmod a+x fwlayout.sh;"
-                                          "./fwlayout.sh | sed s:%(_tbm_build_dir_)s/:: | tee ./bin/layout.txt;"
-                                          "awk '{print $1}' bin/layout.txt | xargs tar jcf ./bin/stm32l562e-dk-tfm.tar.bz2; popd")]
+                                          "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")]
                    },
 
     # (Optional) If set will fail if those artefacts are missing post build
diff --git a/lava_helper/jinja2_templates/stm32l562e_dk.jinja2 b/lava_helper/jinja2_templates/stm32l562e_dk.jinja2
new file mode 100644
index 0000000..80a6ba8
--- /dev/null
+++ b/lava_helper/jinja2_templates/stm32l562e_dk.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: musca
+
+    - 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_create_jobs.py b/lava_helper/lava_create_jobs.py
index 3fd75cc..f5c7721 100755
--- a/lava_helper/lava_create_jobs.py
+++ b/lava_helper/lava_create_jobs.py
@@ -144,6 +144,11 @@
                                     params,
                                     test_dict.get("binaries").get("firmware"),
                                 ),
+                                "tarball_url": get_artifact_url(
+                                    artifact_store_url,
+                                    params,
+                                    test_dict.get("binaries").get("tarball"),
+                                ),
                             }
                         )
                         params.update(
diff --git a/lava_helper/lava_helper_configs.py b/lava_helper/lava_helper_configs.py
index e5a81cd..c8aee13 100644
--- a/lava_helper/lava_helper_configs.py
+++ b/lava_helper/lava_helper_configs.py
@@ -2821,6 +2821,130 @@
     },
 }
 
+# STM32L562E-DK
+stm32l562e_dk = {
+    "templ": "stm32l562e_dk.jinja2",
+    "job_name": "stm32l562e_dk",
+    "device_type": "stm32l562e-dk",
+    "job_timeout": 24,
+    "action_timeout": 15,
+    "monitor_timeout": 15,
+    "poweroff_timeout": 5,
+    "platforms": {"stm32l562e_dk": ""},
+    "compilers": ["GNUARM", "ARMCLANG"],
+    "build_types": ["Release", "Minsizerel"],
+    "boot_types": ["BL2"],
+    "tests": {
+        "Regression": {
+            "binaries": {
+                "tarball": "stm32l562e-dk-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
+        },
+        "RegressionIPC": {
+            "binaries": {
+                "tarball": "stm32l562e-dk-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
+        },
+        "RegressionIPCTfmLevel2": {
+            "binaries": {
+                "tarball": "stm32l562e-dk-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
+        },
+        "RegressionIPCTfmLevel3": {
+            "binaries": {
+                "tarball": "stm32l562e-dk-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 = {
@@ -2832,6 +2956,7 @@
     "qemu_mps2_bl2": qemu_mps2_bl2,
     "musca_b1": musca_b1_bl2,
     "musca_b1_otp": musca_b1_otp_bl2,
+    "stm32l562e_dk": stm32l562e_dk,
 }
 
 lavagen_config_sort_order = [