Add local CI scripts for TFM 1.0 release

These scripts are based on current CI scripts
    iot-sw/tfm-ci-scripts with commit 5acf417

Major changes:
    Add configs to build all combinations for release required
    Codebase dynamically change when build PSA suite and OTP for parallel
    Build rules for PSA DEV API/PSA FF/ARCH TEST/OTP
    Build with parallel as much at it can be on the host
    Add test PSA ARCH on AN521 FVP for PSA DEV API
    Support PSA FF/DEV API tests on AN521 FVP
    Add “Minsizerel” type support for FVP tests
    Some hard-code or temporary changes that need to refine

Change-Id: I497b97e7cc57924295321259068b333a81a8f1a6
Signed-off-by: Karl Zhang <karl.zhang@arm.com>
diff --git a/tfm_ci_pylib/fastmodel_wrapper/__init__.py b/tfm_ci_pylib/fastmodel_wrapper/__init__.py
index d59ebcc..a1fca97 100644
--- a/tfm_ci_pylib/fastmodel_wrapper/__init__.py
+++ b/tfm_ci_pylib/fastmodel_wrapper/__init__.py
@@ -18,4 +18,6 @@
 
 from .config_templates import template_default_config, \
     template_regression_config, template_coreipc_config, \
-    template_coreipctfmlevel2_config
+    template_coreipctfmlevel2_config, template_regressionipc_config, \
+    template_regressionipctfmlevel2_config, template_psaapitestipctfmlevel2_config, \
+    template_psaapitestipc_config, template_psaapitest_config
diff --git a/tfm_ci_pylib/fastmodel_wrapper/config_templates.py b/tfm_ci_pylib/fastmodel_wrapper/config_templates.py
index 2f97652..fea5b7c 100644
--- a/tfm_ci_pylib/fastmodel_wrapper/config_templates.py
+++ b/tfm_ci_pylib/fastmodel_wrapper/config_templates.py
@@ -44,6 +44,7 @@
         "config": "%(config)s",
         "platform": "%(platform)s",
         "compiler": "%(compiler)s",
+        "psa_suite": "%(psa_suite)s",
         "build_type": "%(build_type)s",
         "bootloader": "%(bootloader)s"
     }
@@ -228,3 +229,108 @@
     # Testing will stop if string is reached
     _cfg["test_end_string"] = "Secure image initializing"
     _cfg["simlimit"] = "1200"
+
+class template_psaapitestipctfmlevel2_config(template_cfg):
+    """ Will automatically populate the required information for tfm
+    coreipc tfmlevel2 configuration testing. User still needs to set the
+    buildpath, platform, compiler variants """
+
+    _cfg = deepcopy(template_cfg._cfg)
+
+    _vdict = deepcopy(template_cfg._vdict)
+
+    # Set defaults across all variants
+    _vdict["build_path"] = "build-ci-all"
+
+    _vdict["app_bin_path"] = "install/outputs/fvp"
+    _vdict["data_bin_path"] = "install/outputs/fvp"
+
+    _vdict["variant_name_tpl"] = "%(platform)s_%(compiler)s_%(config)s_" + \
+        "%(psa_suite)s_%(build_type)s_%(bootloader)s"
+
+    # Mofify the %(config)s parameter of the template
+    _vdict["config"] = "ConfigPsaApiTestIPCTfmLevel2"
+    _cfg["terminal_log"] = _cfg["terminal_log"] % _vdict
+
+    # System supports two types of matching with
+    # test_case_id and result match group and only test_case_id
+    _cfg["test_rex"] = (r'Entering standby'
+                        )
+
+    # test_case_id capture group Should match test_cases entries
+    _cfg["test_cases"] = [
+        'Secure image initializing!',
+    ]
+    # Testing will stop if string is reached
+    _cfg["test_end_string"] = "Entering standby.."
+    _cfg["simlimit"] = "1200"
+
+class template_psaapitestipc_config(template_cfg):
+    """ Will automatically populate the required information for tfm
+    coreipc tfmlevel2 configuration testing. User still needs to set the
+    buildpath, platform, compiler variants """
+
+    _cfg = deepcopy(template_cfg._cfg)
+
+    _vdict = deepcopy(template_cfg._vdict)
+
+    # Set defaults across all variants
+    _vdict["build_path"] = "build-ci-all"
+
+    _vdict["app_bin_path"] = "install/outputs/fvp"
+    _vdict["data_bin_path"] = "install/outputs/fvp"
+
+    _vdict["variant_name_tpl"] = "%(platform)s_%(compiler)s_%(config)s_" + \
+        "%(psa_suite)s_%(build_type)s_%(bootloader)s"
+
+    # Mofify the %(config)s parameter of the template
+    _vdict["config"] = "ConfigPsaApiTestIPC"
+    _cfg["terminal_log"] = _cfg["terminal_log"] % _vdict
+
+    # System supports two types of matching with
+    # test_case_id and result match group and only test_case_id
+    _cfg["test_rex"] = (r'Entering standby'
+                        )
+
+    # test_case_id capture group Should match test_cases entries
+    _cfg["test_cases"] = [
+        'Secure image initializing!',
+    ]
+    # Testing will stop if string is reached
+    _cfg["test_end_string"] = "Entering standby.."
+    _cfg["simlimit"] = "1200"
+
+class template_psaapitest_config(template_cfg):
+    """ Will automatically populate the required information for tfm
+    coreipc tfmlevel2 configuration testing. User still needs to set the
+    buildpath, platform, compiler variants """
+
+    _cfg = deepcopy(template_cfg._cfg)
+
+    _vdict = deepcopy(template_cfg._vdict)
+
+    # Set defaults across all variants
+    _vdict["build_path"] = "build-ci-all"
+
+    _vdict["app_bin_path"] = "install/outputs/fvp"
+    _vdict["data_bin_path"] = "install/outputs/fvp"
+
+    _vdict["variant_name_tpl"] = "%(platform)s_%(compiler)s_%(config)s_" + \
+        "%(psa_suite)s_%(build_type)s_%(bootloader)s"
+
+    # Mofify the %(config)s parameter of the template
+    _vdict["config"] = "ConfigPsaApiTest"
+    _cfg["terminal_log"] = _cfg["terminal_log"] % _vdict
+
+    # System supports two types of matching with
+    # test_case_id and result match group and only test_case_id
+    _cfg["test_rex"] = (r'Entering standby'
+                        )
+
+    # test_case_id capture group Should match test_cases entries
+    _cfg["test_cases"] = [
+        'Secure image initializing!',
+    ]
+    # Testing will stop if string is reached
+    _cfg["test_end_string"] = "Entering standby.."
+    _cfg["simlimit"] = "1200"
diff --git a/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper.py b/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper.py
index 7566c2e..d49cd6c 100755
--- a/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper.py
+++ b/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper.py
@@ -257,6 +257,7 @@
 
         # Convert to list
         cmd = self.compile_cmd().split(" ")
+        print("fvp cmd ", self.compile_cmd())
 
         # Run it as subproccess
         self.fvp_proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=False)
@@ -286,9 +287,10 @@
                     queue.put(line)
 
                 # If the text end string is found terminate
-                if self.test_end_string in str(line):
+                if str(line).find(self.test_end_string) > 0:
 
                     queue.put("Found End String \"%s\"" % self.test_end_string)
+                    print("Found End String \"%s\"" % self.test_end_string)
                     self.test_complete = True
                     self.stop()
                     break
@@ -344,7 +346,7 @@
             print("Could not find all binaries from %s" % ", ".join(bin_list))
             print("Missing Files:", ", ".join(find_missing_files(bin_list)))
             sys.exit(1)
-
+        self.show_cmd()
         self.pids.append(self.run_fpv())
         self.pids.append(self.run_monitor())
         print("Spawned Proccesses with PID %s" % repr(self.pids)[1:-1])
diff --git a/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper_config.py b/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper_config.py
index 0c2f60a..2180620 100644
--- a/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper_config.py
+++ b/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper_config.py
@@ -200,6 +200,25 @@
                 _cfg["application"] = _cfg["application"] % _vdict
                 _cfg["data"] = _cfg["data"] % _vdict
 
+                if _vdict["psa_suite"] == "FF":
+                    print("TfmFastModelConfig override:")
+                    _cfg["parameters"] = [
+                        "fvp_mps2.platform_type=2",
+                        "cpu0.baseline=0",
+                        "cpu0.INITVTOR_S=0x10080400",
+                        "cpu0.semihosting-enable=0",
+                        "fvp_mps2.DISABLE_GATING=0",
+                        "fvp_mps2.telnetterminal0.start_telnet=0",
+                        "fvp_mps2.telnetterminal1.start_telnet=0",
+                        "fvp_mps2.telnetterminal2.start_telnet=0",
+                        "fvp_mps2.telnetterminal0.quiet=1",
+                        "fvp_mps2.telnetterminal1.quiet=1",
+                        "fvp_mps2.telnetterminal2.quiet=1",
+                        "fvp_mps2.UART2.out_file=$TERM_FILE",
+                        "fvp_mps2.UART2.unbuffered_output=1",
+                        "fvp_mps2.UART0.shutdown_on_eot=1",
+                        "fvp_mps2.mps2_visualisation.disable-visualisation=1"]
+
                 _name = cls._name % _vdict
 
         return TfmFastModelConfig