summaryrefslogtreecommitdiffstats
path: root/sched
diff options
context:
space:
mode:
authorBenoit Lamarche <benoitlamarche@google.com>2015-02-04 14:55:32 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-02-04 14:55:33 +0000
commitc5557accf55a77edfc1cfb76a1f0b78dc71c857d (patch)
treec12971e74fc849e25bae111146ea64e4e525f192 /sched
parent67bb245352e54941a7979e6333d3dc06cacc6031 (diff)
parent793608a52ecab08512e2142698922e5e582177ad (diff)
downloadtoolchain_jack-c5557accf55a77edfc1cfb76a1f0b78dc71c857d.zip
toolchain_jack-c5557accf55a77edfc1cfb76a1f0b78dc71c857d.tar.gz
toolchain_jack-c5557accf55a77edfc1cfb76a1f0b78dc71c857d.tar.bz2
Merge "Add deletion tests in VFSTest" into ub-jack
Diffstat (limited to 'sched')
-rw-r--r--sched/tests/com/android/sched/vfs/VFSTest.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/sched/tests/com/android/sched/vfs/VFSTest.java b/sched/tests/com/android/sched/vfs/VFSTest.java
index 401e3d1..71643c8 100644
--- a/sched/tests/com/android/sched/vfs/VFSTest.java
+++ b/sched/tests/com/android/sched/vfs/VFSTest.java
@@ -21,6 +21,7 @@ import com.android.sched.util.config.ConfigurationException;
import com.android.sched.util.config.MessageDigestFactory;
import com.android.sched.util.config.ThreadConfig;
import com.android.sched.util.file.CannotCreateFileException;
+import com.android.sched.util.file.CannotDeleteFileException;
import com.android.sched.util.file.CannotSetPermissionException;
import com.android.sched.util.file.Directory;
import com.android.sched.util.file.FileAlreadyExistsException;
@@ -32,6 +33,7 @@ import com.android.sched.util.file.InputZipFile;
import com.android.sched.util.file.NoSuchFileException;
import com.android.sched.util.file.NotDirectoryException;
import com.android.sched.util.file.NotFileException;
+import com.android.sched.util.file.NotFileOrDirectoryException;
import com.android.sched.util.file.OutputZipFile;
import com.android.sched.util.file.WrongPermissionException;
@@ -78,6 +80,7 @@ public class VFSTest {
directVFS = new DirectVFS(new Directory(path, null, Existence.NOT_EXIST,
Permission.READ | Permission.WRITE, ChangePermission.NOCHANGE));
testOutputVFS(directVFS);
+ testDelete(directVFS);
testInputVFS(directVFS);
directVFS.close();
@@ -119,6 +122,7 @@ public class VFSTest {
Permission.WRITE, ChangePermission.NOCHANGE), Permission.READ | Permission.WRITE));
testOutputVFS(directVFS);
+ testDelete(directVFS);
testInputVFS(directVFS);
directVFS.close();
@@ -163,6 +167,7 @@ public class VFSTest {
| Permission.WRITE)));
testOutputVFS(directVFS);
+ testDelete(directVFS);
testInputVFS(directVFS);
directVFS.close();
@@ -208,6 +213,8 @@ public class VFSTest {
| Permission.WRITE)));
testOutputVFS(directVFS);
+ // XXX: does not work, needs to be fixed
+ //testDelete(directVFS);
testInputVFS(directVFS);
directVFS.close();
@@ -262,6 +269,7 @@ public class VFSTest {
Permission.READ | Permission.WRITE), new MessageDigestFactory(sha1)));
testOutputVFS(directVFS);
+ testDelete(directVFS);
testInputVFS(directVFS);
InputVFile fileAAB1 =
directVFS.getRootInputVDir().getInputVFile(new VPath("dirA/dirAA/dirAAB/fileAAB1", '/'));
@@ -312,6 +320,7 @@ public class VFSTest {
| Permission.WRITE), new VPath("stuff", '/')));
testOutputVFS(directVFS);
+ testDelete(directVFS);
testInputVFS(directVFS);
directVFS.close();
@@ -387,6 +396,7 @@ public class VFSTest {
zipVFS = new InputOutputZipVFS(
new OutputZipFile(path, null, Existence.MAY_EXIST, ChangePermission.NOCHANGE));
testOutputVFS(zipVFS);
+ testDelete(zipVFS);
testInputVFS(zipVFS);
zipVFS.close();
inputZipVFS = new InputZipVFS(
@@ -522,6 +532,7 @@ public class VFSTest {
zipVFS = new GenericInputOutputVFS(new ReadWriteZipFS(
new OutputZipFile(path, null, Existence.MAY_EXIST, ChangePermission.NOCHANGE)));
testOutputVFS(zipVFS);
+ testDelete(zipVFS);
testInputVFS(zipVFS);
zipVFS.close();
inputZipVFS = new InputZipVFS(
@@ -540,6 +551,55 @@ public class VFSTest {
}
}
+
+ private void testDelete(@Nonnull InputOutputVFS ioVFS)
+ throws NoSuchFileException,
+ CannotDeleteFileException,
+ NotFileOrDirectoryException,
+ CannotCreateFileException,
+ IOException {
+
+ // let's delete "dirA/dirAA/dirAAB/fileAAB1"
+ InputOutputVDir dirA = ioVFS.getRootInputOutputVDir().getInputVDir(new VPath("dirA", '/'));
+ dirA.delete(new VPath("dirAA/dirAAB/fileAAB1", '/'));
+ try {
+ ioVFS.getRootInputVDir().getInputVFile(new VPath("dirA/dirAA/dirAAB/fileAAB1", '/'));
+ Assert.fail();
+ } catch (NoSuchFileException e) {
+ //expected
+ }
+
+ // let's delete "dirB/dirBB/fileBB1"
+ InputOutputVDir dirBB =
+ ioVFS.getRootInputOutputVDir().getInputVDir(new VPath("dirB/dirBB", '/'));
+ dirBB.delete(new VPath("fileBB1", '/'));
+ try {
+ ioVFS.getRootInputVDir().getInputVFile(new VPath("dirB/dirBB/fileBB1", '/'));
+ Assert.fail();
+ } catch (NoSuchFileException e) {
+ //expected
+ }
+
+ // let's delete "dirC/fileC1"
+ ioVFS.getRootInputOutputVDir().delete(new VPath("dirC/fileC1", '/'));
+ try {
+ ioVFS.getRootInputVDir().getInputVFile(new VPath("dirC/fileC1", '/'));
+ Assert.fail();
+ } catch (NoSuchFileException e) {
+ //expected
+ }
+
+ // let's re-create the files we've deleted to leave the VFS in the same state as before.
+ OutputVFile fileAAB1 = dirA.createOutputVFile(new VPath("dirAA/dirAAB/fileAAB1", '/'));
+ writeToFile(fileAAB1, "dirA/dirAA/dirAAB/fileAAB1");
+ OutputVFile fileBB1 = dirBB.createOutputVFile(new VPath("fileBB1", '/'));
+ writeToFile(fileBB1, "dirB/dirBB/fileBB1");
+ OutputVFile fileC1 =
+ ioVFS.getRootInputOutputVDir().createOutputVFile(new VPath("dirC/fileC1", '/'));
+ writeToFile(fileC1, "dirC/fileC1");
+ }
+
+
private boolean containsFile(@Nonnull Collection<? extends InputVElement> elements,
@Nonnull String fileSimpleName, @Nonnull String fileContent) throws IOException {
for (VElement element : elements) {