Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d45d4630 authored by Guang Zhu's avatar Guang Zhu Committed by Android (Google) Code Review
Browse files

Merge "Make DRT pull data over network"

parents 3bd92957 f6d1b3f1
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -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)
+23 −16
Original line number Diff line number Diff line
@@ -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;
}
+0 −9
Original line number Diff line number Diff line
@@ -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);
+41 −4
Original line number Diff line number Diff line
@@ -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();
+2 −1
Original line number Diff line number Diff line
@@ -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);
                }