diff options
author | Guang Zhu <guangzhu@google.com> | 2011-04-26 16:41:13 -0700 |
---|---|---|
committer | Guang Zhu <guangzhu@google.com> | 2011-04-26 17:55:27 -0700 |
commit | f6d1b3f125b06fcc4847be3cfb35e8ce21905676 (patch) | |
tree | 08cac927d230c83597c3f4bbc119a910026403b8 /tests/DumpRenderTree | |
parent | 46baa14f27eb08b55434bf6e9cf9bcc9c9dbc17f (diff) | |
download | frameworks_base-f6d1b3f125b06fcc4847be3cfb35e8ce21905676.zip frameworks_base-f6d1b3f125b06fcc4847be3cfb35e8ce21905676.tar.gz frameworks_base-f6d1b3f125b06fcc4847be3cfb35e8ce21905676.tar.bz2 |
Make DRT pull data over network
command format:
adb shell am instrument -w -e class \
com.android.dumprendertree.LoadTestsAutoTest#runPageCyclerTest \
-e suite moz \
-e iteration 1 \
-e forward android-browser-test:80/page_cycler/ \
com.android.dumprendertree/.LayoutTestsAutoRunner
Change-Id: Ib4e9db28953f6be155517bb4b139e4477305c2c2
Diffstat (limited to 'tests/DumpRenderTree')
5 files changed, 96 insertions, 31 deletions
diff --git a/tests/DumpRenderTree/assets/run_page_cycler.py b/tests/DumpRenderTree/assets/run_page_cycler.py index 692f32e..f995086 100755 --- a/tests/DumpRenderTree/assets/run_page_cycler.py +++ b/tests/DumpRenderTree/assets/run_page_cycler.py @@ -33,10 +33,16 @@ def main(options, args): # Include all tests if none are specified. if not args: print "need a URL, e.g. file:///sdcard/webkit/page_cycler/moz/start.html\?auto=1\&iterations=10" + print " or remote:android-browser-test:80/page_cycler/" sys.exit(1) else: path = ' '.join(args); + if path[:7] == "remote:": + remote_path = path[7:] + else: + remote_path = None + adb_cmd = "adb "; if options.adb_options: adb_cmd += options.adb_options @@ -56,7 +62,20 @@ def main(options, args): run_load_test_cmd_postfix = " -w com.android.dumprendertree/.LayoutTestsAutoRunner" # Call LoadTestsAutoTest::runTest. - run_load_test_cmd = run_load_test_cmd_prefix + " -e class com.android.dumprendertree.LoadTestsAutoTest#runPageCyclerTest -e path \"" + path + "\" -e timeout " + timeout_ms + run_load_test_cmd = run_load_test_cmd_prefix + " -e class com.android.dumprendertree.LoadTestsAutoTest#runPageCyclerTest -e timeout " + timeout_ms + + if remote_path: + if options.suite: + run_load_test_cmd += " -e suite %s -e forward %s " % (options.suite, + remote_path) + else: + print "for network mode, need to specify --suite as well." + sys.exit(1) + if options.iteration: + run_load_test_cmd += " -e iteration %s" % options.iteration + else: + run_load_test_cmd += " -e path \"%s\" " % path + if options.drawtime: run_load_test_cmd += " -e drawtime true " @@ -130,5 +149,15 @@ if '__main__' == __name__: default=None, help="stores rendered page to a location on device.") + option_parser.add_option("-u", "--suite", + default=None, + help="(for network mode) specify the suite to" + " run by name") + + option_parser.add_option("-i", "--iteration", + default="5", + help="(for network mode) specify how many iterations" + " to run") + options, args = option_parser.parse_args(); main(options, args) diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java index e058f32..3ba3488 100755 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java @@ -25,7 +25,7 @@ import junit.framework.TestSuite; /** * Instrumentation Test Runner for all DumpRenderTree tests. - * + * * Running all tests: * * adb shell am instrument \ @@ -57,7 +57,7 @@ public class LayoutTestsAutoRunner extends InstrumentationTestRunner { e.printStackTrace(); } } - + String delay_str = (String) icicle.get("delay"); if(delay_str != null) { try { @@ -66,30 +66,37 @@ public class LayoutTestsAutoRunner extends InstrumentationTestRunner { } } - String r = (String)icicle.get("rebaseline"); + String r = icicle.getString("rebaseline"); this.mRebaseline = (r != null && r.toLowerCase().equals("true")); - String logtime = (String) icicle.get("logtime"); + String logtime = icicle.getString("logtime"); this.mLogtime = (logtime != null && logtime.toLowerCase().equals("true")); - String drawTime = (String) icicle.get("drawtime"); + String drawTime = icicle.getString("drawtime"); this.mGetDrawTime = (drawTime != null && drawTime.toLowerCase().equals("true")); - mSaveImagePath = (String) icicle.get("saveimage"); + mSaveImagePath = icicle.getString("saveimage"); - mJsEngine = (String) icicle.get("jsengine"); + mJsEngine = icicle.getString("jsengine"); + + mPageCyclerSuite = icicle.getString("suite"); + mPageCyclerForwardHost = icicle.getString("forward"); + mPageCyclerIteration = icicle.getString("iteration", "5"); super.onCreate(icicle); } - - public String mTestPath; - public String mSaveImagePath; - public int mTimeoutInMillis; - public int mDelay; - public boolean mRebaseline; - public boolean mLogtime; - public boolean mGetDrawTime; - public String mJsEngine; + + String mPageCyclerSuite; + String mPageCyclerForwardHost; + String mPageCyclerIteration; + String mTestPath; + String mSaveImagePath; + int mTimeoutInMillis; + int mDelay; + boolean mRebaseline; + boolean mLogtime; + boolean mGetDrawTime; + String mJsEngine; } diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java index 050b779..7ac0665 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java @@ -401,15 +401,6 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh activity.setDefaultDumpDataType(DumpDataType.EXT_REPR); // Run tests. - int addr = -1; - try{ - addr = AdbUtils.resolve("android-browser-test.mtv.corp.google.com"); - } catch (IOException ioe) { - Log.w(LOGTAG, "error while resolving test host name", ioe); - } - if(addr == -1) { - Log.w(LOGTAG, "failed to resolve test host. http tests will fail."); - } for (int i = 0; i < mTestList.size(); i++) { String s = mTestList.elementAt(i); boolean ignoreResult = mTestListIgnoreResult.elementAt(i); diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java index 622fb0e..ee5bb5d 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java @@ -16,6 +16,9 @@ package com.android.dumprendertree; +import com.android.dumprendertree.forwarder.AdbUtils; +import com.android.dumprendertree.forwarder.ForwardServer; + import android.app.Instrumentation; import android.content.Context; import android.content.Intent; @@ -34,6 +37,8 @@ import java.io.OutputStream; import java.io.PrintStream; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShellActivity> { @@ -41,13 +46,15 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel private final static String LOAD_TEST_RESULT = Environment.getExternalStorageDirectory() + "/load_test_result.txt"; private final static int MAX_GC_WAIT_SEC = 10; + private final static int LOCAL_PORT = 17171; private boolean mFinished; static final String LOAD_TEST_RUNNER_FILES[] = { "run_page_cycler.py" }; + private ForwardServer mForwardServer; public LoadTestsAutoTest() { - super("com.android.dumprendertree", TestShellActivity.class); + super(TestShellActivity.class); } // This function writes the result of the layout test to @@ -59,14 +66,38 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel inst.sendStatus(0, bundle); } + private String setUpForwarding(String forwardInfo, String suite, String iteration) throws IOException { + // read forwarding information first + Pattern forwardPattern = Pattern.compile("(.*):(\\d+)/(.*)/"); + Matcher matcher = forwardPattern.matcher(forwardInfo); + if (!matcher.matches()) { + throw new RuntimeException("Invalid forward information"); + } + String host = matcher.group(1); + int port = Integer.parseInt(matcher.group(2)); + mForwardServer = new ForwardServer(LOCAL_PORT, AdbUtils.resolve(host), port); + mForwardServer.start(); + return String.format("http://127.0.0.1:%d/%s/%s/start.html?auto=1&iterations=%s", + LOCAL_PORT, matcher.group(3), suite, iteration); + } + // Invokes running of layout tests // and waits till it has finished running. - public void runPageCyclerTest() { + public void runPageCyclerTest() throws IOException { LayoutTestsAutoRunner runner = (LayoutTestsAutoRunner) getInstrumentation(); + if (runner.mPageCyclerSuite != null) { + // start forwarder to use page cycler suites hosted on external web server + if (runner.mPageCyclerForwardHost == null) { + throw new RuntimeException("no forwarder information provided"); + } + runner.mTestPath = setUpForwarding(runner.mPageCyclerForwardHost, + runner.mPageCyclerSuite, runner.mPageCyclerIteration); + Log.d(LOGTAG, "using path: " + runner.mTestPath); + } + if (runner.mTestPath == null) { - Log.e(LOGTAG, "No test specified"); - return; + throw new RuntimeException("No test specified"); } TestShellActivity activity = (TestShellActivity) getActivity(); @@ -79,6 +110,10 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel runner.mGetDrawTime, runner.mSaveImagePath); activity.clearCache(); + if (mForwardServer != null) { + mForwardServer.stop(); + mForwardServer = null; + } try { Thread.sleep(5000); } catch (InterruptedException e) { @@ -92,7 +127,9 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel private void freeMem() { Log.v(LOGTAG, "freeMem: calling gc..."); final CountDownLatch latch = new CountDownLatch(1); + @SuppressWarnings("unused") Object dummy = new Object() { + // this object instance is used to track gc @Override protected void finalize() throws Throwable { latch.countDown(); diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/Forwarder.java b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/Forwarder.java index a1f3cdf..a971e7b 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/Forwarder.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/Forwarder.java @@ -36,6 +36,7 @@ public class Forwarder { private Socket from, to; private static final String LOGTAG = "Forwarder"; + private static final int BUFFER_SIZE = 16384; public Forwarder (Socket from, Socket to, ForwardServer server) { this.server = server; @@ -90,7 +91,7 @@ public class Forwarder { int length; InputStream is = in.getInputStream(); OutputStream os = out.getOutputStream(); - byte[] buffer = new byte[4096]; + byte[] buffer = new byte[BUFFER_SIZE]; while ((length = is.read(buffer)) > 0) { os.write(buffer, 0, length); } |