Per-patch: Only test on physical boards

Transfer AN521 tests from FVP to physical boards in per-patch job.
As engineers normally test patches on local FVP,
testing on physical boards in per-patch job could avoid
configs working on FVP but failing on physical boards.

Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: Ic49e6d2a641aaae3c87f9a49ad6a8e93f51bfc84
diff --git a/jenkins/lava-submit.jpl b/jenkins/lava-submit.jpl
index 65ac671..dd7d1f4 100644
--- a/jenkins/lava-submit.jpl
+++ b/jenkins/lava-submit.jpl
@@ -12,10 +12,10 @@
   return cause
 }
 
-def submitJobs(fvp_only_cmd, bl2_string, psa_string) {
+def submitJobs(device_type, bl2_string, psa_string) {
   dir("tf-m-ci-scripts") {
     def res = sh(script: """./lava_helper/lava_create_jobs.py \
-      --build-number ${env.BUILD_NUMBER} --output-dir lava_jobs ${fvp_only_cmd}\
+      --build-number ${env.BUILD_NUMBER} --output-dir lava_jobs ${device_type}\
       --compiler ${env.COMPILER} --platform ${env.TARGET_PLATFORM} \
       ${bl2_string} ${psa_string} --build-type ${env.CMAKE_BUILD_TYPE} \
       --jenkins-build-url ${env.BUILD_URL} --proj-config ${env.PROJ_CONFIG} \
@@ -40,11 +40,11 @@
       }
     }
     stage("LAVA") {
-      def fvp_only_cmd = ""
+      def device_type = ""
       def upstreamProject = getUpstreamJob()[0].upstreamProject
       if (upstreamProject == "tf-m-build-and-test") {
-        fvp_only_cmd = "--fvp-only "
-        print("Run test cases only on FVP in per-patch.")
+        device_type = "--physical-board-only "
+        print("Run test cases only on physical boards in per-patch.")
       }
 
       withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) {
@@ -59,11 +59,11 @@
           psa_string = "--psa-api-suite ${env.PSA_API_SUITE}"
         }
         try {
-          submitJobs(fvp_only_cmd, bl2_string, psa_string)
+          submitJobs(device_type, bl2_string, psa_string)
         } catch (Exception ex) {
           print("LAVA-Submit failed! Exception: ${ex}")
           print("Try to submit again...")
-          submitJobs(fvp_only_cmd, bl2_string, psa_string)
+          submitJobs(device_type, bl2_string, psa_string)
           currentBuild.setDescription(currentBuild.getDescription() + " Submitted twice!")
         }
       }
diff --git a/lava_helper/lava_create_jobs.py b/lava_helper/lava_create_jobs.py
index f5c7721..83be77d 100755
--- a/lava_helper/lava_create_jobs.py
+++ b/lava_helper/lava_create_jobs.py
@@ -207,6 +207,10 @@
         for key in config_keys:
             if "fvp" not in key:
                 config_keys.remove(key)
+    if user_args.physical_board_only:
+        for key in config_keys:
+            if "fvp" in key or "qemu" in key:
+                config_keys.remove(key)
     if user_args.config_key:
         config_keys = [user_args.config_key]
     for config_key in config_keys:
@@ -220,6 +224,7 @@
     # Parse command line arguments to override config
     parser = argparse.ArgumentParser(description="Lava Create Jobs")
     cmdargs = parser.add_argument_group("Create LAVA Jobs")
+    device_type = parser.add_mutually_exclusive_group()
 
     # Configuration control
     cmdargs.add_argument(
@@ -268,12 +273,6 @@
         help="Set the jenkins job name",
     )
     cmdargs.add_argument(
-        "--fvp-only",
-        dest="fvp_only",
-        action="store_true",
-        help="Run test cases on FVP only",
-    )
-    cmdargs.add_argument(
         "--proj-config", dest="proj_config", action="store", help="Proj config"
     )
     cmdargs.add_argument(
@@ -292,8 +291,21 @@
     cmdargs.add_argument(
         "--psa-api-suite", dest="psa_suite", action="store", help="PSA API Suite name"
     )
-    return parser.parse_args()
 
+    device_type.add_argument(
+        "--fvp-only",
+        dest="fvp_only",
+        action="store_true",
+        help="Run test cases on FVP only",
+    )
+    device_type.add_argument(
+        "--physical-board-only",
+        dest="physical_board_only",
+        action="store_true",
+        help="Run test cases on physical boards only",
+    )
+
+    return parser.parse_args()
 
 if __name__ == "__main__":
     main(get_cmd_args())