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 \
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;
// 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() {
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;
* 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;
}
/**
}
/**
- * 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) {
--- /dev/null
+/*
+ * 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());
+ }
+}
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;
testRun.setResult(Result.ERROR, e);
return;
}
- testRun.setTestClasses(testClasses);
+ testRun.setTestClasspath(testClasses);
}
/**
}
final Command command = newVmCommandBuilder()
- .classpath(testRun.getTestClasses())
+ .classpath(testRun.getTestClasspath())
.classpath(testRunnerClasses)
.classpath(getRuntimeSupportClasspath())
.userDir(testRun.getUserDir())