Move a few ART run-tests to the `presubmit` test group in `TEST_MAPPING`.

Move 1% of ART run-tests from the `postsubmit` test group to the
`presubmit` test group. This progressive rollout is to make sure
introducing ART run-tests to this test group won't disturb/break
Android presubmits.

This partly reverts commit d9a7d0abcba766114d7b64311ea3aee4a66b2154.

Test: atest --test-mapping art:presubmit
Test: atest --test-mapping art:postsubmit
Bug: 152374989
Bug: 169310621
Change-Id: I9c0388f26cb4fbce5f8c2e24c3d1cd256960880d
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 3a8c976..82bf09a 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -10,16 +10,17 @@
     // ART gtests.
     {
       "name": "ArtGtestsTarget"
-    }
-  ],
-  "postsubmit": [
+    },
     // ART run-tests.
     {
       "name": "art-run-test-001-HelloWorld"
     },
     {
       "name": "art-run-test-001-Main"
-    },
+    }
+  ],
+  "postsubmit": [
+    // ART run-tests.
     {
       "name": "art-run-test-002-sleep"
     },
@@ -384,6 +385,9 @@
       "name": "art-run-test-2030-long-running-child"
     },
     {
+      "name": "art-run-test-2037-thread-name-inherit"
+    },
+    {
       "name": "art-run-test-300-package-override"
     },
     {
diff --git a/test/utils/regen-test-files b/test/utils/regen-test-files
index 34239e4..b47aa4e 100755
--- a/test/utils/regen-test-files
+++ b/test/utils/regen-test-files
@@ -263,6 +263,12 @@
   art-run-test-997-single-step
 )
 
+# Percentage of ART run-tests (among the ones expected to succeed) to include in
+# the `presubmit` test group in `TEST_MAPPING` file -- the rest will be included
+# in `postsubmit` test group.
+# Currently, this value has to be a number between 1 and 99.
+presubmit_tests_percentage=1
+
 cd "$ANDROID_BUILD_TOP/art"
 
 tests_dir=test
@@ -349,6 +355,8 @@
 # Regenerate `TEST_MAPPING` file.
 # -------------------------------
 
+# Note: We only include ART run-tests expected to succeed for now.
+
 # Complement of `known_failing_tests` in `handled_tests`.
 declare -a expected_succeeding_tests
 for run_test in "${handled_tests[@]}"; do
@@ -367,6 +375,10 @@
 cat >TEST_MAPPING <<EOF
 // Generated by \`$me\`. Do not edit manually.
 {
+EOF
+
+# Presubmits.
+cat >>TEST_MAPPING <<EOF
   "presubmit": [
     {
       "name": "CtsJdwpTestCases"
@@ -377,14 +389,32 @@
     // ART gtests.
     {
       "name": "ArtGtestsTarget"
-    }
+    },
+    // ART run-tests.
+EOF
+num_presubmit_tests=$((${#expected_succeeding_tests[@]} * $presubmit_tests_percentage / 100))
+trailer=,
+for ((i=0; i < $num_presubmit_tests; ++i)); do
+  # Do not print a trailing comma for the last test (JSON does not allow
+  # superfluous trailing commas).
+  [[ $((i + 1)) -eq $num_presubmit_tests ]] && trailer=
+  cat >>TEST_MAPPING <<EOF
+    {
+      "name": "${expected_succeeding_tests[$i]}"
+    }$trailer
+EOF
+done
+cat >>TEST_MAPPING <<EOF
   ],
+EOF
+
+# Postsubmits.
+cat >>TEST_MAPPING <<EOF
   "postsubmit": [
     // ART run-tests.
 EOF
-# Only include tests expected to succeed for now.
 trailer=,
-for ((i=0; i < ${#expected_succeeding_tests[@]}; ++i)); do
+for ((i=$num_presubmit_tests; i < ${#expected_succeeding_tests[@]}; ++i)); do
   # Do not print a trailing comma for the last test (JSON does not allow
   # superfluous trailing commas).
   [[ $((i + 1)) -eq ${#expected_succeeding_tests[@]} ]] && trailer=
@@ -394,6 +424,7 @@
     }$trailer
 EOF
 done
+
 # Epilogue.
 cat >>TEST_MAPPING <<EOF
   ]
@@ -402,5 +433,10 @@
 
 expected_succeeding_tests_percentage=$((${#expected_succeeding_tests[@]} * 100 / num_tests))
 
+num_postsubmit_tests=$((${#expected_succeeding_tests[@]} - $num_presubmit_tests))
+postsubmit_tests_percentage=$((100 - $presubmit_tests_percentage))
+
 echo "Generated TEST_MAPPING entries for ${#expected_succeeding_tests[@]} ART run-tests ouf of" \
-  "$num_tests ($expected_succeeding_tests_percentage%)."
+  "$num_tests ($expected_succeeding_tests_percentage%):"
+echo "  $num_presubmit_tests tests ($presubmit_tests_percentage%) in \`presubmit\` test group;"
+echo "  $num_postsubmit_tests tests ($postsubmit_tests_percentage%) in \`postsubmit\` test group."