2012-12-14 14:56:37 +00:00
|
|
|
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
Verify that the bench_pictures.cfg file is sane.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
2012-12-17 17:21:04 +00:00
|
|
|
def ThrowIfNotAString(obj):
|
|
|
|
""" Raise a TypeError if obj is not a string. """
|
|
|
|
if str(obj) != obj:
|
|
|
|
raise TypeError('%s is not a string!' % str(obj))
|
|
|
|
|
|
|
|
|
2012-12-14 14:56:37 +00:00
|
|
|
def Main(argv):
|
2012-12-17 17:21:04 +00:00
|
|
|
""" Verify that the bench_pictures.cfg file is sane.
|
|
|
|
|
|
|
|
- Exec the file to ensure that it uses correct Python syntax.
|
|
|
|
- Make sure that every element is a string, because the buildbot scripts will
|
|
|
|
fail to execute if this is not the case.
|
|
|
|
|
|
|
|
This test does not verify that the well-formed configs are actually valid.
|
|
|
|
"""
|
2012-12-14 14:56:37 +00:00
|
|
|
vars = {'import_path': 'tools'}
|
|
|
|
execfile(os.path.join('tools', 'bench_pictures.cfg'), vars)
|
|
|
|
bench_pictures_cfg = vars['bench_pictures_cfg']
|
|
|
|
|
|
|
|
for config_name, config_list in bench_pictures_cfg.iteritems():
|
2012-12-17 17:21:04 +00:00
|
|
|
ThrowIfNotAString(config_name)
|
2012-12-14 14:56:37 +00:00
|
|
|
for config in config_list:
|
|
|
|
for key, value in config.iteritems():
|
2012-12-17 17:21:04 +00:00
|
|
|
ThrowIfNotAString(key)
|
2012-12-14 14:56:37 +00:00
|
|
|
if type(value).__name__ == 'list':
|
|
|
|
for item in value:
|
2012-12-17 17:21:04 +00:00
|
|
|
ThrowIfNotAString(item)
|
2013-01-11 20:45:24 +00:00
|
|
|
elif not value is True:
|
2012-12-17 17:21:04 +00:00
|
|
|
ThrowIfNotAString(value)
|
2012-12-14 14:56:37 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(Main(sys.argv))
|