OLD | NEW |
| (Empty) |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 | |
6 """ | |
7 Verify that the bench_pictures.cfg file is sane. | |
8 """ | |
9 | |
10 | |
11 import os | |
12 import sys | |
13 | |
14 | |
15 def ThrowIfNotAString(obj): | |
16 """ Raise a TypeError if obj is not a string. """ | |
17 if str(obj) != obj: | |
18 raise TypeError('%s is not a string!' % str(obj)) | |
19 | |
20 | |
21 def Main(argv): | |
22 """ Verify that the bench_pictures.cfg file is sane. | |
23 | |
24 - Exec the file to ensure that it uses correct Python syntax. | |
25 - Make sure that every element is a string, because the buildbot scripts will | |
26 fail to execute if this is not the case. | |
27 | |
28 This test does not verify that the well-formed configs are actually valid. | |
29 """ | |
30 vars = {'import_path': 'tools'} | |
31 execfile(os.path.join('tools', 'bench_pictures.cfg'), vars) | |
32 bench_pictures_cfg = vars['bench_pictures_cfg'] | |
33 | |
34 for config_name, config_list in bench_pictures_cfg.iteritems(): | |
35 ThrowIfNotAString(config_name) | |
36 for config in config_list: | |
37 for key, value in config.iteritems(): | |
38 ThrowIfNotAString(key) | |
39 if type(value).__name__ == 'list': | |
40 for item in value: | |
41 ThrowIfNotAString(item) | |
42 elif not value is True: | |
43 ThrowIfNotAString(value) | |
44 | |
45 if __name__ == '__main__': | |
46 sys.exit(Main(sys.argv)) | |
OLD | NEW |