From: Jesse Wilson Date: Fri, 18 Dec 2009 02:10:17 +0000 (-0800) Subject: Fixing clean to use rm -rf so it won't fail if the directory wasn't ever created. X-Git-Tag: android-x86-2.2~360 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=96e0f6315d0dd5bae2aa2d2ce4c88a6e57e16137;p=android-x86%2Fdalvik.git Fixing clean to use rm -rf so it won't fail if the directory wasn't ever created. Adding a --skip-clean option. Adding a --device-runner-dir option to run off the SD card --- diff --git a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/DeviceDalvikVm.java b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/DeviceDalvikVm.java index 48797fa41..7e3207e20 100644 --- a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/DeviceDalvikVm.java +++ b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/DeviceDalvikVm.java @@ -31,13 +31,17 @@ final class DeviceDalvikVm extends Vm { 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() { @@ -65,7 +69,10 @@ final class DeviceDalvikVm extends Vm { @Override public void shutdown() { super.shutdown(); - adb.rm(runnerDir); + + if (clean) { + adb.rm(runnerDir); + } } @Override public void buildAndInstall(TestRun testRun) { @@ -80,7 +87,9 @@ final class DeviceDalvikVm extends Vm { @Override public void cleanup(TestRun testRun) { super.cleanup(testRun); - adb.rm(testClassesDirOnDevice(testRun)); + if (clean) { + adb.rm(testClassesDirOnDevice(testRun)); + } } private File testClassesDirOnDevice(TestRun testRun) { diff --git a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Harness.java b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Harness.java index fa4959d1f..6eb3739aa 100644 --- a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Harness.java +++ b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Harness.java @@ -40,6 +40,8 @@ public final class Harness { private Set expectationDirs = new LinkedHashSet(); private File xmlReportsDirectory; private String javaHome; + private boolean clean = true; + private String deviceRunnerDir = "/sdcard/dalvikrunner"; private List testFiles = new ArrayList(); private Harness() { @@ -67,6 +69,9 @@ public final class 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()) { @@ -75,7 +80,7 @@ public final class Harness { } 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); @@ -92,6 +97,9 @@ public final class Harness { return false; } + } else if ("--skip-clean".equals(args[i])) { + clean = false; + } else if ("--verbose".equals(args[i])) { Logger.getLogger("dalvik.jtreg").setLevel(Level.FINE); @@ -131,12 +139,16 @@ public final class Harness { 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 : 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 : use the specified directory when"); System.out.println(" looking for test expectations. The directory should include"); System.out.println(" .expected files describing expected results."); System.out.println(" Default is: " + expectationDirs); System.out.println(); - System.out.println(" --javaHome : execute the tests on the local workstation"); + System.out.println(" --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."); @@ -147,6 +159,10 @@ public final class Harness { 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 : maximum execution time of each"); System.out.println(" test before the runner aborts it."); System.out.println(" Default is: " + timeoutSeconds); @@ -160,8 +176,9 @@ public final class Harness { 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(); diff --git a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/JavaVm.java b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/JavaVm.java index d9bad33c1..7db0423fd 100644 --- a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/JavaVm.java +++ b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/JavaVm.java @@ -26,8 +26,8 @@ final class JavaVm extends Vm { private final String javaHome; JavaVm(Integer debugPort, long timeoutSeconds, File sdkJar, - File localTemp, String javaHome) { - super(debugPort, timeoutSeconds, sdkJar, localTemp); + File localTemp, String javaHome, boolean clean) { + super(debugPort, timeoutSeconds, sdkJar, localTemp, clean); this.javaHome = javaHome; } diff --git a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Vm.java b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Vm.java index 8e65dfc77..8dff81a7a 100644 --- a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Vm.java +++ b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/Vm.java @@ -63,15 +63,18 @@ public abstract class Vm { 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; } /** @@ -132,10 +135,12 @@ public abstract class Vm { * 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(); + } } /**