zephyr/scripts/sanity_chk/ini2yaml.py

38 lines
876 B
Python
Raw Normal View History

sanitycheck: support testcases in yaml instead of ini This commit changes the syntax of the testcase files and changes the behaviour and configuration of the sanitycheck script. To avoid having multiple files with different syntax for boards, samples, tests; this change unifies the syntax and uses YAML instead of INI. We maintain the current keywords used in the old syntax and maintain the flexibility of adding tests with different configuration by using YAML list configuration. On top of that, the following features are added: - We now scan for board configurations in the boards directory and look for a YAML file describing a board and how it should be tested. This eliminates the need for listing boards per architecture in a special ini file under scripts/. - We define hardware information charachterstics in the board YAML file that helps identifying if a certain test should run on that board or not. For example, we can specify the available RAM in the board and filter tests that would require more RAM than the board can handle. - Boards can be set as default for testing meaning that we always run a test case (build and run of possible) when sanitycheck is called without any arguments. Previously this was done only by selecting the first board defined for a specific architecture. - Tests can be configured to run on all possible boards, this is to make sure we always build some basic tests for all boards to catch issues with the core kernel features. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-05 06:47:49 +08:00
#!/usr/bin/env python
# SPDX-License-Identifier: Apache-2.0
sanitycheck: support testcases in yaml instead of ini This commit changes the syntax of the testcase files and changes the behaviour and configuration of the sanitycheck script. To avoid having multiple files with different syntax for boards, samples, tests; this change unifies the syntax and uses YAML instead of INI. We maintain the current keywords used in the old syntax and maintain the flexibility of adding tests with different configuration by using YAML list configuration. On top of that, the following features are added: - We now scan for board configurations in the boards directory and look for a YAML file describing a board and how it should be tested. This eliminates the need for listing boards per architecture in a special ini file under scripts/. - We define hardware information charachterstics in the board YAML file that helps identifying if a certain test should run on that board or not. For example, we can specify the available RAM in the board and filter tests that would require more RAM than the board can handle. - Boards can be set as default for testing meaning that we always run a test case (build and run of possible) when sanitycheck is called without any arguments. Previously this was done only by selecting the first board defined for a specific architecture. - Tests can be configured to run on all possible boards, this is to make sure we always build some basic tests for all boards to catch issues with the core kernel features. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-05 06:47:49 +08:00
import ConfigParser, os
import yaml
import sys
sample = False
in_file = sys.argv[1]
if sys.argv[2] == 'sample':
sample = True
out_file = os.path.join(os.path.dirname(in_file), sys.argv[2] + ".yaml")
config = ConfigParser.ConfigParser()
config.readfp(open(sys.argv[1]))
y = {'tests': 'tests'}
tests = []
for section in config.sections():
tc = {}
for opt in config.options(section):
value = config.get(section, opt)
if value in ['false', 'true']:
tc[opt] = True if value == 'true' else False
else:
tc[opt] = value
test = { section : tc}
tests.append(test)
y['tests'] = tests
if sample:
y['sample'] = { 'name': "TBD", 'description': "TBD" }
with open(out_file, "w") as f:
yaml.dump(y, f, width=50, indent=4, default_flow_style=False)