mirror of
https://git.rtems.org/rtems-tools/
synced 2025-10-18 13:43:56 +08:00
tester: Refactor to use INI format files for BSP configurations.
- Add support for user condfigurations files with the --user-config. - Add support for a $HOME/.rtemstesterrc for a user configuration. Closes #3204.
This commit is contained in:
@@ -36,6 +36,7 @@ from __future__ import print_function
|
||||
|
||||
import os
|
||||
import re
|
||||
import yaml
|
||||
|
||||
try:
|
||||
import configparser
|
||||
@@ -52,6 +53,23 @@ class configuration:
|
||||
self.ini = None
|
||||
self.macro_filter = re.compile('\$\{.+\}')
|
||||
|
||||
def __str__(self):
|
||||
if self.ini is None:
|
||||
return 'empty'
|
||||
s = ['Base: %s' % (self.ini['base'])]
|
||||
s += ['Files:']
|
||||
for f in self.ini['files']:
|
||||
s += [' %s' % (f)]
|
||||
s += ['Defaults:']
|
||||
for default in self.config.defaults():
|
||||
s += ' ' + default
|
||||
s += ['Sections:']
|
||||
for section in self.config.sections():
|
||||
s += [' [%s]' % (section)]
|
||||
for option in self.config.options(section):
|
||||
s += [' %s = %s' % (option, self.config.get(section, option))]
|
||||
return os.linesep.join(s)
|
||||
|
||||
def get_item(self, section, label, err = True):
|
||||
try:
|
||||
rec = self.config.get(section, label).replace(os.linesep, ' ')
|
||||
@@ -78,10 +96,14 @@ class configuration:
|
||||
pass
|
||||
return rec
|
||||
|
||||
def get_items(self, section, err = True):
|
||||
def get_items(self, section, err = True, flatten = True):
|
||||
try:
|
||||
items = [(name, key.replace(os.linesep, ' ')) \
|
||||
for name, key in self.config.items(section)]
|
||||
items = []
|
||||
for name, key in self.config.items(section):
|
||||
if flatten:
|
||||
items += [(name, key.replace(os.linesep, ' '))]
|
||||
else:
|
||||
items += [(name, key)]
|
||||
return items
|
||||
except:
|
||||
if err:
|
||||
@@ -102,6 +124,9 @@ class configuration:
|
||||
raise error.general('config: section "%s" not found' % (section))
|
||||
return []
|
||||
|
||||
def has_section(self, section):
|
||||
return self.config.has_section(section)
|
||||
|
||||
def load(self, name):
|
||||
#
|
||||
# Load all the files.
|
||||
@@ -132,6 +157,5 @@ class configuration:
|
||||
for section in self.config.sections():
|
||||
includes += self.comma_list(section, 'include', err = False)
|
||||
|
||||
|
||||
def files(self):
|
||||
return self.ini['files']
|
||||
|
Reference in New Issue
Block a user