Merge "just skip the file system benchmarking if there is not enough space" into jb-mr2-dev
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
index 319445f..d698b4b 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
@@ -237,11 +237,9 @@
* The size is rounded in bufferSize. And the size will be bigger than 400MB.
* @param context
* @param bufferSize
- * @return
- * @throws IOException
+ * @return file size or 0 if there is not enough space.
*/
- public static long getFileSizeExceedingMemory(Context context, int bufferSize)
- throws IOException {
+ public static long getFileSizeExceedingMemory(Context context, int bufferSize) {
long freeDisk = SystemUtil.getFreeDiskSize(context);
long memSize = SystemUtil.getTotalMemory(context);
long diskSizeTarget = (2 * memSize / bufferSize) * bufferSize;
@@ -250,7 +248,8 @@
diskSizeTarget = minimumDiskSize;
}
if (diskSizeTarget > freeDisk) {
- throw new IOException("Free disk size " + freeDisk + " too small");
+ Log.i(TAG, "Free disk size " + freeDisk + " too small");
+ return 0;
}
return diskSizeTarget;
}
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/RandomRWTest.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/RandomRWTest.java
index e52af08..0ac096f 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/RandomRWTest.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/RandomRWTest.java
@@ -36,6 +36,9 @@
public void testRandomRead() throws Exception {
final int READ_BUFFER_SIZE = 4 * 1024;
final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), READ_BUFFER_SIZE);
+ if (fileSize == 0) { // not enough space, give up
+ return;
+ }
FileUtil.doRandomReadTest(getContext(), DIR_RANDOM_RD, getReportLog(), fileSize,
READ_BUFFER_SIZE);
}
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java
index 4a9c3dd..d36b45c 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java
@@ -33,22 +33,25 @@
public class SequentialRWTest extends PtsAndroidTestCase {
private static final String DIR_SEQ_WR = "SEQ_WR";
- private static final String DIR_SEQ_UPD = "SEQ_UPD";
+ private static final String DIR_SEQ_UPDATE = "SEQ_UPDATE";
private static final String DIR_SEQ_RD = "SEQ_RD";
private static final int BUFFER_SIZE = 10 * 1024 * 1024;
@Override
protected void tearDown() throws Exception {
FileUtil.removeFileOrDir(getContext(), DIR_SEQ_WR);
- FileUtil.removeFileOrDir(getContext(), DIR_SEQ_UPD);
+ FileUtil.removeFileOrDir(getContext(), DIR_SEQ_UPDATE);
FileUtil.removeFileOrDir(getContext(), DIR_SEQ_RD);
super.tearDown();
}
@TimeoutReq(minutes = 30)
public void testSingleSequentialWrite() throws Exception {
- final int numberOfFiles =(int)(FileUtil.getFileSizeExceedingMemory(
- getContext(), BUFFER_SIZE) / BUFFER_SIZE);
+ final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), BUFFER_SIZE);
+ if (fileSize == 0) { // not enough space, give up
+ return;
+ }
+ final int numberOfFiles =(int)(fileSize / BUFFER_SIZE);
getReportLog().printValue("files", numberOfFiles, ResultType.NEUTRAL,
ResultUnit.COUNT);
final byte[] data = FileUtil.generateRandomData(BUFFER_SIZE);
@@ -76,14 +79,20 @@
@TimeoutReq(minutes = 60)
public void testSingleSequentialUpdate() throws Exception {
final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), BUFFER_SIZE);
+ if (fileSize == 0) { // not enough space, give up
+ return;
+ }
final int NUMBER_REPETITION = 6;
- FileUtil.doSequentialUpdateTest(getContext(), DIR_SEQ_UPD, getReportLog(), fileSize,
+ FileUtil.doSequentialUpdateTest(getContext(), DIR_SEQ_UPDATE, getReportLog(), fileSize,
BUFFER_SIZE, NUMBER_REPETITION);
}
@TimeoutReq(minutes = 30)
public void testSingleSequentialRead() throws Exception {
final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), BUFFER_SIZE);
+ if (fileSize == 0) { // not enough space, give up
+ return;
+ }
long start = System.currentTimeMillis();
final File file = FileUtil.createNewFilledFile(getContext(),
DIR_SEQ_RD, fileSize);