CTS: Fix & amend VM tests

Refactor the VM tests to be slightly more maintainable and precise.
Fix errors uncovered by refactoring. Add tests for b/17207857.

Bug: 17207857, 17266951, 17264206, 17287529
Change-Id: I753c568e1417eea9582dd45c965da0dbd6ffa01b
diff --git a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
index 6f5226c..3630446 100644
--- a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
+++ b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
@@ -599,6 +599,22 @@
             entries.add(res.trim());
         }
 
+        // search for " load(\"...\" " and add as dependency
+        Pattern loadPattern = Pattern.compile("load\\(\"([^\"]*)\"", Pattern.MULTILINE);
+        Matcher loadMatcher = loadPattern.matcher(methodSource);
+        while (loadMatcher.find()) {
+            String res = loadMatcher.group(1);
+            entries.add(res.trim());
+        }
+
+        // search for " loadAndRun(\"...\" " and add as dependency
+        Pattern loadAndRunPattern = Pattern.compile("loadAndRun\\(\"([^\"]*)\"", Pattern.MULTILINE);
+        Matcher loadAndRunMatcher = loadAndRunPattern.matcher(methodSource);
+        while (loadAndRunMatcher.find()) {
+            String res = loadAndRunMatcher.group(1);
+            entries.add(res.trim());
+        }
+
         // lines with the form @uses
         // dot.junit.opcodes.add_double.jm.T_add_double_2
         // one dependency per one @uses