mirror of https://github.com/ARMmbed/mbed-os.git
[build tools] Added test coverage for config features feature
parent
d9749b0447
commit
6da324fa3f
|
@ -105,8 +105,26 @@ def get_config(src_path, target, toolchain_name):
|
|||
for path in src_paths[1:]:
|
||||
resources.add(toolchain.scan_resources(path))
|
||||
|
||||
config.add_config_files(resources.json_files)
|
||||
return config.get_config_data()
|
||||
# Update configuration files until added features creates no changes
|
||||
prev_features = set()
|
||||
while True:
|
||||
# Update the configuration with any .json files found while scanning
|
||||
config.add_config_files(resources.json_files)
|
||||
|
||||
# Add features while we find new ones
|
||||
features = config.get_features()
|
||||
if features == prev_features:
|
||||
break
|
||||
|
||||
for feature in features:
|
||||
if feature in resources.features:
|
||||
resources += resources.features[feature]
|
||||
|
||||
prev_features = features
|
||||
|
||||
cfg, macros = config.get_config_data()
|
||||
features = config.get_features()
|
||||
return cfg, macros, features
|
||||
|
||||
def build_project(src_path, build_path, target, toolchain_name,
|
||||
libraries_paths=None, options=None, linker_script=None,
|
||||
|
@ -207,9 +225,8 @@ def build_project(src_path, build_path, target, toolchain_name,
|
|||
break
|
||||
|
||||
for feature in features:
|
||||
if feature not in resources.features:
|
||||
raise KeyError("Feature %s is unavailable" % feature)
|
||||
resources += resources.features[feature]
|
||||
if feature in resources.features:
|
||||
resources += resources.features[feature]
|
||||
|
||||
prev_features = features
|
||||
|
||||
|
@ -373,7 +390,8 @@ def build_library(src_paths, build_path, target, toolchain_name,
|
|||
break
|
||||
|
||||
for feature in features:
|
||||
resources += resources.features[feature]
|
||||
if feature in resources.features:
|
||||
resources += resources.features[feature]
|
||||
|
||||
prev_features = features
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ def compare_config(cfg, expected):
|
|||
except KeyError:
|
||||
return "Unexpected key '%s' in configuration data" % k
|
||||
for k in expected:
|
||||
if k != "desc" and k != "expected_macros" and not k in cfg:
|
||||
if k not in ["desc", "expected_macros", "expected_features"] + cfg.keys():
|
||||
return "Expected key '%s' was not found in configuration data" % k
|
||||
return ""
|
||||
|
||||
|
@ -43,7 +43,7 @@ def test_tree(full_name, name):
|
|||
sys.stdout.flush()
|
||||
err_msg = None
|
||||
try:
|
||||
cfg, macros = get_config(full_name, target, "GCC_ARM")
|
||||
cfg, macros, features = get_config(full_name, target, "GCC_ARM")
|
||||
except ConfigException as e:
|
||||
err_msg = e.message
|
||||
if err_msg:
|
||||
|
@ -63,23 +63,33 @@ def test_tree(full_name, name):
|
|||
failed += 1
|
||||
else:
|
||||
res = compare_config(cfg, expected)
|
||||
expected_macros = expected.get("expected_macros", None)
|
||||
expected_features = expected.get("expected_features", None)
|
||||
|
||||
if res:
|
||||
print "FAILED!"
|
||||
sys.stdout.write(" " + res + "\n")
|
||||
failed += 1
|
||||
else:
|
||||
expected_macros = expected.get("expected_macros", None)
|
||||
if expected_macros is not None:
|
||||
if sorted(expected_macros) != sorted(macros):
|
||||
print "FAILED!"
|
||||
sys.stderr.write(" List of macros doesn't match\n")
|
||||
sys.stderr.write(" Expected: '%s'\n" % ",".join(sorted(expected_macros)))
|
||||
sys.stderr.write(" Got: '%s'\n" % ",".join(sorted(expected_macros)))
|
||||
failed += 1
|
||||
else:
|
||||
print "OK"
|
||||
elif expected_macros is not None:
|
||||
if sorted(expected_macros) != sorted(macros):
|
||||
print "FAILED!"
|
||||
sys.stderr.write(" List of macros doesn't match\n")
|
||||
sys.stderr.write(" Expected: '%s'\n" % ",".join(sorted(expected_macros)))
|
||||
sys.stderr.write(" Got: '%s'\n" % ",".join(sorted(expected_macros)))
|
||||
failed += 1
|
||||
else:
|
||||
print "OK"
|
||||
elif expected_features is not None:
|
||||
if sorted(expected_features) != sorted(features):
|
||||
print "FAILED!"
|
||||
sys.stderr.write(" List of features doesn't match\n")
|
||||
sys.stderr.write(" Expected: '%s'\n" % ",".join(sorted(expected_features)))
|
||||
sys.stderr.write(" Got: '%s'\n" % ",".join(sorted(expected_features)))
|
||||
failed += 1
|
||||
else:
|
||||
print "OK"
|
||||
else:
|
||||
print "OK"
|
||||
sys.path.remove(full_name)
|
||||
return failed
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features": ["IPV4", "IPV6"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
# Testing basic features
|
||||
|
||||
expected_results = {
|
||||
"K64F": {
|
||||
"desc": "test basic features",
|
||||
"expected_features": ["IPV4", "IPV6"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "lib1",
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_add": ["IPV4"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_add": ["IPV6"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
# Testing when adding two features
|
||||
|
||||
expected_results = {
|
||||
"K64F": {
|
||||
"desc": "test composing features",
|
||||
"expected_features": ["IPV4", "IPV6"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "lib1",
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_add": ["IPV4"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "lib2",
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_remove": ["IPV4"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_add": ["IPV6"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
# Testing when two features collide
|
||||
|
||||
expected_results = {
|
||||
"K64F": {
|
||||
"desc": "test feature collisions",
|
||||
"exception_msg": "Configuration conflict. Feature IPV4 both added and removed."
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "lib1",
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_add": ["IPV6"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "lib2",
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_add": ["UVISOR"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_add": ["IPV4"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
# Testing if features can enable other features
|
||||
|
||||
expected_results = {
|
||||
"K64F": {
|
||||
"desc": "test recursive features",
|
||||
"expected_features": ["IPV4", "IPV6", "UVISOR"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "lib1",
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_add": ["IPV6"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "lib2",
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features_add": ["UVISOR"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"features": ["IPV4", "IPV6"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
# Testing if feature collisions are detected accross recursive features
|
||||
|
||||
expected_results = {
|
||||
"K64F": {
|
||||
"desc": "test recursive feature collisions",
|
||||
"exception_msg": "Configuration conflict. Feature UVISOR both added and removed."
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue