Loading core/tests/coretests/src/android/os/MemoryFileTest.java +19 −16 Original line number Original line Diff line number Diff line Loading @@ -16,10 +16,8 @@ package android.os; package android.os; import android.os.MemoryFile; import android.test.AndroidTestCase; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest; import java.io.File; import java.io.File; Loading @@ -44,11 +42,14 @@ public class MemoryFileTest extends AndroidTestCase { /** /** * Keep allocating new files till the system purges them. * Keep allocating new files till the system purges them. */ */ @MediumTest @LargeTest public void testPurge() throws Exception { public void testPurge() throws Exception { List<MemoryFile> files = new ArrayList<MemoryFile>(); List<MemoryFile> files = new ArrayList<MemoryFile>(); try { while (true) { while (true) { MemoryFile newFile = new MemoryFile("MemoryFileTest", 1000000); // This will fail if the process runs out of file descriptors before // the kernel starts purging ashmem areas. MemoryFile newFile = new MemoryFile("MemoryFileTest", 10000000); newFile.allowPurging(true); newFile.allowPurging(true); newFile.writeBytes(testString, 0, 0, testString.length); newFile.writeBytes(testString, 0, 0, testString.length); files.add(newFile); files.add(newFile); Loading @@ -57,13 +58,15 @@ public class MemoryFileTest extends AndroidTestCase { file.readBytes(testString, 0, 0, testString.length); file.readBytes(testString, 0, 0, testString.length); } catch (IOException e) { } catch (IOException e) { // Expected // Expected for (MemoryFile fileToClose : files) { fileToClose.close(); } return; return; } } } } } } } finally { for (MemoryFile fileToClose : files) { fileToClose.close(); } } } } @SmallTest @SmallTest Loading Loading
core/tests/coretests/src/android/os/MemoryFileTest.java +19 −16 Original line number Original line Diff line number Diff line Loading @@ -16,10 +16,8 @@ package android.os; package android.os; import android.os.MemoryFile; import android.test.AndroidTestCase; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest; import java.io.File; import java.io.File; Loading @@ -44,11 +42,14 @@ public class MemoryFileTest extends AndroidTestCase { /** /** * Keep allocating new files till the system purges them. * Keep allocating new files till the system purges them. */ */ @MediumTest @LargeTest public void testPurge() throws Exception { public void testPurge() throws Exception { List<MemoryFile> files = new ArrayList<MemoryFile>(); List<MemoryFile> files = new ArrayList<MemoryFile>(); try { while (true) { while (true) { MemoryFile newFile = new MemoryFile("MemoryFileTest", 1000000); // This will fail if the process runs out of file descriptors before // the kernel starts purging ashmem areas. MemoryFile newFile = new MemoryFile("MemoryFileTest", 10000000); newFile.allowPurging(true); newFile.allowPurging(true); newFile.writeBytes(testString, 0, 0, testString.length); newFile.writeBytes(testString, 0, 0, testString.length); files.add(newFile); files.add(newFile); Loading @@ -57,13 +58,15 @@ public class MemoryFileTest extends AndroidTestCase { file.readBytes(testString, 0, 0, testString.length); file.readBytes(testString, 0, 0, testString.length); } catch (IOException e) { } catch (IOException e) { // Expected // Expected for (MemoryFile fileToClose : files) { fileToClose.close(); } return; return; } } } } } } } finally { for (MemoryFile fileToClose : files) { fileToClose.close(); } } } } @SmallTest @SmallTest Loading