new File("/system/framework/jsr305.jar"));
private static final Logger logger = Logger.getLogger(DeviceDalvikVm.class.getName());
- private final File runnerDir = new File("/sdcard/dalvikrunner");
- private final File testTemp = new File(runnerDir, "/tests.tmp");
+ private final File runnerDir;
+ private final File testTemp;
private final Adb adb = new Adb();
- DeviceDalvikVm(Integer debugPort, long timeoutSeconds, File sdkJar, File localTemp) {
- super(debugPort, timeoutSeconds, sdkJar, localTemp);
+ DeviceDalvikVm(Integer debugPort, long timeoutSeconds,
+ File sdkJar, File localTemp, boolean clean, String runnerDir) {
+ super(debugPort, timeoutSeconds, sdkJar, localTemp, clean);
+
+ this.runnerDir = new File(runnerDir);
+ this.testTemp = new File(this.runnerDir, "/tests.tmp");
}
@Override public void prepare() {
@Override public void shutdown() {
super.shutdown();
- adb.rm(runnerDir);
+
+ if (clean) {
+ adb.rm(runnerDir);
+ }
}
@Override public void buildAndInstall(TestRun testRun) {
@Override public void cleanup(TestRun testRun) {
super.cleanup(testRun);
- adb.rm(testClassesDirOnDevice(testRun));
+ if (clean) {
+ adb.rm(testClassesDirOnDevice(testRun));
+ }
}
private File testClassesDirOnDevice(TestRun testRun) {
private Set<File> expectationDirs = new LinkedHashSet<File>();
private File xmlReportsDirectory;
private String javaHome;
+ private boolean clean = true;
+ private String deviceRunnerDir = "/sdcard/dalvikrunner";
private List<File> testFiles = new ArrayList<File>();
private Harness() {
if ("--debug".equals(args[i])) {
debugPort = Integer.valueOf(args[++i]);
+ } else if ("--device-runner-dir".equals(args[i])) {
+ deviceRunnerDir = args[++i];
+
} else if ("--expectations".equals(args[i])) {
File expectationDir = new File(args[++i]);
if (!expectationDir.isDirectory()) {
}
expectationDirs.add(expectationDir);
- } else if ("--javaHome".equals(args[i])) {
+ } else if ("--java-home".equals(args[i])) {
javaHome = args[++i];
if (!new File(javaHome, "/bin/java").exists()) {
System.out.println("Invalid java home: " + javaHome);
return false;
}
+ } else if ("--skip-clean".equals(args[i])) {
+ clean = false;
+
} else if ("--verbose".equals(args[i])) {
Logger.getLogger("dalvik.jtreg").setLevel(Level.FINE);
System.out.println(" This port must be free both on the device and on the local");
System.out.println(" system.");
System.out.println();
+ System.out.println(" ----device-runner-dir <directory>: use the specified directory for");
+ System.out.println(" on-device temporary files and code.");
+ System.out.println(" Default is: " + deviceRunnerDir);
+ System.out.println();
System.out.println(" --expectations <directory>: use the specified directory when");
System.out.println(" looking for test expectations. The directory should include");
System.out.println(" <test>.expected files describing expected results.");
System.out.println(" Default is: " + expectationDirs);
System.out.println();
- System.out.println(" --javaHome <java_home>: execute the tests on the local workstation");
+ System.out.println(" --java-home <java_home>: execute the tests on the local workstation");
System.out.println(" using the specified java home directory. This does not impact");
System.out.println(" which javac gets used. When unset, tests are run on a device");
System.out.println(" using adb.");
System.out.println(" a release version like 1.5.");
System.out.println(" Default is: " + sdkJar);
System.out.println();
+ System.out.println(" --skip-clean: leave temporary files in their place. Useful when");
+ System.out.println(" coupled with --verbose if you'd like to manually re-run");
+ System.out.println(" commands afterwards.");
+ System.out.println();
System.out.println(" --timeout-seconds <seconds>: maximum execution time of each");
System.out.println(" test before the runner aborts it.");
System.out.println(" Default is: " + timeoutSeconds);
private void run() throws Exception {
Vm vm = javaHome != null
- ? new JavaVm(debugPort, timeoutSeconds, sdkJar, localTemp, javaHome)
- : new DeviceDalvikVm(debugPort, timeoutSeconds, sdkJar, localTemp);
+ ? new JavaVm(debugPort, timeoutSeconds, sdkJar, localTemp, javaHome, clean)
+ : new DeviceDalvikVm(debugPort, timeoutSeconds, sdkJar, localTemp,
+ clean, deviceRunnerDir);
JtregFinder jtregFinder = new JtregFinder(localTemp);
JUnitFinder jUnitFinder = new JUnitFinder();
CaliperFinder caliperFinder = new CaliperFinder();
protected final long timeoutSeconds;
protected final File sdkJar;
protected final File localTemp;
+ protected final boolean clean;
/** The path of the test runner's compiled classes */
private Classpath testRunnerClasses;
- Vm(Integer debugPort, long timeoutSeconds, File sdkJar, File localTemp) {
+ Vm(Integer debugPort, long timeoutSeconds, File sdkJar, File localTemp,
+ boolean clean) {
this.debugPort = debugPort;
this.timeoutSeconds = timeoutSeconds;
this.sdkJar = sdkJar;
this.localTemp = localTemp;
+ this.clean = clean;
}
/**
* the given test.
*/
public void cleanup(TestRun testRun) {
- logger.fine("clean " + testRun.getQualifiedName());
+ if (clean) {
+ logger.fine("clean " + testRun.getQualifiedName());
- new Command.Builder().args("rm", "-r", testClassesDir(testRun).getPath())
- .execute();
+ new Command.Builder().args("rm", "-rf", testClassesDir(testRun).getPath())
+ .execute();
+ }
}
/**