summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authormsw <msw@chromium.org>2015-05-22 09:41:57 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-22 16:43:03 +0000
commit7d5de20718df4dcebd4e0222c06b1748d8c05f44 (patch)
tree9421798e84fe30fdfae6789630c3bc05d964bb11 /mojo
parent7b3638806824d77dd66453029df40fa99772e863 (diff)
downloadchromium_src-7d5de20718df4dcebd4e0222c06b1748d8c05f44.zip
chromium_src-7d5de20718df4dcebd4e0222c06b1748d8c05f44.tar.gz
chromium_src-7d5de20718df4dcebd4e0222c06b1748d8c05f44.tar.bz2
Add a buildbot script to run Mojo apptests.
Add testing/scripts/mojo_apptest.py to run mojo apptests. Support Chromium JSON test result output in apptest_runner. TODO: Use Chromium and TYP testing infrastructure. TODO: Use GTest Suite.Fixture names, not the apptest names. Add the mojo_apptest.py script entry to the following bots: "Linux GN" (main waterfall release bot) "linux_chromium_gn_rel" (CQ bot) BUG=478244 TEST=Mojo apptests can run on the CQ and the main waterfall. R=jam@chromium.org,dpranke@chromium.org,phajdan.jr@chromium.org Review URL: https://codereview.chromium.org/1155683002 Cr-Commit-Position: refs/heads/master@{#331122}
Diffstat (limited to 'mojo')
-rwxr-xr-xmojo/tools/apptest_runner.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/mojo/tools/apptest_runner.py b/mojo/tools/apptest_runner.py
index b1c69e4..d4a8068 100755
--- a/mojo/tools/apptest_runner.py
+++ b/mojo/tools/apptest_runner.py
@@ -6,8 +6,10 @@
"""A test runner for gtest application tests."""
import argparse
+import json
import logging
import sys
+import time
from mopy import gtest
from mopy.android import AndroidShell
@@ -21,6 +23,8 @@ def main():
help="a file listing apptests to run")
parser.add_argument("build_dir", type=str, help="the build output directory")
parser.add_argument("--verbose", default=False, action='store_true')
+ parser.add_argument('--write-full-results-to', metavar='FILENAME',
+ help='Path to write the JSON list of full results.')
args = parser.parse_args()
gtest.set_color()
@@ -69,8 +73,55 @@ def main():
print "[ FAILED ] %d apptests" % len(failed),
print ": %s" % ", ".join(failed) if failed else ""
+ if args.write_full_results_to:
+ _WriteJSONResults(tests, failed, args.write_full_results_to)
+
return 1 if failed else 0
+def _WriteJSONResults(tests, failed, write_full_results_to):
+ """Write the apptest results in the Chromium JSON test results format.
+ See <http://www.chromium.org/developers/the-json-test-results-format>
+ TODO(msw): Use Chromium and TYP testing infrastructure.
+ TODO(msw): Use GTest Suite.Fixture names, not the apptest names.
+ Adapted from chrome/test/mini_installer/test_installer.py
+ """
+ results = {
+ 'interrupted': False,
+ 'path_delimiter': '.',
+ 'version': 3,
+ 'seconds_since_epoch': time.time(),
+ 'num_failures_by_type': {
+ 'FAIL': len(failed),
+ 'PASS': len(tests) - len(failed),
+ },
+ 'tests': {}
+ }
+
+ for test in tests:
+ value = {
+ 'expected': 'PASS',
+ 'actual': 'FAIL' if test in failed else 'PASS',
+ 'is_unexpected': True if test in failed else False,
+ }
+ _AddPathToTrie(results['tests'], test, value)
+
+ with open(write_full_results_to, 'w') as fp:
+ json.dump(results, fp, indent=2)
+ fp.write('\n')
+
+ return results
+
+
+def _AddPathToTrie(trie, path, value):
+ if '.' not in path:
+ trie[path] = value
+ return
+ directory, rest = path.split('.', 1)
+ if directory not in trie:
+ trie[directory] = {}
+ _AddPathToTrie(trie[directory], rest, value)
+
+
if __name__ == '__main__':
sys.exit(main())