diff options
author | Nicholas Sauer <nicksauer@google.com> | 2016-05-11 17:55:32 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-05-11 17:55:32 +0000 |
commit | dc815b507a273fced6194d700a9e6f88f8fb900f (patch) | |
tree | 20d8d527c1e4978070b16d4c0b3daadaef2eb7e0 | |
parent | 6c8951d8f32d7eb293827aa6773fa4cef22d8b6a (diff) | |
parent | 7993756467f9a5b66961f03e3ca69868db963c91 (diff) | |
download | apache-harmony-dc815b507a273fced6194d700a9e6f88f8fb900f.tar.gz |
Merge "Get UnixFileTest running in CTS" into nyc-dev
am: 7993756467
* commit '7993756467f9a5b66961f03e3ca69868db963c91':
Get UnixFileTest running in CTS
Change-Id: Iaa78a0a9a426055a4328e8a4133ed399383e911c
-rw-r--r-- | luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java b/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java index 8f850a2..960edd5 100644 --- a/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java +++ b/luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java @@ -23,8 +23,12 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import tests.support.resource.Support_Resources; + import junit.framework.TestCase; +import libcore.io.Libcore; + /** * Please note that this case can only be passed on Linux due to some file * system dependent reason. @@ -363,7 +367,7 @@ public class UnixFileTest extends TestCase { if (!testDir.exists()) { testDir.mkdir(); } - root = System.getProperty("user.name").equals("root"); + root = false; //System.getProperty("user.name").equals("root"); } @Override @@ -376,10 +380,10 @@ public class UnixFileTest extends TestCase { super.tearDown(); } - public void test_getCanonicalPath() throws IOException, - InterruptedException { - File tmpFolder1 = new File("folder1"); - tmpFolder1.mkdirs(); + public void test_getCanonicalPath() throws Exception { + + File tempFolder = Support_Resources.createTempFolder(); + File tmpFolder1 = new File(tempFolder, "folder1"); tmpFolder1.deleteOnExit(); File tmpFolder2 = new File(tmpFolder1.toString() + "/folder2"); @@ -395,27 +399,29 @@ public class UnixFileTest extends TestCase { tmpFolder4.deleteOnExit(); // make a link to folder1/folder2 - Process ln = Runtime.getRuntime().exec("ln -s folder1/folder2 folder2"); - ln.waitFor(); - File linkFile = new File("folder2"); + String tempFolderAbsolutePath = tempFolder.getAbsolutePath(); + String target = tempFolderAbsolutePath + "/folder1/folder2"; + String linkName = tempFolderAbsolutePath + "/folder2"; + Libcore.os.symlink(target, linkName); + File linkFile = new File(tempFolder, "folder2"); linkFile.deleteOnExit(); - File file = new File("folder2"); + File file = new File(tempFolder, "folder2"); assertEquals(tmpFolder2.getCanonicalPath(), file.getCanonicalPath()); - file = new File("folder1/folder2"); + file = new File(tempFolder, "folder1/folder2"); assertEquals(tmpFolder2.getCanonicalPath(), file.getCanonicalPath()); - file = new File("folder2/folder3"); + file = new File(tempFolder, "folder2/folder3"); assertEquals(tmpFolder3.getCanonicalPath(), file.getCanonicalPath()); - file = new File("folder2/folder3/folder4"); + file = new File(tempFolder, "folder2/folder3/folder4"); assertEquals(tmpFolder4.getCanonicalPath(), file.getCanonicalPath()); - file = new File("folder1/folder2/folder3"); + file = new File(tempFolder, "folder1/folder2/folder3"); assertEquals(tmpFolder3.getCanonicalPath(), file.getCanonicalPath()); - file = new File("folder1/folder2/folder3/folder4"); + file = new File(tempFolder, "folder1/folder2/folder3/folder4"); assertEquals(tmpFolder4.getCanonicalPath(), file.getCanonicalPath()); } } |