Add buildfailures.json

Explicitly enumerate run-tests configurations that don't build.
(because they depend on Android APIs while building for the RI)

This removes run-test build dependency on knownfailures.json.

Bug: 213297521
Test: m art-run-test-{host,target,jvm}-data
Test: test.py -b -r --host --jvm
Change-Id: Ie6886df17fedd7d31394c511187936fa36ed9a97
diff --git a/test/Android.bp b/test/Android.bp
index 87d1fef..dcf6cad 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -1852,7 +1852,7 @@
     ],
     tool_files: [
         "run-test-build.py",
-        "knownfailures.json",
+        "buildfailures.json",
         "etc/default-build",
         "etc/default-run",
         "etc/default-check",
diff --git a/test/buildfailures.json b/test/buildfailures.json
new file mode 100644
index 0000000..c926298
--- /dev/null
+++ b/test/buildfailures.json
@@ -0,0 +1,31 @@
+[
+    {
+        "description": ["The following tests don't build on RI."],
+        "tests": [
+            "004-UnsafeTest",
+            "030-bad-finalizer",
+            "122-npe",
+            "160-read-barrier-stress",
+            "178-app-image-native-method",
+            "612-jit-dex-cache",
+            "613-inlining-dex-cache",
+            "674-hiddenapi",
+            "676-resolve-field-type",
+            "689-zygote-jit-deopt",
+            "692-vdex-inmem-loader",
+            "692-vdex-secondary-loader",
+            "693-vdex-inmem-loader-evict",
+            "811-checker-invoke-super-secondary",
+            "817-hiddenapi",
+            "831-unverified-bcp",
+            "1336-short-finalizer-timeout",
+            "1339-dead-reference-safe",
+            "2005-pause-all-redefine-multithreaded",
+            "2040-huge-native-alloc",
+            "2041-bad-cleaner",
+            "2235-JdkUnsafeTest",
+            "2239-varhandle-perf"
+        ],
+        "variant": "jvm"
+    }
+]
diff --git a/test/run-test-build.py b/test/run-test-build.py
index aaee89c..03ac18f 100755
--- a/test/run-test-build.py
+++ b/test/run-test-build.py
@@ -22,7 +22,7 @@
 import argparse, os, tempfile, shutil, subprocess, glob, textwrap, re, json, concurrent.futures
 
 ZIP = "prebuilts/build-tools/linux-x86/bin/soong_zip"
-KNOWNFAILURES = json.loads(open(os.path.join("art", "test", "knownfailures.json"), "rt").read())
+BUILDFAILURES = json.loads(open(os.path.join("art", "test", "buildfailures.json"), "rt").read())
 
 def copy_sources(args, tmp, mode, srcdir):
   """Copy test files from Android tree into the build sandbox and return its path."""
@@ -32,9 +32,9 @@
   dstdir = join(tmp, mode, test)
 
   # Don't build tests that are disabled since they might not compile (e.g. on jvm).
-  def is_knownfailure(kf):
+  def is_buildfailure(kf):
     return test in kf.get("tests", []) and mode == kf.get("variant") and not kf.get("env_vars")
-  if any(is_knownfailure(kf) for kf in KNOWNFAILURES):
+  if any(is_buildfailure(kf) for kf in BUILDFAILURES):
     return None
 
   # Copy all source files to the temporary directory.
@@ -99,7 +99,7 @@
       for stdout, exitcode in pool.map(lambda dstdir: build_test(args, args.mode, dstdir), dstdirs):
         if stdout:
           print(stdout.strip())
-        assert(exitcode == 0) # Build failed.
+        assert(exitcode == 0) # Build failed. Add test to buildfailures.json if this is expected.
 
     # Create the final zip file which contains the content of the temporary directory.
     proc = subprocess.run([ZIP, "-o", args.out, "-C", tmp, "-D", tmp], check=True)