Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/android/offline_pages/evaluation/run_offline_page_evaluation_test.py

Issue 2465303003: [Offline Pages] Script for running evaluation tests. (Closed)
Patch Set: comments. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6 #
7 #
8 # This script is used to run OfflinePageSavePageLaterEvaluationTests.
9 # Example:
10 # run_offline_page_evaluation_test.py --output-directory
11 # ~/offline_eval_short_output/ --url-timeout 150 --not-user-requested
12 # --use-test-scheduler $CHROME_SRC/out/Default ~/offline_eval_urls.txt
13
14 import argparse
15 import os
16 import shutil
17 import subprocess
18 import sys
19
20 DEFAULT_URL_TIMEOUT = 60 * 8
21 DEFAULT_USER_REQUEST = True
22 DEFAULT_USE_TEST_SCHEDULER = False
23 DEFAULT_VERBOSE = False
24 CONFIG_FILENAME = 'test_config'
25 CONFIG_TEMPLATE = """\
26 TimeoutPerUrlInSeconds = {timeout_per_url_in_seconds}
27 IsUserRequested = {is_user_requested}
28 UseTestScheduler = {use_test_scheduler}
29 """
30
31
32 def main(args):
33 # Setting up the argument parser.
34 parser = argparse.ArgumentParser()
35 parser.add_argument(
36 '--output-directory',
37 dest='output_dir',
38 help='Directory for output. Default is ~/offline_eval_output/')
39 parser.add_argument(
40 '--url-timeout',
41 type=int,
42 dest='url_timeout',
43 help='Time out per url, in seconds. Default is 480 seconds.')
44 parser.add_argument(
45 '--not-user-requested',
Pete Williamson 2016/11/03 18:21:11 It is generally better to phrase options in the po
romax 2016/11/03 20:17:20 after some self-struggling i'm adding all options(
46 dest='user_request',
47 action='store_false',
48 help='Test as not user-requested urls.')
49 parser.add_argument(
50 '--use-test-scheduler',
51 dest='use_test_scheduler',
52 action='store_true',
53 help='Start processing immediately. Using GCMNetworkManager by default.')
54 parser.add_argument(
55 '-v',
56 '--verbose',
57 dest='verbose',
58 action='store_true',
59 help='Make test runner verbose.')
60 parser.add_argument('build_output_dir', help='Path to build directory.')
61 parser.add_argument(
62 'test_urls_file', help='Path to input file with urls to be tested.')
63 parser.set_defaults(
64 output_dir=os.path.expanduser('~/offline_eval_output'),
65 url_timeout=DEFAULT_URL_TIMEOUT,
66 user_request=DEFAULT_USER_REQUEST,
67 user_test_scheduler=DEFAULT_USE_TEST_SCHEDULER,
68 verbose=DEFAULT_VERBOSE)
69
70 # Get the arguments and several paths.
71 options, extra_args = parser.parse_known_args(args)
72
73 if extra_args:
74 print 'Unknown args: ' + ', '.join(
75 extra_args) + '. Please check and run again.'
76 return
77
78 build_dir_path = os.path.abspath(
79 os.path.join(os.getcwd(), options.build_output_dir))
80 test_runner_path = os.path.join(build_dir_path,
81 'bin/run_chrome_public_test_apk')
82 config_output_path = os.path.join(options.output_dir, CONFIG_FILENAME)
83 external_dir = subprocess.check_output(
84 ['adb', 'shell', 'echo', '$EXTERNAL_STORAGE']).strip()
85
86 # Create the output directory for results, and have a copy of test config
87 # there.
88 if not os.path.exists(options.output_dir):
89 print 'Creating output directory for results... ' + options.output_dir
90 os.makedirs(options.output_dir)
91 with open(config_output_path, 'w') as config:
92 config.write(
93 CONFIG_TEMPLATE.format(
94 timeout_per_url_in_seconds=options.url_timeout,
95 is_user_requested=options.user_request,
96 use_test_scheduler=options.use_test_scheduler))
97
98 print 'Uploading config file and input file onto the device.'
99 subprocess.call([
100 'adb', 'push', config_output_path, external_dir + '/paquete/test_config'
101 ])
102 subprocess.call([
103 'adb', 'push', options.test_urls_file,
104 '/sdcard/paquete/offline_eval_urls.txt'
105 ])
106 print 'Start running test...'
107
108 # Run test
109 test_runner_cmd = [
110 test_runner_path, '-f',
111 'OfflinePageSavePageLaterEvaluationTest.testFailureRateWithTimeout'
112 ]
113 if options.verbose:
114 test_runner_cmd += ['-v']
115 subprocess.call(test_runner_cmd)
116
117 print 'Fetching results from device...'
118 archive_dir = os.path.join(options.output_dir, 'archives/')
119 if os.path.exists(archive_dir):
120 shutil.rmtree(archive_dir)
121 subprocess.call([
122 'adb', 'pull', '/data/data/org.chromium.chrome/app_chrome/'
123 'Default/Offline Pages/archives', archive_dir
124 ])
125 subprocess.call([
126 'adb', 'pull', external_dir + '/paquete/offline_eval_results.txt',
127 options.output_dir
128 ])
129 subprocess.call([
130 'adb', 'pull', external_dir + '/paquete/offline_eval_logs.txt',
131 options.output_dir
132 ])
133 print 'Test finished!'
134
135
136 if __name__ == '__main__':
137 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageSavePageLaterEvaluationTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698