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

Commit 16b8bf07 authored by Steve Block's avatar Steve Block Committed by Android (Google) Code Review
Browse files

Merge changes I4a85ff69,Idba4acc2

* changes:
  Fix DumpRenderTree2 script to allow only one path to be specified
  Improve error handling in DumpRenderTree2 scripts
parents 2cd6f470 fc16915d
Loading
Loading
Loading
Loading
+26 −13
Original line number Diff line number Diff line
@@ -29,19 +29,14 @@ import logging
import optparse
import time

def main(options, args):
  if len(args) < 1:
    run_cmd = ""
  else:
    run_cmd = args[0]

def main(run_cmd, options):
  # Setup logging class
  logging.basicConfig(level=logging.INFO, format='%(message)s')

  if not run_cmd in ("start", "stop", "restart"):
    logging.info("illegal argument: " + run_cmd)
    logging.info("Usage: python run_apache2.py start|stop|restart")
    return
    return False

  # Create /tmp/WebKit if it doesn't exist. This is needed for various files used by apache2
  tmp_WebKit = os.path.join("/tmp", "WebKit")
@@ -114,14 +109,25 @@ def main(options, args):
  # to a different PidFile it will not work and will result in a second apache2 instance.
  if (run_cmd == 'restart'):
    logging.info("First will stop...")
    execute_cmd(export_envvars_cmd + " && " + (apache2_restart_template % ('stop')) + directives + conf_file_cmd)
    if execute_cmd(envvars_path, error_log_path,
                   export_envvars_cmd + " && " + (apache2_restart_template % ('stop')) + directives + conf_file_cmd) == False:
      logging.info("Failed to stop Apache2")
      return False
    logging.info("Stopped. Will start now...")
    # We need to sleep breifly to avoid errors with apache being stopped and started too quickly
    time.sleep(0.5)

  execute_cmd(export_envvars_cmd + " && " + (apache2_restart_template % (run_cmd)) + directives + conf_file_cmd)
  if execute_cmd(envvars_path, error_log_path,
                 export_envvars_cmd + " && " +
                 (apache2_restart_template % (run_cmd)) + directives +
                 conf_file_cmd) == False:
    logging.info("Failed to start Apache2")
    return False

  logging.info("Successfully started")
  return True

def execute_cmd(cmd):
def execute_cmd(envvars_path, error_log_path, cmd):
  p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  (out, err) = p.communicate()

@@ -139,12 +145,19 @@ def execute_cmd(cmd):
    else:
      logging.info(err)
      logging.info("Try looking in " + error_log_path + " for details")
  else:
    logging.info("OK")
    return False

  return True

if __name__ == "__main__":
  option_parser = optparse.OptionParser(usage="Usage: %prog [options] start|stop|restart")
  option_parser.add_option("", "--tests-root-directory",
                           help="The directory from which to take the tests, default is external/webkit/LayoutTests in this checkout of the Android tree")
  options, args = option_parser.parse_args();
  main(options, args);

  if len(args) < 1:
    run_cmd = ""
  else:
    run_cmd = args[0]

  main(run_cmd, options)
+16 −18
Original line number Diff line number Diff line
@@ -18,31 +18,19 @@ import subprocess
import tempfile
import webbrowser

import run_apache2

#TODO: These should not be hardcoded
RESULTS_ABSOLUTE_PATH = "/sdcard/layout-test-results/"
DETAILS_HTML = "details.html"
SUMMARY_TXT = "summary.txt"

def main(options, args):
  if args:
    path = " ".join(args);
  else:
    path = "";

  logging.basicConfig(level=logging.INFO, format='%(message)s')

def main(path, options):
  tmpdir = tempfile.gettempdir()

  if options.tests_root_directory != None:
    # if options.tests_root_directory is absolute, os.getcwd() is discarded!
    tests_root_directory = os.path.normpath(os.path.join(os.getcwd(), options.tests_root_directory))
    server_options = " --tests-root-directory=" + tests_root_directory
  else:
    server_options = "";

  # Restart the server
  cmd = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "run_apache2.py") + server_options + " restart"
  os.system(cmd);
  if run_apache2.main("restart", options) == False:
    return

  # Run the tests in path
  adb_cmd = "adb"
@@ -91,4 +79,14 @@ if __name__ == "__main__":
                           help="The directory from which to take the tests, default is external/webkit/LayoutTests in this checkout of the Android tree")
  option_parser.add_option("-s", "--serial", default=None, help="Specify the serial number of device to run test on")
  options, args = option_parser.parse_args();
  main(options, args);

  logging.basicConfig(level=logging.INFO, format='%(message)s')

  if len(args) > 1:
    logging.fatal("Usage: run_layout_tests.py [options] test-relative-path")
  else:
    if len(args) < 1:
      path = "";
    else:
      path = args[0]
    main(path, options);