Making helper threads daemons in the jtreg runner.
Fixing a bug where we were attempting to execute errord out tests. And
renaming the testClasses to a testClasspath.
diff --git a/libcore/tools/dalvik_jtreg/Android.mk b/libcore/tools/dalvik_jtreg/Android.mk
index 50583b7..6c3cf1b 100644
--- a/libcore/tools/dalvik_jtreg/Android.mk
+++ b/libcore/tools/dalvik_jtreg/Android.mk
@@ -33,6 +33,7 @@
java/dalvik/jtreg/TestRun.java \
java/dalvik/jtreg/TestFinder.java \
java/dalvik/jtreg/TestRunner.java \
+ java/dalvik/jtreg/Threads.java \
java/dalvik/jtreg/Vm.java \
java/dalvik/jtreg/XmlReportPrinter.java \
diff --git a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Driver.java b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Driver.java
index 0f23d4d..4922051 100644
--- a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Driver.java
+++ b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Driver.java
@@ -26,7 +26,6 @@
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
@@ -89,8 +88,7 @@
// build and install tests in a background thread. Using lots of
// threads helps for packages that contain many unsupported tests
- ExecutorService builders = Executors.newFixedThreadPool(
- Runtime.getRuntime().availableProcessors());
+ ExecutorService builders = Threads.threadPerCpuExecutor();
for (final TestRun testRun : tests) {
builders.submit(new Runnable() {
public void run() {
diff --git a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/TestRun.java b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/TestRun.java
index 2cd4205..9da60c6 100644
--- a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/TestRun.java
+++ b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/TestRun.java
@@ -44,7 +44,7 @@
private final String qualifiedName;
private final String description;
- private Classpath testClasses;
+ private Classpath testClasspath;
private File userDir = new File(System.getProperty("user.dir"));
private ExpectedResult expectedResult = ExpectedResult.SUCCESS;
@@ -121,12 +121,12 @@
* Initializes the path to the jar file or directory containing test
* classes.
*/
- public void setTestClasses(Classpath classes) {
- this.testClasses = classes;
+ public void setTestClasspath(Classpath classpath) {
+ this.testClasspath = classpath;
}
- public Classpath getTestClasses() {
- return testClasses;
+ public Classpath getTestClasspath() {
+ return testClasspath;
}
/**
@@ -141,10 +141,11 @@
}
/**
- * Returns true if this test is ready for execution.
+ * Returns true if this test is ready for execution. Such tests have their
+ * classpath prepared and have not yet been assigned a result.
*/
public boolean isRunnable() {
- return testClasses != null;
+ return testClasspath != null && result == null;
}
public void setResult(Result result, Throwable e) {
diff --git a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Threads.java b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Threads.java
new file mode 100644
index 0000000..41eef67
--- /dev/null
+++ b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Threads.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dalvik.jtreg;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * Utility methods for working with threads.
+ */
+class Threads {
+
+ public static ThreadFactory daemonThreadFactory() {
+ return new ThreadFactory() {
+ public Thread newThread(Runnable r) {
+ Thread thread = new Thread(r, r.toString());
+ thread.setDaemon(true);
+ return thread;
+ }
+ };
+ }
+
+ public static ExecutorService threadPerCpuExecutor() {
+ return Executors.newFixedThreadPool(
+ Runtime.getRuntime().availableProcessors(), daemonThreadFactory());
+ }
+}
diff --git a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Vm.java b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Vm.java
index 09a75de..2685c8d 100644
--- a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Vm.java
+++ b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Vm.java
@@ -56,7 +56,8 @@
private static final Logger logger = Logger.getLogger(Vm.class.getName());
- protected final ExecutorService outputReaders = Executors.newFixedThreadPool(1);
+ protected final ExecutorService outputReaders
+ = Executors.newFixedThreadPool(1, Threads.daemonThreadFactory());
protected final Integer debugPort;
protected final long timeoutSeconds;
@@ -123,7 +124,7 @@
testRun.setResult(Result.ERROR, e);
return;
}
- testRun.setTestClasses(testClasses);
+ testRun.setTestClasspath(testClasses);
}
/**
@@ -177,7 +178,7 @@
}
final Command command = newVmCommandBuilder()
- .classpath(testRun.getTestClasses())
+ .classpath(testRun.getTestClasspath())
.classpath(testRunnerClasses)
.classpath(getRuntimeSupportClasspath())
.userDir(testRun.getUserDir())