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

Side by Side Diff: tools/skiaserve/tester/tester.py

Issue 1773263002: Add a bit more to the python test driver (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 Google Inc. 1 # Copyright 2016 Google Inc.
2 # 2 #
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 import requests 10 import requests
11 11
12 from os import listdir 12 from os import listdir
13 from os.path import isfile, join 13 from os.path import isfile, join
14 14
15 ops = [ 15 default_ops = [
16 "enable_gpu", 16 "enable_gpu",
17 "post", 17 "post",
18 "info", 18 "info",
19 "cmd", 19 "cmd",
20 "img" 20 "img",
21 "batchList"
21 ] 22 ]
22 23
23 def Check(request): 24 def Check(request):
24 assert(request.status_code == 200) 25 assert(request.status_code == 200)
25 return request 26 return request
26 27
27 def WriteJson(request, path): 28 def WriteJson(request, path):
28 # Writes out pretty printed json 29 # Writes out pretty printed json
29 with open(path, 'wb+') as fd: 30 with open(path, 'wb+') as fd:
30 json.dump(request.json(), fd, sort_keys=True, indent=2, 31 json.dump(request.json(), fd, sort_keys=True, indent=2,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 def enable_gpu(self): 74 def enable_gpu(self):
74 return Check(requests.post(self.url + '/enableGPU/1')) 75 return Check(requests.post(self.url + '/enableGPU/1'))
75 76
76 def disable_gpu(self): 77 def disable_gpu(self):
77 return Check(requests.post(self.url + '/enableGPU/0')) 78 return Check(requests.post(self.url + '/enableGPU/0'))
78 79
79 def opcount(self): 80 def opcount(self):
80 r = self.cmd() 81 r = self.cmd()
81 return len(r.json()['commands']) - 1 # why the minus 1 here? 82 return len(r.json()['commands']) - 1 # why the minus 1 here?
82 83
84 def batchList(self):
85 path = self.output_dir + '/' + self.skp_name + '.batches.json'
86 return WriteJson(Check(requests.get(self.url + '/batches')), path)
87
83 def main(): 88 def main():
84 parser = argparse.ArgumentParser(description='Tester for SkiaServe') 89 parser = argparse.ArgumentParser(description='Tester for SkiaServe')
85 parser.add_argument('--skp_dir', default='skps', type=str) 90 parser.add_argument('--skp_dir', default='skps', type=str)
86 parser.add_argument('--url', default='http://localhost:8888', type=str) 91 parser.add_argument('--url', default='http://localhost:8888', type=str)
87 parser.add_argument('--output_dir', default='results', type=str) 92 parser.add_argument('--output_dir', default='results', type=str)
88 parser.add_argument('--match', default='.*', type=str) 93 parser.add_argument('--match', default='.*', type=str)
94 parser.add_argument('--ops', nargs='+', default=default_ops)
89 95
90 args = parser.parse_args() 96 args = parser.parse_args()
91 skp_dir = args.skp_dir 97 skp_dir = args.skp_dir
92 url = args.url 98 url = args.url
93 output_dir = args.output_dir 99 output_dir = args.output_dir
100 ops = args.ops
94 101
95 if not os.path.isdir(output_dir): 102 if not os.path.isdir(output_dir):
96 os.makedirs(output_dir) 103 os.makedirs(output_dir)
97 104
98 skps = [] 105 skps = []
99 for skp in listdir(skp_dir): 106 for skp in listdir(skp_dir):
100 if isfile(join(skp_dir, skp)) and re.match(args.match, skp): 107 if isfile(join(skp_dir, skp)) and re.match(args.match, skp):
101 skps.append(skp) 108 skps.append(skp)
102 109
103 tester = SkiaServeTester(url, output_dir) 110 tester = SkiaServeTester(url, output_dir)
104 111
105 for skp_name in skps: 112 for skp_name in skps:
106 tester.set_skp(skp_dir, skp_name) 113 tester.set_skp(skp_dir, skp_name)
107 for op in ops: 114 for op in ops:
108 getattr(tester, op)() 115 getattr(tester, op)()
109 116
110 if __name__ == "__main__": 117 if __name__ == "__main__":
111 main() 118 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698