summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Sauer <nicksauer@google.com>2016-05-04 13:00:56 -0700
committerNicholas Sauer <nicksauer@google.com>2016-05-11 08:40:11 -0700
commit255836dcd19c1e7f2fc126192fcc00738bc37438 (patch)
tree3222e9a1733eca3da6f2f047fd3cb983643a78fc
parent973cf9e2189ea170b883890bea899172bdbc7212 (diff)
downloadapache-harmony-255836dcd19c1e7f2fc126192fcc00738bc37438.tar.gz
Get UnixFileTest running in CTS
bug: 28535310 Change-Id: Ib508ad085329ec5bc76a96a2e996d6780f8d448e
-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());
}
}