Clean up dead code: filter.
[platform/upstream/libSkiaSharp.git] / tools / dm_flags.py
1 #
2 # Copyright 2015 Google Inc.
3 #
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 #!/usr/bin/env python
9
10 usage = '''
11 Write extra flags to outfile for DM based on the bot name:
12   $ python dm_flags.py outfile Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug
13 Or run self-tests:
14   $ python dm_flags.py test
15 '''
16
17 import inspect
18 import json
19 import os
20 import sys
21
22
23 def lineno():
24   caller = inspect.stack()[1]  # Up one level to our caller.
25   return inspect.getframeinfo(caller[0]).lineno
26
27
28 cov_start = lineno()+1   # We care about coverage starting just past this def.
29 def get_args(bot):
30   args = []
31
32   configs = ['565', '8888', 'gpu']
33
34   if 'Android' not in bot:
35     configs.extend(('upright-matrix-8888', 'upright-matrix-gpu'))
36     args.extend('--matrix 0 1 1 0'.split(' '))
37
38   if '-GCE-' in bot:
39     configs.append('sp-8888')
40     configs.extend(['remote-8888', 'remote_cache-8888'])
41
42   if '-TSAN' not in bot:
43     if ('TegraK1'  in bot or
44         'GTX550Ti' in bot or
45         'GTX660'   in bot or
46         'GT610'    in bot):
47       if 'Android' in bot:
48         configs.append('nvprmsaa4')
49       else:
50         configs.append('nvprmsaa16')
51
52   # The S4 crashes and the NP produces a long error stream when we run with
53   # MSAA.  The Tegra2 and Tegra3 just don't support it.
54   if ('GalaxyS4'    not in bot and
55       'NexusPlayer' not in bot and
56       'Tegra3'      not in bot and
57       'iOS'         not in bot):
58     if 'Android' in bot:
59       configs.append('msaa4')
60     else:
61       configs.append('msaa16')
62   # Runs out of memory on Android bots and Daisy.  Everyone else seems fine.
63   if 'Android' not in bot and 'Daisy' not in bot:
64     configs.append('pdf')
65     configs.append('pdf_poppler')
66
67   # NP is running out of RAM when we run all these modes.  skia:3255
68   if 'NexusPlayer' not in bot:
69     configs.extend(mode + '-8888' for mode in
70                    ['serialize', 'tiles_rt', 'pipe'])
71
72   if 'ANGLE' in bot:
73     configs.append('angle')
74   args.append('--config')
75   args.extend(configs)
76
77   # Run tests and gms everywhere,
78   # and image decoding tests everywhere except GPU bots.
79   # TODO: remove skp from default --src list?
80   if 'GPU' in bot:
81     args.extend('--src tests gm'.split(' '))
82   else:
83     args.extend('--src tests gm image'.split(' '))
84
85   if 'GalaxyS' in bot:
86     args.extend(('--threads', '0'))
87
88   blacklist = []
89
90   # Several of the newest version bmps fail on SkImageDecoder
91   blacklist.extend('_ image decode pal8os2v2.bmp'.split(' '))
92   blacklist.extend('_ image decode pal8v4.bmp'.split(' '))
93   blacklist.extend('_ image decode pal8v5.bmp'.split(' '))
94   blacklist.extend('_ image decode rgb16-565.bmp'.split(' '))
95   blacklist.extend('_ image decode rgb16-565pal.bmp'.split(' '))
96   blacklist.extend('_ image decode rgb32-111110.bmp'.split(' '))
97   blacklist.extend('_ image decode rgb32bf.bmp'.split(' '))
98   blacklist.extend('_ image decode rgba32.bmp'.split(' '))
99   blacklist.extend('_ image decode rgba32abf.bmp'.split(' '))
100   blacklist.extend('_ image decode rgb24largepal.bmp'.split(' '))
101   blacklist.extend('_ image decode pal8os2v2-16.bmp'.split(' '))
102   blacklist.extend('_ image decode pal8oversizepal.bmp'.split(' '))
103   blacklist.extend('_ image decode pal4rletrns.bmp'.split(' '))
104   blacklist.extend('_ image decode pal8rletrns.bmp'.split(' '))
105   blacklist.extend('_ image decode 4bpp-pixeldata-cropped.bmp'.split(' '))
106   blacklist.extend('_ image decode 8bpp-pixeldata-cropped.bmp'.split(' '))
107   blacklist.extend('_ image decode 24bpp-pixeldata-cropped.bmp'.split(' '))
108   blacklist.extend('_ image decode 32bpp-pixeldata-cropped.bmp'.split(' '))
109   blacklist.extend('_ image decode testcase7.bmp'.split(' '))
110
111   # New ico files that fail on SkImageDecoder
112   blacklist.extend('_ image decode Hopstarter-Mac-Folders-Apple.ico'.split(' '))
113
114   # Incomplete image tests that fail on SkImageDecoder
115   blacklist.extend('_ image decode inc0.gif'.split(' '))
116   blacklist.extend('_ image decode inc1.gif'.split(' '))
117   blacklist.extend('_ image decode incInterlaced.gif'.split(' '))
118   blacklist.extend('_ image decode inc0.jpg'.split(' '))
119   blacklist.extend('_ image decode incGray.jpg'.split(' '))
120   blacklist.extend('_ image decode inc0.wbmp'.split(' '))
121   blacklist.extend('_ image decode inc1.wbmp'.split(' '))
122   blacklist.extend('_ image decode inc0.webp'.split(' '))
123   blacklist.extend('_ image decode inc1.webp'.split(' '))
124   blacklist.extend('_ image decode inc0.ico'.split(' '))
125   blacklist.extend('_ image decode inc1.ico'.split(' '))
126   blacklist.extend('_ image decode inc0.png'.split(' '))
127   blacklist.extend('_ image decode inc1.png'.split(' '))
128   blacklist.extend('_ image decode inc2.png'.split(' '))
129   blacklist.extend('_ image decode inc12.png'.split(' '))
130   blacklist.extend('_ image decode inc13.png'.split(' '))
131   blacklist.extend('_ image decode inc14.png'.split(' '))
132
133   # Leon doesn't care about this, so why run it?
134   if 'Win' in bot:
135     blacklist.extend('_ image decode _'.split(' '))
136
137   # Certain gm's on win7 gpu and pdf are never finishing and keeping the test
138   # running forever
139   if 'Win7' in bot:
140     blacklist.extend('msaa16 gm _ colorwheelnative'.split(' '))
141     blacklist.extend('pdf gm _ fontmgr_iter_factory'.split(' '))
142
143   if 'Valgrind' in bot:
144     # PDF + .webp -> jumps depending on uninitialized memory.  skia:3505
145     blacklist.extend('pdf _ _ .webp'.split(' '))
146     # These take 18+ hours to run.
147     blacklist.extend('pdf gm _ fontmgr_iter'.split(' '))
148     blacklist.extend('pdf _ _ PANO_20121023_214540.jpg'.split(' '))
149     blacklist.extend('pdf skp _ worldjournal'.split(' '))
150     blacklist.extend('pdf skp _ desk_baidu.skp'.split(' '))
151     blacklist.extend('pdf skp _ desk_wikipedia.skp'.split(' '))
152
153   if 'iOS' in bot:
154     blacklist.extend('gpu skp _ _ msaa skp _ _'.split(' '))
155     blacklist.extend('gpu image decode _ msaa image decode _'.split(' '))
156     blacklist.extend('msaa16 gm _ tilemodesProcess'.split(' '))
157
158   # the 32-bit GCE bots run out of memory in DM when running these large images
159   if 'x86' in bot and not 'x86-64' in bot:
160     blacklist.extend('_ image _ interlaced1.png'.split(' '))
161     blacklist.extend('_ image _ interlaced2.png'.split(' '))
162     blacklist.extend('_ image _ interlaced3.png'.split(' '))
163
164   if blacklist:
165     args.append('--blacklist')
166     args.extend(blacklist)
167
168   match = []
169   if 'Valgrind' in bot: # skia:3021
170     match.append('~Threaded')
171   if 'TSAN' in bot: # skia:3562
172     match.append('~Math')
173
174   if 'GalaxyS3' in bot:  # skia:1699
175     match.append('~WritePixels')
176
177   # skia:3249: these images flakily don't decode on Android.
178   if 'Android' in bot:
179     match.append('~tabl_mozilla_0')
180     match.append('~desk_yahoonews_0')
181
182   if 'NexusPlayer' in bot:
183     match.append('~ResourceCache')
184
185   if 'iOS' in bot:
186     match.append('~WritePixels')
187
188   if 'GalaxyS4' in bot:  # skia:4079
189     match.append('~imagefiltersclipped')
190     match.append('~imagefilterscropexpand')
191     match.append('~scaled_tilemodes_npot')
192     match.append('~bleed_image')  # skia:4367
193     match.append('~ReadPixels')  # skia:4368
194
195   if match:
196     args.append('--match')
197     args.extend(match)
198
199   return args
200 cov_end = lineno()   # Don't care about code coverage past here.
201
202
203 def self_test():
204   import coverage  # This way the bots don't need coverage.py to be installed.
205   args = {}
206   cases = [
207     'Pretend-iOS-Bot',
208     'Test-Android-GCC-Nexus9-GPU-TegraK1-Arm64-Debug',
209     'Test-Android-GCC-GalaxyS3-GPU-Mali400-Arm7-Debug',
210     'Test-Android-GCC-GalaxyS4-GPU-SGX544-Arm7-Release',
211     'Test-Android-GCC-Nexus7-GPU-Tegra3-Arm7-Release',
212     'Test-Android-GCC-NexusPlayer-CPU-SSSE3-x86-Release',
213     'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
214     'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-TSAN',
215     'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Valgrind',
216     'Test-Win7-MSVC-ShuttleA-GPU-HD2000-x86-Debug-ANGLE',
217   ]
218
219   cov = coverage.coverage()
220   cov.start()
221   for case in cases:
222     args[case] = get_args(case)
223   cov.stop()
224
225   this_file = os.path.basename(__file__)
226   _, _, not_run, _ = cov.analysis(this_file)
227   filtered = [line for line in not_run if line > cov_start and line < cov_end]
228   if filtered:
229     print 'Lines not covered by test cases: ', filtered
230     sys.exit(1)
231
232   golden = this_file.replace('.py', '.json')
233   with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
234     json.dump(args, f, indent=2, sort_keys=True)
235
236
237 if __name__ == '__main__':
238   if len(sys.argv) == 2 and sys.argv[1] == 'test':
239     self_test()
240     sys.exit(0)
241
242   if len(sys.argv) != 3:
243     print usage
244     sys.exit(1)
245
246   with open(sys.argv[1], 'w') as out:
247     json.dump(get_args(sys.argv[2]), out)