summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Sauer <nicksauer@google.com>2016-05-11 17:47:01 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-05-11 17:47:01 +0000
commit7993756467f9a5b66961f03e3ca69868db963c91 (patch)
tree20d8d527c1e4978070b16d4c0b3daadaef2eb7e0
parente5dfd08ce90be5fb6ae7f31f5d7dff70986f92f3 (diff)
parent255836dcd19c1e7f2fc126192fcc00738bc37438 (diff)
downloadapache-harmony-7993756467f9a5b66961f03e3ca69868db963c91.tar.gz
Merge "Get UnixFileTest running in CTS" into nyc-dev
-rw-r--r--luni/src/test/api/unix/org/apache/harmony/luni/tests/java/io/UnixFileTest.java34
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());
}
}