summaryrefslogtreecommitdiffstats
path: root/tests/DumpRenderTree2
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-10-15 17:39:09 +0100
committerSteve Block <steveblock@google.com>2010-10-18 20:20:41 +0100
commitae47ce00460538d7db688a269d8cbae5a2054b18 (patch)
treee4ec30911691dfe1da8c76fd3c85ce594257c2a2 /tests/DumpRenderTree2
parent99e3fab534d3a489726665cb8c71edecd5798b04 (diff)
downloadframeworks_base-ae47ce00460538d7db688a269d8cbae5a2054b18.zip
frameworks_base-ae47ce00460538d7db688a269d8cbae5a2054b18.tar.gz
frameworks_base-ae47ce00460538d7db688a269d8cbae5a2054b18.tar.bz2
Improve error handling in DumpRenderTree2 scripts
Change-Id: Idba4acc22dd037a001ea5c05cbd6a29292f6de2c
Diffstat (limited to 'tests/DumpRenderTree2')
-rwxr-xr-xtests/DumpRenderTree2/assets/run_apache2.py39
-rwxr-xr-xtests/DumpRenderTree2/assets/run_layout_tests.py13
2 files changed, 30 insertions, 22 deletions
diff --git a/tests/DumpRenderTree2/assets/run_apache2.py b/tests/DumpRenderTree2/assets/run_apache2.py
index 5edead1..b4a8685 100755
--- a/tests/DumpRenderTree2/assets/run_apache2.py
+++ b/tests/DumpRenderTree2/assets/run_apache2.py
@@ -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)
diff --git a/tests/DumpRenderTree2/assets/run_layout_tests.py b/tests/DumpRenderTree2/assets/run_layout_tests.py
index 303a054..fe7bf55 100755
--- a/tests/DumpRenderTree2/assets/run_layout_tests.py
+++ b/tests/DumpRenderTree2/assets/run_layout_tests.py
@@ -18,6 +18,8 @@ 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"
@@ -33,16 +35,9 @@ def main(options, args):
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"