Change 099-vmdebug test to use File.createTempFile.
Avoids issues with concurrency.
Bug: 17439227
(cherry picked from commit 1ae33d6839a0e14a7e37bf9b88896479e30282d2)
Change-Id: I672e83537a12110a77c589697b721b9b26f3c53b
diff --git a/test/099-vmdebug/src/Main.java b/test/099-vmdebug/src/Main.java
index e2c04db..7f24b1b 100644
--- a/test/099-vmdebug/src/Main.java
+++ b/test/099-vmdebug/src/Main.java
@@ -29,17 +29,15 @@
}
private static void testMethodTracing() throws Exception {
- String tempFileName;
- if (new File("/tmp").isDirectory()) {
- tempFileName = "/tmp/test.trace";
- } else if (new File("/sdcard").isDirectory()) {
- tempFileName = "/sdcard/test.trace";
- } else {
- System.out.println("Can't find proper output directory for trace file");
- return;
+ File tempFile;
+ try {
+ tempFile = File.createTempFile("test", ".trace");
+ } catch (IOException e) {
+ System.setProperty("java.io.tmpdir", "/sdcard");
+ tempFile = File.createTempFile("test", ".trace");
}
- File tempFile = new File(tempFileName);
- tempFile.delete();
+ tempFile.deleteOnExit();
+ String tempFileName = tempFile.getPath();
if (VMDebug.getMethodTracingMode() != 0) {
VMDebug.stopMethodTracing();