diff options
author | Jeff Hao <jeffhao@google.com> | 2014-09-09 13:07:59 -0700 |
---|---|---|
committer | Jeff Hao <jeffhao@google.com> | 2014-09-09 13:19:54 -0700 |
commit | 8cf89c4ac6e09f17093ef0f8c35e86dcd2807d98 (patch) | |
tree | 4aba2d059dd226d3455620ca9ed6de70c553841e /test | |
parent | 7c2c52b2276c97b6a0db973a3a3e784e3d4bed24 (diff) | |
download | art-8cf89c4ac6e09f17093ef0f8c35e86dcd2807d98.zip art-8cf89c4ac6e09f17093ef0f8c35e86dcd2807d98.tar.gz art-8cf89c4ac6e09f17093ef0f8c35e86dcd2807d98.tar.bz2 |
Change 099-vmdebug test to use File.createTempFile.
Avoids issues with concurrency.
Bug: 17439227
(cherry picked from commit 1ae33d6839a0e14a7e37bf9b88896479e30282d2)
Change-Id: I672e83537a12110a77c589697b721b9b26f3c53b
Diffstat (limited to 'test')
-rw-r--r-- | test/099-vmdebug/src/Main.java | 18 |
1 files changed, 8 insertions, 10 deletions
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 @@ public class Main { } 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(); |