summaryrefslogtreecommitdiffstats
path: root/media/tests/MediaFrameworkTest
diff options
context:
space:
mode:
authorYu Shan Emily Lau <yslau@google.com>2011-03-16 15:44:22 -0700
committerYu Shan Emily Lau <yslau@google.com>2011-03-16 16:36:17 -0700
commit9dab78470592be7542b9c0f9090603ed0dc80949 (patch)
tree4948dc4c469cabcaab824e64b7e68730d0b04030 /media/tests/MediaFrameworkTest
parentacca16004fd58c2b8c489f031281b58551551dc8 (diff)
downloadframeworks_base-9dab78470592be7542b9c0f9090603ed0dc80949.zip
frameworks_base-9dab78470592be7542b9c0f9090603ed0dc80949.tar.gz
frameworks_base-9dab78470592be7542b9c0f9090603ed0dc80949.tar.bz2
Suppress the 1 hour video editor export test case which exceed the 5 mins large test limit.
Add the media test util for capturing the memory usage. Bug# 4108259 Change-Id: I751a622ff5dfbb1d563f63a2cbc9db71d194a0f6
Diffstat (limited to 'media/tests/MediaFrameworkTest')
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java110
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java2
2 files changed, 110 insertions, 2 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java
index 0183b5d..beb2927 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java
@@ -17,9 +17,13 @@
package com.android.mediaframeworktest;
import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Writer;
import android.os.Debug;
import android.os.Environment;
+import android.util.Log;
/**
*
@@ -30,10 +34,13 @@ public class MediaTestUtil {
private MediaTestUtil(){
}
+ private static String TAG = "MediaTestUtil";
private static final String STORAGE_PATH =
Environment.getExternalStorageDirectory().toString();
+ private static int mMediaStartMemory = 0;
+ private static int mDrmStartMemory = 0;
- //Catpure the heapdump for memory leaksage analysis\
+ //Catpure the heapdump for memory leaksage analysis
public static void getNativeHeapDump (String name) throws Exception {
System.gc();
System.runFinalization();
@@ -42,4 +49,103 @@ public class MediaTestUtil {
Debug.dumpNativeHeap(o.getFD());
o.close();
}
-} \ No newline at end of file
+
+ public static String captureMemInfo(String type) {
+ String cm = "ps ";
+ cm += type;
+ String memoryUsage = null;
+
+ int ch;
+ try {
+ Process p = Runtime.getRuntime().exec(cm);
+ InputStream in = p.getInputStream();
+ StringBuffer sb = new StringBuffer(512);
+ while ((ch = in.read()) != -1) {
+ sb.append((char) ch);
+ }
+ memoryUsage = sb.toString();
+ } catch (IOException e) {
+ Log.v(TAG, e.toString());
+ }
+ String[] poList = memoryUsage.split("\r|\n|\r\n");
+ String memusage = poList[1].concat("\n");
+ return memusage;
+ }
+
+ public static int getMediaServerVsize() {
+ String memoryUsage = captureMemInfo("mediaserver");
+ String[] poList2 = memoryUsage.split("\t|\\s+");
+ String vsize = poList2[3];
+ int vsizevalue = Integer.parseInt(vsize);
+ Log.v(TAG, "VSIZE = " + vsizevalue);
+ return vsizevalue;
+ }
+
+ public static int getDrmServerVsize() {
+ String memoryUsage = captureMemInfo("drmserver");
+ String[] poList2 = memoryUsage.split("\t|\\s+");
+ String vsize = poList2[3];
+ int vsizevalue = Integer.parseInt(vsize);
+ Log.v(TAG, "VSIZE = " + vsizevalue);
+ return vsizevalue;
+ }
+
+ // Write the ps mediaserver output to the file
+ public static void getMediaServerMemoryLog(Writer output, int writeCount, int totalCount)
+ throws Exception {
+ String memusage = null;
+
+ if (writeCount == 0) {
+ mMediaStartMemory = getMediaServerVsize();
+ output.write("Start memory : " + mMediaStartMemory + "\n");
+ }
+ memusage = captureMemInfo("mediaserver");
+ output.write(memusage);
+ }
+
+ // Write the ps drmserver output to the file
+ public static void getDrmServerMemoryLog(Writer output, int writeCount, int totalCount)
+ throws Exception {
+ String memusage = null;
+
+ if (writeCount == 0) {
+ mDrmStartMemory = getDrmServerVsize();
+ output.write("Start memory : " + mDrmStartMemory + "\n");
+ }
+ memusage = captureMemInfo("drmserver");
+ output.write(memusage);
+ }
+
+ // Write the ps drmserver output to the file
+ public static void getDrmServerMemorySummary(Writer output, String tag) throws Exception {
+
+ getTestMemorySummary(output, tag, "drmMem");
+ }
+
+ // Write the ps drmserver output to the file
+ public static void getMediaServerMemorySummary(Writer output, String tag) throws Exception {
+
+ getTestMemorySummary(output, tag, "mediaMem");
+ }
+
+ public static void getTestMemorySummary(Writer output, String tag, String type)
+ throws Exception {
+
+ int endMemory = 0;
+ int memDiff = 0;
+
+ if (type == "mediaMem") {
+ endMemory = getMediaServerVsize();
+ memDiff = endMemory - mMediaStartMemory;
+ } else if (type == "drmMem") {
+ endMemory = getDrmServerVsize();
+ memDiff = endMemory - mDrmStartMemory;
+ }
+ output.write("End Memory :" + endMemory + "\n");
+ if (memDiff < 0) {
+ memDiff = 0;
+ }
+ output.write(tag + " total diff = " + memDiff);
+ output.write("\n\n");
+ }
+}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java
index 37b1f54..74d4766 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java
@@ -44,6 +44,7 @@ import android.util.Log;
import com.android.mediaframeworktest.MediaFrameworkTest;
import android.test.suitebuilder.annotation.LargeTest;
+import android.test.suitebuilder.annotation.Suppress;
import com.android.mediaframeworktest.VideoEditorHelper;
public class VideoEditorExportTest extends
@@ -701,6 +702,7 @@ public class VideoEditorExportTest extends
*
* @throws Exception
*/
+ @Suppress
@LargeTest
public void testExportDuration1Hour() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH +