summaryrefslogtreecommitdiffstats
path: root/sched/tests
diff options
context:
space:
mode:
authorBenoit Lamarche <benoitlamarche@google.com>2015-01-20 17:33:14 +0100
committerBenoit Lamarche <benoitlamarche@google.com>2015-01-23 16:46:56 +0000
commit16bf5fc262dc97224abf422b170469c904913fb4 (patch)
tree504c06e70bc78304f8449519b364c0fc8fa6a56a /sched/tests
parent5f43493188fcec62d4c08e8b8884d398740b2467 (diff)
downloadtoolchain_jack-16bf5fc262dc97224abf422b170469c904913fb4.zip
toolchain_jack-16bf5fc262dc97224abf422b170469c904913fb4.tar.gz
toolchain_jack-16bf5fc262dc97224abf422b170469c904913fb4.tar.bz2
Add new MessageDigestFS
Change-Id: I494ba2024f731e8324f62e52a710a90b972392a3
Diffstat (limited to 'sched/tests')
-rw-r--r--sched/tests/com/android/sched/vfs/VFSTest.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/sched/tests/com/android/sched/vfs/VFSTest.java b/sched/tests/com/android/sched/vfs/VFSTest.java
index 9673c33..6b21bd7 100644
--- a/sched/tests/com/android/sched/vfs/VFSTest.java
+++ b/sched/tests/com/android/sched/vfs/VFSTest.java
@@ -18,6 +18,7 @@ package com.android.sched.vfs;
import com.android.sched.util.config.AsapConfigBuilder;
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.CannotSetPermissionException;
@@ -44,6 +45,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.security.Provider;
+import java.security.Security;
import java.util.Collection;
import javax.annotation.Nonnull;
@@ -228,6 +231,65 @@ public class VFSTest {
}
@Test
+ public void testMessageDigestFS()
+ throws NotDirectoryException,
+ CannotCreateFileException,
+ WrongPermissionException,
+ CannotSetPermissionException,
+ NoSuchFileException,
+ FileAlreadyExistsException,
+ IOException {
+ File file = null;
+ InputOutputVFS directVFS = null;
+ InputOutputVFS directVFS2 = null;
+ try {
+ file = File.createTempFile("vfs", "dir");
+ String path = file.getAbsolutePath();
+ Assert.assertTrue(file.delete());
+
+ Provider.Service sha1 = null;
+ for (Provider provider : Security.getProviders()) {
+ for (Provider.Service service : provider.getServices()) {
+ if (service.getType().equals("MessageDigest") && service.getAlgorithm().equals("SHA")) {
+ sha1 = service;
+ }
+ }
+ }
+ Assert.assertNotNull(sha1);
+
+ directVFS = new GenericInputOutputVFS(new MessageDigestFS(new DirectFS(new Directory(path,
+ null, Existence.NOT_EXIST, Permission.WRITE, ChangePermission.NOCHANGE),
+ Permission.READ | Permission.WRITE), new MessageDigestFactory(sha1)));
+
+ testOutputVFS(directVFS);
+ testInputVFS(directVFS);
+ InputVFile fileAAB1 =
+ directVFS.getRootInputVDir().getInputVFile(new VPath("dirA/dirAA/dirAAB/fileAAB1", '/'));
+ Assert.assertNotNull(((GenericInputVFile) fileAAB1).getDigest());
+ directVFS.close();
+
+ directVFS2 = new GenericInputOutputVFS(new MessageDigestFS(new DirectFS(new Directory(path,
+ null, Existence.MUST_EXIST, Permission.WRITE, ChangePermission.NOCHANGE),
+ Permission.READ | Permission.WRITE), new MessageDigestFactory(sha1)));
+ testInputVFS(directVFS2);
+ InputVFile fileAAB1b =
+ directVFS2.getRootInputVDir().getInputVFile(new VPath("dirA/dirAA/dirAAB/fileAAB1", '/'));
+ Assert.assertNotNull(((GenericInputVFile) fileAAB1b).getDigest());
+
+ } finally {
+ if (directVFS != null) {
+ directVFS.close();
+ }
+ if (directVFS2 != null) {
+ directVFS2.close();
+ }
+ if (file != null) {
+ FileUtils.deleteDir(file);
+ }
+ }
+ }
+
+ @Test
public void testInputOutputZipVFS()
throws NotDirectoryException,
CannotCreateFileException,