Merge "testVfsCacheConsistency: Error message is startsWith fails"
diff --git a/hostsidetests/scopedstorage/src/android/scopedstorage/cts/ScopedStorageTest.java b/hostsidetests/scopedstorage/src/android/scopedstorage/cts/ScopedStorageTest.java
index f1a8035..47b45ed 100644
--- a/hostsidetests/scopedstorage/src/android/scopedstorage/cts/ScopedStorageTest.java
+++ b/hostsidetests/scopedstorage/src/android/scopedstorage/cts/ScopedStorageTest.java
@@ -3048,12 +3048,28 @@
assertThat(readPfd.getStatSize()).isEqualTo(writePfd.getStatSize());
}
+ private void assertStartsWith(String actual, String prefix, boolean expected) throws Exception {
+ String message = "String \"" + actual + "\" should start with \"" + prefix + "\"";
+
+ if (expected) {
+ assertTrue(message, actual.startsWith(prefix));
+ } else {
+ assertFalse(message, actual.startsWith(prefix));
+ }
+ }
+
private void assertLowerFsFd(ParcelFileDescriptor pfd) throws Exception {
- assertThat(Os.readlink("/proc/self/fd/" + pfd.getFd()).startsWith("/storage")).isTrue();
+ String path = Os.readlink("/proc/self/fd/" + pfd.getFd());
+ String prefix = "/storage";
+
+ assertStartsWith(path, prefix, true);
}
private void assertUpperFsFd(ParcelFileDescriptor pfd) throws Exception {
- assertThat(Os.readlink("/proc/self/fd/" + pfd.getFd()).startsWith("/mnt/user")).isTrue();
+ String path = Os.readlink("/proc/self/fd/" + pfd.getFd());
+ String prefix = "/mnt/user";
+
+ assertStartsWith(path, prefix, true);
}
private static void assertCanCreateFile(File file) throws IOException {