diff --git a/.travis.yml b/.travis.yml index 0738cdf0b56..67a635d8381 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,14 +19,13 @@ script: - | find -name "*.s" | tee BUILD/badasm | sed -e "s/^/Bad Assembler file name found: /" && [ ! -s BUILD/badasm ] - make -C events/equeue test clean - - PYTHONPATH=. python tools/test/config_test/config_test.py - - PYTHONPATH=. python tools/test/build_api/build_api_test.py - - PYTHONPATH=. python tools/test/targets/target_test.py - - python tools/test/pylint.py - - py.test tools/test/toolchains/api.py - - python tools/test/memap/memap_test.py - - python tools/project.py -S - - python tools/build_travis.py + - PYTHONPATH=. coverage run -a -m pytest tools/test + - python2 tools/test/pylint.py + - coverage run -a tools/project.py -S + - python2 tools/build_travis.py + - coverage html +after_success: + - coveralls before_install: - sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa - sudo add-apt-repository -y ppa:libreoffice/libreoffice-4-2 @@ -42,3 +41,5 @@ install: - pip install pylint - pip install hypothesis - pip install mock + - pip install coverage + - pip install coveralls diff --git a/README.md b/README.md index 3f1be0c06d0..ee51e5fd6e1 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ We run continuous integration on all of our branches and pull requests to verify - Master branch [![Master Branch CI Badge](https://travis-ci.org/ARMmbed/mbed-os.svg?branch=master)](https://travis-ci.org/ARMmbed/mbed-os) - Latest release [![Latest Tag CI Badge](https://travis-ci.org/ARMmbed/mbed-os.svg?branch=latest)](https://travis-ci.org/ARMmbed/mbed-os/branches) +Tools coverage [![Coverage Status](https://coveralls.io/repos/github/ARMmbed/mbed-os/badge.svg?branch=master)](https://coveralls.io/github/ARMmbed/mbed-os?branch=master) + ## Getting Started for Developers You need [mbed CLI](https://github.com/ARMmbed/mbed-cli) to build mbed OS. For more details, read the [mbed OS Handbook](https://docs.mbed.com/docs/mbed-os-handbook/en/latest/). diff --git a/tools/test/config_test/test11/lib1/lib2/mbed_lib.json b/tools/test/config/app_override_libs/lib1/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test11/lib1/lib2/mbed_lib.json rename to tools/test/config/app_override_libs/lib1/lib2/mbed_lib.json diff --git a/tools/test/config_test/test12/lib1/mbed_lib.json b/tools/test/config/app_override_libs/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test12/lib1/mbed_lib.json rename to tools/test/config/app_override_libs/lib1/mbed_lib.json diff --git a/tools/test/config_test/test12/mbed_app.json b/tools/test/config/app_override_libs/mbed_app.json similarity index 100% rename from tools/test/config_test/test12/mbed_app.json rename to tools/test/config/app_override_libs/mbed_app.json diff --git a/tools/test/config_test/test12/targets.json b/tools/test/config/app_override_libs/targets.json similarity index 100% rename from tools/test/config_test/test12/targets.json rename to tools/test/config/app_override_libs/targets.json diff --git a/tools/test/config/app_override_libs/test_data.json b/tools/test/config/app_override_libs/test_data.json new file mode 100644 index 00000000000..b7a5ff3fd9d --- /dev/null +++ b/tools/test/config/app_override_libs/test_data.json @@ -0,0 +1,9 @@ +{ + "test_target": { + "lib1.p1": "v_p1_lib1_app", + "lib1.p2": "v_p2_lib1", + "lib1.p3": "v_p3_lib1", + "lib2.p1": "v_p1_lib2_app", + "lib2.p2": "v_p2_lib2" + } +} diff --git a/tools/test/config_test/test29/mbed_app.json b/tools/test/config/bootloader_missing/mbed_app.json similarity index 100% rename from tools/test/config_test/test29/mbed_app.json rename to tools/test/config/bootloader_missing/mbed_app.json diff --git a/tools/test/config/bootloader_missing/test_data.json b/tools/test/config/bootloader_missing/test_data.json new file mode 100644 index 00000000000..81592858644 --- /dev/null +++ b/tools/test/config/bootloader_missing/test_data.json @@ -0,0 +1,5 @@ +{ + "K64F": { + "exception_msg": "not found" + } +} diff --git a/tools/test/config_test/test02/targets.json b/tools/test/config/compound_inheritance/targets.json similarity index 82% rename from tools/test/config_test/test02/targets.json rename to tools/test/config/compound_inheritance/targets.json index faa880097b2..19ad992c0d4 100644 --- a/tools/test/config_test/test02/targets.json +++ b/tools/test/config/compound_inheritance/targets.json @@ -1,5 +1,5 @@ { - "b1": { + "base": { "extra_labels": [], "default_lib": "std", "core": "Cortex-M0", @@ -9,8 +9,8 @@ "base1_3": "v_base1_3_b1" } }, - "d1": { - "inherits": ["b1"], + "left_middle": { + "inherits": ["base"], "config": { "derived1": "v_derived1_d1", "derived2": "v_derived2_d1" @@ -20,8 +20,8 @@ "base1_2": "v_base1_2_d1" } }, - "b2": { - "inherits": ["b1"], + "right_middle": { + "inherits": ["base"], "config": { "base2_1": "v_base2_1_b2", "base2_2": "v_base2_2_b2" @@ -30,8 +30,8 @@ "base1_2": "v_base1_2_b2" } }, - "f": { - "inherits": ["d1", "b2"], + "inherits_diamond": { + "inherits": ["left_middle", "right_middle"], "config": { "f1_1": "v_f1_1_f", "f1_2": "v_f1_2_f" diff --git a/tools/test/config/compound_inheritance/test_data.json b/tools/test/config/compound_inheritance/test_data.json new file mode 100644 index 00000000000..89871d7cf99 --- /dev/null +++ b/tools/test/config/compound_inheritance/test_data.json @@ -0,0 +1,20 @@ +{ + "inherits_diamond": { + "target.base1_1": "v_base1_1_f", + "target.base1_2": "v_base1_2_b2", + "target.base1_3": "v_base1_3_b1", + "target.derived1": "v_derived1_d1", + "target.derived2": "v_derived2_f", + "target.base2_1": "v_base2_1_f", + "target.base2_2": "v_base2_2_b2", + "target.f1_1": "v_f1_1_f_override", + "target.f1_2": "v_f1_2_f" + }, + "right_middle": { + "target.base1_1": "v_base1_1_b1", + "target.base1_2": "v_base1_2_b2", + "target.base1_3": "v_base1_3_b1", + "target.base2_1": "v_base2_1_b2", + "target.base2_2": "v_base2_2_b2" + } +} diff --git a/tools/test/config/config_test.py b/tools/test/config/config_test.py index 114f088c28e..157dcb72d32 100644 --- a/tools/test/config/config_test.py +++ b/tools/test/config/config_test.py @@ -1,6 +1,6 @@ """ mbed SDK -Copyright (c) 2016 ARM Limited +Copyright (c) 2011-2017 ARM Limited Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,118 +15,161 @@ limitations under the License. """ -import os.path -import unittest +import os +import sys +import json +import pytest from mock import patch -from tools.config import Config - -""" -Tests for config.py -""" - -class ConfigTests(unittest.TestCase): +from hypothesis import given +from hypothesis.strategies import sampled_from +from os.path import join, isfile, dirname, abspath +from tools.build_api import get_config +from tools.targets import set_targets_json_location, Target, TARGET_NAMES +from tools.config import ConfigException, Config + +def compare_config(cfg, expected): + """Compare the output of config against a dictionary of known good results + + :param cfg: the configuration to check + :param expected: what to expect in that config """ - Test cases for Config class + try: + for k in cfg: + if cfg[k].value != expected[k]: + return "'%s': expected '%s', got '%s'" % (k, expected[k], cfg[k].value) + except KeyError: + return "Unexpected key '%s' in configuration data" % k + for k in expected: + if k not in ["expected_macros", "expected_features"] + cfg.keys(): + return "Expected key '%s' was not found in configuration data" % k + return "" + +def data_path(path): + """The expected data file for a particular test + + :param path: the path to the test """ + return join(path, "test_data.json") - def setUp(self): - """ - Called before each test case +def is_test(path): + """Does a directory represent a test? - :return: - """ - self.target = "K64F" + :param path: the path to the test + """ + return isfile(data_path(path)) - def tearDown(self): - """ - Called after each test case +root_dir = abspath(dirname(__file__)) - :return: - """ - pass +@pytest.mark.parametrize("name", filter(lambda d: is_test(join(root_dir, d)), + os.listdir(root_dir))) +def test_config(name): + """Run a particular configuration test - @patch.object(Config, '_process_config_and_overrides') - @patch('tools.config.json_file_to_dict') - def test_init_app_config(self, mock_json_file_to_dict, _): - """ - Test that the initialisation correctly uses app_config + :param name: test name (same as directory name) + """ + test_dir = join(root_dir, name) + test_data = json.load(open(data_path(test_dir))) + targets_json = os.path.join(test_dir, "targets.json") + set_targets_json_location(targets_json if isfile(targets_json) else None) + for target, expected in test_data.items(): + try: + cfg, macros, features = get_config(test_dir, target, "GCC_ARM") + res = compare_config(cfg, expected) + assert not(res), res + expected_macros = expected.get("expected_macros", None) + expected_features = expected.get("expected_features", None) + + if expected_macros is not None: + macros = Config.config_macros_to_macros(macros) + assert sorted(expected_macros) == sorted(macros) + if expected_features is not None: + assert sorted(expected_features) == sorted(features) + except ConfigException as e: + err_msg = e.message + if "exception_msg" not in expected: + assert not(err_msg), "Unexpected Error: %s" % e + else: + assert expected["exception_msg"] in err_msg + + +@pytest.mark.parametrize("target", ["K64F"]) +def test_init_app_config(target): + """ + Test that the initialisation correctly uses app_config - :param mock_json_file_to_dict: mock of function json_file_to_dict - :param _: mock of function _process_config_and_overrides (not tested) - :return: - """ + :param target: The target to use + """ + set_targets_json_location() + with patch.object(Config, '_process_config_and_overrides'),\ + patch('tools.config.json_file_to_dict') as mock_json_file_to_dict: app_config = "app_config" - mock_return = {'config': 'test'} + mock_return = {'config': {'test': False}} mock_json_file_to_dict.return_value = mock_return - config = Config(self.target, app_config=app_config) + config = Config(target, app_config=app_config) mock_json_file_to_dict.assert_called_with(app_config) - self.assertEqual(config.app_config_data, mock_return, - "app_config_data should be set to the returned value") + assert config.app_config_data == mock_return - @patch.object(Config, '_process_config_and_overrides') - @patch('tools.config.json_file_to_dict') - def test_init_no_app_config(self, mock_json_file_to_dict, _): - """ - Test that the initialisation works without app config - :param mock_json_file_to_dict: mock of function json_file_to_dict - :param _: patch of function _process_config_and_overrides (not tested) - :return: - """ - config = Config(self.target) +@pytest.mark.parametrize("target", ["K64F"]) +def test_init_no_app_config(target): + """ + Test that the initialisation works without app config + + :param target: The target to use + """ + set_targets_json_location() + with patch.object(Config, '_process_config_and_overrides'),\ + patch('tools.config.json_file_to_dict') as mock_json_file_to_dict: + config = Config(target) mock_json_file_to_dict.assert_not_called() - self.assertEqual(config.app_config_data, {}, - "app_config_data should be set an empty dictionary") - - @patch.object(Config, '_process_config_and_overrides') - @patch('os.path.isfile') - @patch('tools.config.json_file_to_dict') - def test_init_no_app_config_with_dir(self, mock_json_file_to_dict, mock_isfile, _): - """ - Test that the initialisation works without app config and with a - specified top level directory - - :param mock_json_file_to_dict: mock of function json_file_to_dict - :param _: patch of function _process_config_and_overrides (not tested) - :return: - """ + assert config.app_config_data == {} + + +@pytest.mark.parametrize("target", ["K64F"]) +def test_init_no_app_config_with_dir(target): + """ + Test that the initialisation works without app config and with a + specified top level directory + + :param target: The target to use + """ + set_targets_json_location() + with patch.object(Config, '_process_config_and_overrides'),\ + patch('os.path.isfile') as mock_isfile, \ + patch('tools.config.json_file_to_dict') as mock_json_file_to_dict: directory = '.' path = os.path.join('.', 'mbed_app.json') - mock_return = {'config': 'test'} + mock_return = {'config': {'test': False}} mock_json_file_to_dict.return_value = mock_return mock_isfile.return_value = True - config = Config(self.target, [directory]) + config = Config(target, [directory]) mock_isfile.assert_called_with(path) mock_json_file_to_dict.assert_called_once_with(path) - self.assertEqual(config.app_config_data, mock_return, - "app_config_data should be set to the returned value") - - @patch.object(Config, '_process_config_and_overrides') - @patch('tools.config.json_file_to_dict') - def test_init_override_app_config(self, mock_json_file_to_dict, _): - """ - Test that the initialisation uses app_config instead of top_level_dir - when both are specified - - :param mock_json_file_to_dict: mock of function json_file_to_dict - :param _: patch of function _process_config_and_overrides (not tested) - :return: - """ + assert config.app_config_data == mock_return + + +@pytest.mark.parametrize("target", ["K64F"]) +def test_init_override_app_config(target): + """ + Test that the initialisation uses app_config instead of top_level_dir + when both are specified + + :param target: The target to use + """ + set_targets_json_location() + with patch.object(Config, '_process_config_and_overrides'),\ + patch('tools.config.json_file_to_dict') as mock_json_file_to_dict: app_config = "app_config" directory = '.' - mock_return = {'config': 'test'} + mock_return = {'config': {'test': False}} mock_json_file_to_dict.return_value = mock_return - config = Config(self.target, [directory], app_config=app_config) + config = Config(target, [directory], app_config=app_config) mock_json_file_to_dict.assert_called_once_with(app_config) - self.assertEqual(config.app_config_data, mock_return, - "app_config_data should be set to the returned value") - -if __name__ == '__main__': - unittest.main() + assert config.app_config_data == mock_return diff --git a/tools/test/config_test/test04/targets.json b/tools/test/config/double_define/targets.json similarity index 69% rename from tools/test/config_test/test04/targets.json rename to tools/test/config/double_define/targets.json index 510f37b92ab..2dddbe28acb 100644 --- a/tools/test/config_test/test04/targets.json +++ b/tools/test/config/double_define/targets.json @@ -1,5 +1,5 @@ { - "b1": { + "first_base": { "extra_labels": [], "default_lib": "std", "core": "Cortex-M0", @@ -9,18 +9,7 @@ "base1_3": "v_base1_3_b1" } }, - "d1": { - "inherits": ["b1"], - "config": { - "derived1": "v_derived1_d1", - "derived2": "v_derived2_d1" - }, - "overrides": { - "base1_1": "v_base1_1_d1", - "base1_2": "v_base1_2_d1" - } - }, - "b2": { + "second_base": { "extra_labels": [], "default_lib": "std", "core": "Cortex-M0", @@ -30,8 +19,8 @@ "base1_1": "v_base1_1_b2" } }, - "f": { - "inherits": ["b2", "d1"], + "double_config": { + "inherits": ["first_base", "second_base"], "config": { "f1_1": "v_f1_1_f", "f1_2": "v_f1_2_f" diff --git a/tools/test/config/double_define/test_data.json b/tools/test/config/double_define/test_data.json new file mode 100644 index 00000000000..7c01c064cd7 --- /dev/null +++ b/tools/test/config/double_define/test_data.json @@ -0,0 +1,10 @@ +{ + "double_config": { + "exception_msg": "Parameter name 'base1_1' defined in both 'target:second_base' and 'target:first_base'" + }, + "second_base": { + "target.base2_1": "v_base2_1_b2", + "target.base2_2": "v_base2_2_b2", + "target.base1_1": "v_base1_1_b2" + } +} diff --git a/tools/test/config_test/test13/lib1/mbed_lib.json b/tools/test/config/duplicate_lib_name/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test13/lib1/mbed_lib.json rename to tools/test/config/duplicate_lib_name/lib1/mbed_lib.json diff --git a/tools/test/config_test/test13/lib2/mbed_lib.json b/tools/test/config/duplicate_lib_name/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test13/lib2/mbed_lib.json rename to tools/test/config/duplicate_lib_name/lib2/mbed_lib.json diff --git a/tools/test/config/duplicate_lib_name/test_data.json b/tools/test/config/duplicate_lib_name/test_data.json new file mode 100644 index 00000000000..65689b1fa49 --- /dev/null +++ b/tools/test/config/duplicate_lib_name/test_data.json @@ -0,0 +1,5 @@ +{ + "K64F": { + "exception_msg": "Library name 'lib1' is not unique" + } +} diff --git a/tools/test/config_test/test22/lib1/mbed_lib.json b/tools/test/config/feature_compesition/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test22/lib1/mbed_lib.json rename to tools/test/config/feature_compesition/lib1/mbed_lib.json diff --git a/tools/test/config_test/test22/mbed_app.json b/tools/test/config/feature_compesition/mbed_app.json similarity index 100% rename from tools/test/config_test/test22/mbed_app.json rename to tools/test/config/feature_compesition/mbed_app.json diff --git a/tools/test/config_test/test16/targets.json b/tools/test/config/feature_compesition/targets.json similarity index 100% rename from tools/test/config_test/test16/targets.json rename to tools/test/config/feature_compesition/targets.json diff --git a/tools/test/config/feature_compesition/test_data.json b/tools/test/config/feature_compesition/test_data.json new file mode 100644 index 00000000000..48c56ee168e --- /dev/null +++ b/tools/test/config/feature_compesition/test_data.json @@ -0,0 +1,5 @@ +{ + "test_target": { + "expected_features": ["IPV4", "STORAGE"] + } +} diff --git a/tools/test/config_test/test23/lib1/mbed_lib.json b/tools/test/config/feature_conflict/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test23/lib1/mbed_lib.json rename to tools/test/config/feature_conflict/lib1/mbed_lib.json diff --git a/tools/test/config_test/test23/lib2/mbed_lib.json b/tools/test/config/feature_conflict/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test23/lib2/mbed_lib.json rename to tools/test/config/feature_conflict/lib2/mbed_lib.json diff --git a/tools/test/config_test/test23/mbed_app.json b/tools/test/config/feature_conflict/mbed_app.json similarity index 100% rename from tools/test/config_test/test23/mbed_app.json rename to tools/test/config/feature_conflict/mbed_app.json diff --git a/tools/test/config_test/test23/test_data.py b/tools/test/config/feature_conflict/test_data.json similarity index 53% rename from tools/test/config_test/test23/test_data.py rename to tools/test/config/feature_conflict/test_data.json index b9ab156acf9..b2392658d19 100644 --- a/tools/test/config_test/test23/test_data.py +++ b/tools/test/config/feature_conflict/test_data.json @@ -1,8 +1,5 @@ -# Testing when two features collide - -expected_results = { +{ "K64F": { - "desc": "test feature collisions", "exception_msg": "Configuration conflict. The feature IPV4 both added and removed." } } diff --git a/tools/test/config_test/test24/FEATURE_IPV4/lib1/mbed_lib.json b/tools/test/config/feature_recursive_add/FEATURE_IPV4/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test24/FEATURE_IPV4/lib1/mbed_lib.json rename to tools/test/config/feature_recursive_add/FEATURE_IPV4/lib1/mbed_lib.json diff --git a/tools/test/config_test/test24/FEATURE_STORAGE/lib2/mbed_lib.json b/tools/test/config/feature_recursive_add/FEATURE_STORAGE/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test24/FEATURE_STORAGE/lib2/mbed_lib.json rename to tools/test/config/feature_recursive_add/FEATURE_STORAGE/lib2/mbed_lib.json diff --git a/tools/test/config_test/test24/mbed_app.json b/tools/test/config/feature_recursive_add/mbed_app.json similarity index 100% rename from tools/test/config_test/test24/mbed_app.json rename to tools/test/config/feature_recursive_add/mbed_app.json diff --git a/tools/test/config_test/test21/targets.json b/tools/test/config/feature_recursive_add/targets.json similarity index 100% rename from tools/test/config_test/test21/targets.json rename to tools/test/config/feature_recursive_add/targets.json diff --git a/tools/test/config/feature_recursive_add/test_data.json b/tools/test/config/feature_recursive_add/test_data.json new file mode 100644 index 00000000000..08885e7f526 --- /dev/null +++ b/tools/test/config/feature_recursive_add/test_data.json @@ -0,0 +1,5 @@ +{ + "test_target": { + "expected_features": ["IPV4", "STORAGE", "UVISOR"] + } +} diff --git a/tools/test/config_test/test25/FEATURE_STORAGE/FEATURE_IPV4/lib1/mbed_lib.json b/tools/test/config/feature_recursive_complex/FEATURE_IPV4/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test25/FEATURE_STORAGE/FEATURE_IPV4/lib1/mbed_lib.json rename to tools/test/config/feature_recursive_complex/FEATURE_IPV4/lib1/mbed_lib.json diff --git a/tools/test/config_test/test26/FEATURE_STORAGE/lib2/mbed_lib.json b/tools/test/config/feature_recursive_complex/FEATURE_STORAGE/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test26/FEATURE_STORAGE/lib2/mbed_lib.json rename to tools/test/config/feature_recursive_complex/FEATURE_STORAGE/lib2/mbed_lib.json diff --git a/tools/test/config_test/test26/mbed_app.json b/tools/test/config/feature_recursive_complex/mbed_app.json similarity index 100% rename from tools/test/config_test/test26/mbed_app.json rename to tools/test/config/feature_recursive_complex/mbed_app.json diff --git a/tools/test/config_test/test22/targets.json b/tools/test/config/feature_recursive_complex/targets.json similarity index 100% rename from tools/test/config_test/test22/targets.json rename to tools/test/config/feature_recursive_complex/targets.json diff --git a/tools/test/config/feature_recursive_complex/test_data.json b/tools/test/config/feature_recursive_complex/test_data.json new file mode 100644 index 00000000000..04be347b3ca --- /dev/null +++ b/tools/test/config/feature_recursive_complex/test_data.json @@ -0,0 +1,5 @@ +{ + "test_target": { + "lib2.test": "GOOD" + } +} diff --git a/tools/test/config_test/test27/lib1/mbed_lib.json b/tools/test/config/feature_remove/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test27/lib1/mbed_lib.json rename to tools/test/config/feature_remove/lib1/mbed_lib.json diff --git a/tools/test/config_test/test27/targets.json b/tools/test/config/feature_remove/targets.json similarity index 100% rename from tools/test/config_test/test27/targets.json rename to tools/test/config/feature_remove/targets.json diff --git a/tools/test/config/feature_remove/test_data.json b/tools/test/config/feature_remove/test_data.json new file mode 100644 index 00000000000..8fa0d08dd00 --- /dev/null +++ b/tools/test/config/feature_remove/test_data.json @@ -0,0 +1,5 @@ +{ + "test_target": { + "expected_features": [] + } +} diff --git a/tools/test/config_test/test28/mbed_app.json b/tools/test/config/feature_uvisor/mbed_app.json similarity index 100% rename from tools/test/config_test/test28/mbed_app.json rename to tools/test/config/feature_uvisor/mbed_app.json diff --git a/tools/test/config_test/test24/targets.json b/tools/test/config/feature_uvisor/targets.json similarity index 100% rename from tools/test/config_test/test24/targets.json rename to tools/test/config/feature_uvisor/targets.json diff --git a/tools/test/config/feature_uvisor/test_data.json b/tools/test/config/feature_uvisor/test_data.json new file mode 100644 index 00000000000..0c29a33c353 --- /dev/null +++ b/tools/test/config/feature_uvisor/test_data.json @@ -0,0 +1,5 @@ +{ + "test_target": { + "expected_features": ["UVISOR"] + } +} diff --git a/tools/test/config_test/test26/FEATURE_IPV4/lib1/mbed_lib.json b/tools/test/config/fetaure_recursive_conflict/FEATURE_STORAGE/FEATURE_IPV4/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test26/FEATURE_IPV4/lib1/mbed_lib.json rename to tools/test/config/fetaure_recursive_conflict/FEATURE_STORAGE/FEATURE_IPV4/lib1/mbed_lib.json diff --git a/tools/test/config_test/test25/FEATURE_STORAGE/lib2/mbed_lib.json b/tools/test/config/fetaure_recursive_conflict/FEATURE_STORAGE/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test25/FEATURE_STORAGE/lib2/mbed_lib.json rename to tools/test/config/fetaure_recursive_conflict/FEATURE_STORAGE/lib2/mbed_lib.json diff --git a/tools/test/config_test/test25/mbed_app.json b/tools/test/config/fetaure_recursive_conflict/mbed_app.json similarity index 100% rename from tools/test/config_test/test25/mbed_app.json rename to tools/test/config/fetaure_recursive_conflict/mbed_app.json diff --git a/tools/test/config/fetaure_recursive_conflict/test_data.json b/tools/test/config/fetaure_recursive_conflict/test_data.json new file mode 100644 index 00000000000..b31573bcba2 --- /dev/null +++ b/tools/test/config/fetaure_recursive_conflict/test_data.json @@ -0,0 +1,5 @@ +{ + "K64F": { + "exception_msg": "Configuration conflict. The feature UVISOR both added and removed." + } +} diff --git a/tools/test/config_test/test16/lib1/mbed_lib.json b/tools/test/config/invalid_app_macro_define/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test16/lib1/mbed_lib.json rename to tools/test/config/invalid_app_macro_define/lib1/mbed_lib.json diff --git a/tools/test/config_test/test16/lib2/mbed_lib.json b/tools/test/config/invalid_app_macro_define/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test16/lib2/mbed_lib.json rename to tools/test/config/invalid_app_macro_define/lib2/mbed_lib.json diff --git a/tools/test/config_test/test17/mbed_app.json b/tools/test/config/invalid_app_macro_define/mbed_app.json similarity index 100% rename from tools/test/config_test/test17/mbed_app.json rename to tools/test/config/invalid_app_macro_define/mbed_app.json diff --git a/tools/test/config/invalid_app_macro_define/test_data.json b/tools/test/config/invalid_app_macro_define/test_data.json new file mode 100644 index 00000000000..e679e6f59a4 --- /dev/null +++ b/tools/test/config/invalid_app_macro_define/test_data.json @@ -0,0 +1,5 @@ +{ + "K64F": { + "exception_msg": "Macro 'LIB2_1' defined in both 'library:lib2' and 'application' with incompatible values" + } +} diff --git a/tools/test/config_test/test14/mbed_app.json b/tools/test/config/invalid_key/mbed_app.json similarity index 100% rename from tools/test/config_test/test14/mbed_app.json rename to tools/test/config/invalid_key/mbed_app.json diff --git a/tools/test/config/invalid_key/test_data.json b/tools/test/config/invalid_key/test_data.json new file mode 100644 index 00000000000..564461ad6e3 --- /dev/null +++ b/tools/test/config/invalid_key/test_data.json @@ -0,0 +1,5 @@ +{ + "K64F": { + "exception_msg": "Unknown key(s)" + } +} diff --git a/tools/test/config_test/test15/lib1/mbed_lib.json b/tools/test/config/invalid_key_lib/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test15/lib1/mbed_lib.json rename to tools/test/config/invalid_key_lib/lib1/mbed_lib.json diff --git a/tools/test/config/invalid_key_lib/test_data.json b/tools/test/config/invalid_key_lib/test_data.json new file mode 100644 index 00000000000..564461ad6e3 --- /dev/null +++ b/tools/test/config/invalid_key_lib/test_data.json @@ -0,0 +1,5 @@ +{ + "K64F": { + "exception_msg": "Unknown key(s)" + } +} diff --git a/tools/test/config_test/test17/lib1/mbed_lib.json b/tools/test/config/invalid_lib_macro_define/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test17/lib1/mbed_lib.json rename to tools/test/config/invalid_lib_macro_define/lib1/mbed_lib.json diff --git a/tools/test/config_test/test18/lib2/mbed_lib.json b/tools/test/config/invalid_lib_macro_define/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test18/lib2/mbed_lib.json rename to tools/test/config/invalid_lib_macro_define/lib2/mbed_lib.json diff --git a/tools/test/config_test/test16/mbed_app.json b/tools/test/config/invalid_lib_macro_define/mbed_app.json similarity index 100% rename from tools/test/config_test/test16/mbed_app.json rename to tools/test/config/invalid_lib_macro_define/mbed_app.json diff --git a/tools/test/config/invalid_lib_macro_define/test_data.json b/tools/test/config/invalid_lib_macro_define/test_data.json new file mode 100644 index 00000000000..34835b12eca --- /dev/null +++ b/tools/test/config/invalid_lib_macro_define/test_data.json @@ -0,0 +1,5 @@ +{ + "K64F": { + "exception_msg": "defined in both" + } +} diff --git a/tools/test/config_test/test18/lib1/mbed_lib.json b/tools/test/config/macro_inheritance/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test18/lib1/mbed_lib.json rename to tools/test/config/macro_inheritance/lib1/mbed_lib.json diff --git a/tools/test/config_test/test17/lib2/mbed_lib.json b/tools/test/config/macro_inheritance/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test17/lib2/mbed_lib.json rename to tools/test/config/macro_inheritance/lib2/mbed_lib.json diff --git a/tools/test/config_test/test18/mbed_app.json b/tools/test/config/macro_inheritance/mbed_app.json similarity index 100% rename from tools/test/config_test/test18/mbed_app.json rename to tools/test/config/macro_inheritance/mbed_app.json diff --git a/tools/test/config_test/test26/targets.json b/tools/test/config/macro_inheritance/targets.json similarity index 100% rename from tools/test/config_test/test26/targets.json rename to tools/test/config/macro_inheritance/targets.json diff --git a/tools/test/config/macro_inheritance/test_data.json b/tools/test/config/macro_inheritance/test_data.json new file mode 100644 index 00000000000..a513dc97c5d --- /dev/null +++ b/tools/test/config/macro_inheritance/test_data.json @@ -0,0 +1,5 @@ +{ + "test_target": { + "expected_macros": ["APP1=10", "APP2", "LIB1_1=1","LIB1_2", "LIB2_1=5"] + } +} diff --git a/tools/test/config_test/test06/lib1/lib2/mbed_lib.json b/tools/test/config/override_labels_libs/lib1/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test06/lib1/lib2/mbed_lib.json rename to tools/test/config/override_labels_libs/lib1/lib2/mbed_lib.json diff --git a/tools/test/config_test/test06/lib1/mbed_lib.json b/tools/test/config/override_labels_libs/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test06/lib1/mbed_lib.json rename to tools/test/config/override_labels_libs/lib1/mbed_lib.json diff --git a/tools/test/config_test/test06/mbed_app.json b/tools/test/config/override_labels_libs/mbed_app.json similarity index 100% rename from tools/test/config_test/test06/mbed_app.json rename to tools/test/config/override_labels_libs/mbed_app.json diff --git a/tools/test/config_test/test05/targets.json b/tools/test/config/override_labels_libs/targets.json similarity index 100% rename from tools/test/config_test/test05/targets.json rename to tools/test/config/override_labels_libs/targets.json diff --git a/tools/test/config_test/test06/test_data.py b/tools/test/config/override_labels_libs/test_data.json similarity index 57% rename from tools/test/config_test/test06/test_data.py rename to tools/test/config/override_labels_libs/test_data.json index 0a91823b40a..df30ae9e106 100644 --- a/tools/test/config_test/test06/test_data.py +++ b/tools/test/config/override_labels_libs/test_data.json @@ -1,9 +1,5 @@ -# This build on top of test5 by adding a few libraries with their own configurations -# and overrides. The same targets are used for building and testing (base, b1, b2, both) - -expected_results = { +{ "base": { - "desc": "override values based on labels with libs (no labels)", "app.app1": "v_app1", "app.app2": "v_app2", "lib1.p1": "v_p1_lib1", @@ -13,7 +9,6 @@ "lib2.p2": "v_p2_lib2" }, "b1": { - "desc": "override values based on labels with libs (first label)", "app.app1": "v_app1[b1_label]", "app.app2": "v_app2", "lib1.p1": "v_p1_lib1[b1_label]", @@ -23,7 +18,6 @@ "lib2.p2": "v_p2_lib2[b1_label]" }, "b2": { - "desc": "override values based on labels with libs (second label)", "app.app1": "v_app1", "app.app2": "v_app2[b2_label]", "lib1.p1": "v_p1_lib1", @@ -32,12 +26,7 @@ "lib2.p1": "v_p1_lib2[b2_label]", "lib2.p2": "v_p2_lib2[b2_label]" }, - # The values for lib2.p1 and lib2.p2 illustrate how overriding on multiple - # labels work. In lib2, both lib2.p1 and lib2.p2 are overriden for both - # labels (b1_label and b2_label). However, since "b2_label" is specified - # after "b1_label", it sets the final values of the overrides. "both": { - "desc": "override values based on labels with libs (both labels)", "app.app1": "v_app1[b1_label]", "app.app2": "v_app2[b2_label]", "lib1.p1": "v_p1_lib1[b1_label]", @@ -45,5 +34,5 @@ "lib1.p3": "v_p3_lib1", "lib2.p1": "v_p1_lib2[b2_label]", "lib2.p2": "v_p2_lib2[b2_label]" - }, + } } diff --git a/tools/test/config_test/test07/lib1/lib2/mbed_lib.json b/tools/test/config/override_labels_libs_more/lib1/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test07/lib1/lib2/mbed_lib.json rename to tools/test/config/override_labels_libs_more/lib1/lib2/mbed_lib.json diff --git a/tools/test/config_test/test07/lib1/mbed_lib.json b/tools/test/config/override_labels_libs_more/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test07/lib1/mbed_lib.json rename to tools/test/config/override_labels_libs_more/lib1/mbed_lib.json diff --git a/tools/test/config_test/test07/mbed_app.json b/tools/test/config/override_labels_libs_more/mbed_app.json similarity index 100% rename from tools/test/config_test/test07/mbed_app.json rename to tools/test/config/override_labels_libs_more/mbed_app.json diff --git a/tools/test/config_test/test06/targets.json b/tools/test/config/override_labels_libs_more/targets.json similarity index 100% rename from tools/test/config_test/test06/targets.json rename to tools/test/config/override_labels_libs_more/targets.json diff --git a/tools/test/config_test/test07/test_data.py b/tools/test/config/override_labels_libs_more/test_data.json similarity index 61% rename from tools/test/config_test/test07/test_data.py rename to tools/test/config/override_labels_libs_more/test_data.json index e9d605acfa2..46ae967b0ff 100644 --- a/tools/test/config_test/test07/test_data.py +++ b/tools/test/config/override_labels_libs_more/test_data.json @@ -1,8 +1,5 @@ -# This build on top of test6 by adding overrides for libs in the application - -expected_results = { +{ "base": { - "desc": "override values based on labels with libs (no labels)", "app.app1": "v_app1", "app.app2": "v_app2", "lib1.p1": "v_p1_lib1_app", @@ -12,7 +9,6 @@ "lib2.p2": "v_p2_lib2" }, "b1": { - "desc": "override values based on labels with libs (first label)", "app.app1": "v_app1[b1_label]", "app.app2": "v_app2", "lib1.p1": "v_p1_lib1_app", @@ -22,7 +18,6 @@ "lib2.p2": "v_p2_lib2[b1_label]" }, "b2": { - "desc": "override values based on labels with libs (second label)", "app.app1": "v_app1", "app.app2": "v_app2[b2_label]", "lib1.p1": "v_p1_lib1_app", @@ -31,12 +26,7 @@ "lib2.p1": "v_p1_lib2_app", "lib2.p2": "v_p2_lib2[b2_label]" }, - # The values for lib2.p1 and lib2.p2 illustrate how overriding on multiple - # labels work. In lib2, both lib2.p1 and lib2.p2 are overriden for both - # labels (b1_label and b2_label). However, since "b2_label" is specified - # after "b1_label", it sets the final values of the overrides. "both": { - "desc": "override values based on labels with libs (both labels)", "app.app1": "v_app1[b1_label]", "app.app2": "v_app2[b2_label]", "lib1.p1": "v_p1_lib1_app", diff --git a/tools/test/config_test/test08/lib1/lib2/mbed_lib.json b/tools/test/config/override_labels_targets/lib1/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test08/lib1/lib2/mbed_lib.json rename to tools/test/config/override_labels_targets/lib1/lib2/mbed_lib.json diff --git a/tools/test/config_test/test08/lib1/mbed_lib.json b/tools/test/config/override_labels_targets/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test08/lib1/mbed_lib.json rename to tools/test/config/override_labels_targets/lib1/mbed_lib.json diff --git a/tools/test/config_test/test08/mbed_app.json b/tools/test/config/override_labels_targets/mbed_app.json similarity index 100% rename from tools/test/config_test/test08/mbed_app.json rename to tools/test/config/override_labels_targets/mbed_app.json diff --git a/tools/test/config_test/test08/targets.json b/tools/test/config/override_labels_targets/targets.json similarity index 100% rename from tools/test/config_test/test08/targets.json rename to tools/test/config/override_labels_targets/targets.json diff --git a/tools/test/config_test/test08/test_data.py b/tools/test/config/override_labels_targets/test_data.json similarity index 75% rename from tools/test/config_test/test08/test_data.py rename to tools/test/config/override_labels_targets/test_data.json index 141bf397255..f115f5baffe 100644 --- a/tools/test/config_test/test08/test_data.py +++ b/tools/test/config/override_labels_targets/test_data.json @@ -1,9 +1,5 @@ -# This build on top of test7 by adding some configuration values in targets -# and overriding them in the application - -expected_results = { +{ "base": { - "desc": "override values based on labels with libs and target params (no labels)", "app.app1": "v_app1", "app.app2": "v_app2", "lib1.p1": "v_p1_lib1_app", @@ -16,7 +12,6 @@ "target.par3": "v_par3_base" }, "b1": { - "desc": "override values based on labels with libs and target params (first label)", "app.app1": "v_app1[b1_label]", "app.app2": "v_app2", "lib1.p1": "v_p1_lib1_app", @@ -29,7 +24,6 @@ "target.par3": "v_par3_base" }, "b2": { - "desc": "override values based on labels with libs and target params (second label)", "app.app1": "v_app1", "app.app2": "v_app2[b2_label]", "lib1.p1": "v_p1_lib1_app", @@ -42,7 +36,6 @@ "target.par3": "v_par3_base" }, "both": { - "desc": "override values based on labels with libs and target params (both labels)", "app.app1": "v_app1[b1_label]", "app.app2": "v_app2[b2_label]", "lib1.p1": "v_p1_lib1_app", diff --git a/tools/test/config_test/test09/lib1/lib2/mbed_lib.json b/tools/test/config/override_precidence/lib1/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test09/lib1/lib2/mbed_lib.json rename to tools/test/config/override_precidence/lib1/lib2/mbed_lib.json diff --git a/tools/test/config_test/test09/lib1/mbed_lib.json b/tools/test/config/override_precidence/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test09/lib1/mbed_lib.json rename to tools/test/config/override_precidence/lib1/mbed_lib.json diff --git a/tools/test/config_test/test10/mbed_app.json b/tools/test/config/override_precidence/mbed_app.json similarity index 100% rename from tools/test/config_test/test10/mbed_app.json rename to tools/test/config/override_precidence/mbed_app.json diff --git a/tools/test/config_test/test10/targets.json b/tools/test/config/override_precidence/targets.json similarity index 100% rename from tools/test/config_test/test10/targets.json rename to tools/test/config/override_precidence/targets.json diff --git a/tools/test/config_test/test10/test_data.py b/tools/test/config/override_precidence/test_data.json similarity index 74% rename from tools/test/config_test/test10/test_data.py rename to tools/test/config/override_precidence/test_data.json index 7ed62e2ad93..fd853cb7982 100644 --- a/tools/test/config_test/test10/test_data.py +++ b/tools/test/config/override_precidence/test_data.json @@ -1,8 +1,5 @@ -# This builds on top of test8 by adding target-conditional overrides in mbed_app_config.json. - -expected_results = { +{ "base": { - "desc": "override values based on labels with libs, target params and target overrides (no labels)", "app.app1": "v_app1", "app.app2": "v_app2", "lib1.p1": "v_p1_lib1_app", @@ -15,7 +12,6 @@ "target.par3": "v_par3_base" }, "b1": { - "desc": "override values based on labels with libs, target params and target overrides (first label)", "app.app1": "v_app1[b1_label_label]", "app.app2": "v_app2", "lib1.p1": "v_p1_lib1_app", @@ -28,7 +24,6 @@ "target.par3": "v_par3_base" }, "b2": { - "desc": "override values based on labels with libs, target params and target overrides (second label)", "app.app1": "v_app1", "app.app2": "v_app2[b2_label]", "lib1.p1": "v_p1_lib1_app", @@ -41,7 +36,6 @@ "target.par3": "v_par3_base" }, "both": { - "desc": "override values based on labels with libs, target params and target overrides (both labels)", "app.app1": "v_app1[b1_label_label]", "app.app2": "v_app2[b2_label]", "lib1.p1": "v_p1_lib1_app", diff --git a/tools/test/config_test/test03/targets.json b/tools/test/config/override_undefined/targets.json similarity index 82% rename from tools/test/config_test/test03/targets.json rename to tools/test/config/override_undefined/targets.json index 5a287888d10..ae1cf7c3007 100644 --- a/tools/test/config_test/test03/targets.json +++ b/tools/test/config/override_undefined/targets.json @@ -1,5 +1,5 @@ { - "b1": { + "first_base_target": { "extra_labels": [], "default_lib": "std", "core": "Cortex-M0", @@ -9,8 +9,8 @@ "base1_3": "v_base1_3_b1" } }, - "d1": { - "inherits": ["b1"], + "intermediate": { + "inherits": ["first_base_target"], "config": { "derived1": "v_derived1_d1", "derived2": "v_derived2_d1" @@ -20,7 +20,7 @@ "base1_2": "v_base1_2_d1" } }, - "b2": { + "second_base_target": { "config": { "base2_1": "v_base2_1_b2", "base2_2": "v_base2_2_b2" @@ -29,8 +29,8 @@ "base1_1": "v_base1_1_b2" } }, - "f": { - "inherits": ["b2", "d1"], + "should_fail": { + "inherits": ["second_base_target", "intermediate"], "config": { "f1_1": "v_f1_1_f", "f1_2": "v_f1_2_f" diff --git a/tools/test/config/override_undefined/test_data.json b/tools/test/config/override_undefined/test_data.json new file mode 100644 index 00000000000..f5ca6574d9e --- /dev/null +++ b/tools/test/config/override_undefined/test_data.json @@ -0,0 +1,12 @@ +{ + "should_fail": { + "exception_msg": "Attempt to override undefined parameter 'base1_1' in 'target:second_base_target'" + }, + "intermediate": { + "target.base1_1": "v_base1_1_d1", + "target.base1_2": "v_base1_2_d1", + "target.base1_3": "v_base1_3_b1", + "target.derived1": "v_derived1_d1", + "target.derived2": "v_derived2_d1" + } +} diff --git a/tools/test/config_test/test10/lib1/lib2/mbed_lib.json b/tools/test/config/override_undefined_libs/lib1/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test10/lib1/lib2/mbed_lib.json rename to tools/test/config/override_undefined_libs/lib1/lib2/mbed_lib.json diff --git a/tools/test/config_test/test10/lib1/mbed_lib.json b/tools/test/config/override_undefined_libs/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test10/lib1/mbed_lib.json rename to tools/test/config/override_undefined_libs/lib1/mbed_lib.json diff --git a/tools/test/config_test/test09/mbed_app.json b/tools/test/config/override_undefined_libs/mbed_app.json similarity index 100% rename from tools/test/config_test/test09/mbed_app.json rename to tools/test/config/override_undefined_libs/mbed_app.json diff --git a/tools/test/config_test/test09/targets.json b/tools/test/config/override_undefined_libs/targets.json similarity index 70% rename from tools/test/config_test/test09/targets.json rename to tools/test/config/override_undefined_libs/targets.json index d045de8670f..16c687b6c6b 100644 --- a/tools/test/config_test/test09/targets.json +++ b/tools/test/config/override_undefined_libs/targets.json @@ -4,15 +4,15 @@ "default_lib": "std", "core": "Cortex-M0" }, - "b1": { + "left_intermediate": { "inherits": ["base"], "extra_labels_add": ["b1_label"] }, - "b2": { + "right_intermediate": { "inherits": ["base"], "extra_labels_add": ["b2_label"] }, "both": { - "inherits": ["b1", "b2"] + "inherits": ["left_intermediate", "right_intermediate"] } } diff --git a/tools/test/config_test/test09/test_data.py b/tools/test/config/override_undefined_libs/test_data.json similarity index 55% rename from tools/test/config_test/test09/test_data.py rename to tools/test/config/override_undefined_libs/test_data.json index 04757485a90..15c806215f3 100644 --- a/tools/test/config_test/test09/test_data.py +++ b/tools/test/config/override_undefined_libs/test_data.json @@ -1,10 +1,5 @@ -# This build on top of test6 by adding an invalid override in mbed_app_override.json for b1_label. -# This will prevent the configuration for working for b1 and both, but it should still -# work for base and b2. - -expected_results = { +{ "base": { - "desc": "override values based on labels with libs (no labels)", "app.app1": "v_app1", "app.app2": "v_app2", "lib1.p1": "v_p1_lib1", @@ -13,12 +8,10 @@ "lib2.p1": "v_p1_lib2", "lib2.p2": "v_p2_lib2" }, - "b1": { - "desc": "override values based on labels with libs - invalid override (first label)", + "left_intermediate": { "exception_msg": "Attempt to override undefined parameter 'app.app_wrong' in 'application[b1_label]" }, - "b2": { - "desc": "override values based on labels with libs (second label)", + "right_intermediate": { "app.app1": "v_app1", "app.app2": "v_app2[b2_label]", "lib1.p1": "v_p1_lib1", @@ -28,7 +21,6 @@ "lib2.p2": "v_p2_lib2[b2_label]" }, "both": { - "desc": "override values based on labels with libs - invalid override (both labels)", "exception_msg": "Attempt to override undefined parameter 'app.app_wrong' in 'application[b1_label]" - }, + } } diff --git a/tools/test/config_test/test05/mbed_app.json b/tools/test/config/override_with_labels/mbed_app.json similarity index 55% rename from tools/test/config_test/test05/mbed_app.json rename to tools/test/config/override_with_labels/mbed_app.json index b6ce5881c84..716165a37e5 100644 --- a/tools/test/config_test/test05/mbed_app.json +++ b/tools/test/config/override_with_labels/mbed_app.json @@ -4,11 +4,11 @@ "app2": "v_app2" }, "target_overrides": { - "b1_label": { - "app1": "v_app1[b1_label]" + "left_intermediate_label": { + "app1": "v_app1[left_intermediate_label]" }, - "b2_label": { - "app2": "v_app2[b2_label]" + "right_intermediate_label": { + "app2": "v_app2[right_intermediate_label]" }, "dummy_label": { "app1": "dummy.app1", diff --git a/tools/test/config/override_with_labels/targets.json b/tools/test/config/override_with_labels/targets.json new file mode 100644 index 00000000000..3d78e3ef9c8 --- /dev/null +++ b/tools/test/config/override_with_labels/targets.json @@ -0,0 +1,18 @@ +{ + "base": { + "extra_labels": [], + "default_lib": "std", + "core": "Cortex-M0" + }, + "left_intermediate": { + "inherits": ["base"], + "extra_labels_add": ["left_intermediate_label"] + }, + "right_intermediate": { + "inherits": ["base"], + "extra_labels_add": ["right_intermediate_label"] + }, + "both": { + "inherits": ["left_intermediate", "right_intermediate"] + } +} diff --git a/tools/test/config/override_with_labels/test_data.json b/tools/test/config/override_with_labels/test_data.json new file mode 100644 index 00000000000..7fbc15e7b7d --- /dev/null +++ b/tools/test/config/override_with_labels/test_data.json @@ -0,0 +1,18 @@ +{ + "left_intermediate": { + "app.app1": "v_app1[left_intermediate_label]", + "app.app2": "v_app2" + }, + "right_intermediate": { + "app.app1": "v_app1", + "app.app2": "v_app2[right_intermediate_label]" + }, + "both": { + "app.app1": "v_app1[left_intermediate_label]", + "app.app2": "v_app2[right_intermediate_label]" + }, + "base": { + "app.app1": "v_app1", + "app.app2": "v_app2" + } +} diff --git a/tools/test/config_test/test12/lib1/lib2/mbed_lib.json b/tools/test/config/parameter_outside_lib/lib1/lib2/mbed_lib.json similarity index 100% rename from tools/test/config_test/test12/lib1/lib2/mbed_lib.json rename to tools/test/config/parameter_outside_lib/lib1/lib2/mbed_lib.json diff --git a/tools/test/config_test/test11/lib1/mbed_lib.json b/tools/test/config/parameter_outside_lib/lib1/mbed_lib.json similarity index 100% rename from tools/test/config_test/test11/lib1/mbed_lib.json rename to tools/test/config/parameter_outside_lib/lib1/mbed_lib.json diff --git a/tools/test/config/parameter_outside_lib/test_data.json b/tools/test/config/parameter_outside_lib/test_data.json new file mode 100644 index 00000000000..1975443ec72 --- /dev/null +++ b/tools/test/config/parameter_outside_lib/test_data.json @@ -0,0 +1,5 @@ +{ + "K64F": { + "exception_msg": "Invalid prefix 'lib2' for parameter name 'lib2.p1' in 'library:lib1[K64F]'" + } +} diff --git a/tools/test/config_test/test21/mbed_app.json b/tools/test/config/simple_features/mbed_app.json similarity index 100% rename from tools/test/config_test/test21/mbed_app.json rename to tools/test/config/simple_features/mbed_app.json diff --git a/tools/test/config_test/test28/targets.json b/tools/test/config/simple_features/targets.json similarity index 100% rename from tools/test/config_test/test28/targets.json rename to tools/test/config/simple_features/targets.json diff --git a/tools/test/config/simple_features/test_data.json b/tools/test/config/simple_features/test_data.json new file mode 100644 index 00000000000..2639e0bc1f9 --- /dev/null +++ b/tools/test/config/simple_features/test_data.json @@ -0,0 +1,5 @@ +{ + "test_target": { + "expected_features": ["IPV4"] + } +} diff --git a/tools/test/config_test/test01/targets.json b/tools/test/config/simple_iheritance/targets.json similarity index 83% rename from tools/test/config_test/test01/targets.json rename to tools/test/config/simple_iheritance/targets.json index bf874e47de3..16083664779 100644 --- a/tools/test/config_test/test01/targets.json +++ b/tools/test/config/simple_iheritance/targets.json @@ -1,5 +1,5 @@ { - "b1": { + "first_base": { "extra_labels": [], "default_lib": "std", "core": "Cortex-M0", @@ -9,8 +9,8 @@ "base1_3": "v_base1_3_b1" } }, - "d1": { - "inherits": ["b1"], + "intermediate": { + "inherits": ["first_base"], "config": { "derived1": "v_derived1_d1", "derived2": "v_derived2_d1" @@ -20,14 +20,14 @@ "base1_2": "v_base1_2_d1" } }, - "b2": { + "second_base": { "config": { "base2_1": "v_base2_1_b2", "base2_2": "v_base2_2_b2" } }, - "f": { - "inherits": ["b2", "d1"], + "inherits_tree": { + "inherits": ["second_base", "intermediate"], "config": { "f1_1": "v_f1_1_f", "f1_2": "v_f1_2_f" diff --git a/tools/test/config/simple_iheritance/test_data.json b/tools/test/config/simple_iheritance/test_data.json new file mode 100644 index 00000000000..10ba4a7f69b --- /dev/null +++ b/tools/test/config/simple_iheritance/test_data.json @@ -0,0 +1,25 @@ +{ + "inherits_tree": { + "target.base1_1": "v_base1_1_f", + "target.base1_2": "v_base1_2_d1", + "target.base1_3": "v_base1_3_b1", + "target.derived1": "v_derived1_d1", + "target.derived2": "v_derived2_f", + "target.base2_1": "v_base2_1_f", + "target.base2_2": "v_base2_2_b2", + "target.f1_1": "v_f1_1_f_override", + "target.f1_2": "v_f1_2_f" + }, + "first_base": { + "target.base1_1": "v_base1_1_b1", + "target.base1_2": "v_base1_2_b1", + "target.base1_3": "v_base1_3_b1" + }, + "intermediate": { + "target.base1_1": "v_base1_1_d1", + "target.base1_2": "v_base1_2_d1", + "target.base1_3": "v_base1_3_b1", + "target.derived1": "v_derived1_d1", + "target.derived2": "v_derived2_d1" + } +} diff --git a/tools/test/config_test/config_test.py b/tools/test/config_test/config_test.py deleted file mode 100644 index ac7d1d1a7e1..00000000000 --- a/tools/test/config_test/config_test.py +++ /dev/null @@ -1,113 +0,0 @@ -""" -mbed SDK -Copyright (c) 2011-2016 ARM Limited - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -""" - -from tools.build_api import get_config -from tools.targets import set_targets_json_location, Target -from tools.config import ConfigException, Config -import os, sys - -# Compare the output of config against a dictionary of known good results -def compare_config(cfg, expected): - try: - for k in cfg: - if cfg[k].value != expected[k]: - return "'%s': expected '%s', got '%s'" % (k, expected[k], cfg[k].value) - except KeyError: - raise - return "Unexpected key '%s' in configuration data" % k - for k in expected: - if k not in ["desc", "expected_macros", "expected_features"] + cfg.keys(): - return "Expected key '%s' was not found in configuration data" % k - return "" - -def test_tree(full_name, name): - failed = 0 - sys.path.append(full_name) - if "test_data" in sys.modules: - del sys.modules["test_data"] - import test_data - # If the test defines custom targets, they must exist in a file called - # "targets.json" in the test's directory. - if os.path.isfile(os.path.join(full_name, "targets.json")): - set_targets_json_location(os.path.join(full_name, "targets.json")) - else: # uset the regular set of targets - set_targets_json_location() - for target, expected in test_data.expected_results.items(): - sys.stdout.write("%s:'%s'(%s) " % (name, expected["desc"], target)) - sys.stdout.flush() - err_msg = None - try: - cfg, macros, features = get_config(full_name, target, "GCC_ARM") - macros = Config.config_macros_to_macros(macros) - except ConfigException as e: - err_msg = e.message - if err_msg: - if expected.has_key("exception_msg"): - if err_msg.find(expected["exception_msg"]) == -1: - print "FAILED!" - sys.stderr.write(" Unexpected error message!\n") - sys.stderr.write(" Expected: '%s'\n" % expected["exception_msg"]) - sys.stderr.write(" Got: '%s'\n" % err_msg) - failed += 1 - else: - print "OK" - else: - print "FAILED!" - sys.stderr.write(" Error while getting configuration!\n") - sys.stderr.write(" " + err_msg + "\n") - 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 - 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 - -failed = 0 -root_dir = os.path.abspath(os.path.dirname(__file__)) -tlist = sorted(os.listdir(root_dir), key = lambda e: int(e[4:]) if e.startswith('test') else -1) -for test_name in tlist: - full_name = os.path.join(root_dir, test_name) - if os.path.isdir(full_name) and test_name.startswith('test'): - failed += test_tree(full_name, test_name) -sys.exit(failed) - diff --git a/tools/test/config_test/test01/test_data.py b/tools/test/config_test/test01/test_data.py deleted file mode 100644 index 878ae936900..00000000000 --- a/tools/test/config_test/test01/test_data.py +++ /dev/null @@ -1,46 +0,0 @@ -# Test for configuration data defined in targets -# A base target (B1) defines 3 configuration parameters (base1_1, base1_2 and base1_3) -# A derived target (D1) inherits drom B1 and defines one configuration parameters (derived1 and derived2) and overrides base1_1 and base1_2 -# Another base target (B2) defines its own configuration parameters (base2_1 and base2_2) -# The final target F derives from B2 and D1, defines two configuration paramaters (f1_1 and f1_2) -# and overrides base2_1, base1_1, derived2 and its own configuration parameter f1_1 (which is legal) -# Final result: -# base1_1 must have the value defined in F -# base1_2 must have the value defined in D1 -# base1_3 must have the value defined in B1 -# derived1 must have the value defined in D1 -# derived2 must have the value defined in F -# base2_1 must have the value defined in F -# base2_2 must have the value defined in B2 -# f1_1 must have the value defined and then overriden in F -# f1_2 must have the value defined in F - -expected_results = { - "f": { - "desc": "test multiple target inheritance", - "target.base1_1": "v_base1_1_f", - "target.base1_2": "v_base1_2_d1", - "target.base1_3": "v_base1_3_b1", - "target.derived1": "v_derived1_d1", - "target.derived2": "v_derived2_f", - "target.base2_1": "v_base2_1_f", - "target.base2_2": "v_base2_2_b2", - "target.f1_1": "v_f1_1_f_override", - "target.f1_2": "v_f1_2_f" - }, - "b1": { - "desc": "test with a single base target, no inheritance", - "target.base1_1": "v_base1_1_b1", - "target.base1_2": "v_base1_2_b1", - "target.base1_3": "v_base1_3_b1" - }, - "d1": { - "desc": "test single target inheritance", - "target.base1_1": "v_base1_1_d1", - "target.base1_2": "v_base1_2_d1", - "target.base1_3": "v_base1_3_b1", - "target.derived1": "v_derived1_d1", - "target.derived2": "v_derived2_d1" - } -} - diff --git a/tools/test/config_test/test02/test_data.py b/tools/test/config_test/test02/test_data.py deleted file mode 100644 index b915a17ed41..00000000000 --- a/tools/test/config_test/test02/test_data.py +++ /dev/null @@ -1,30 +0,0 @@ -# This is similar to test1, but this time B2 also inherits from B1, which allows it to override its config data. -# B2 also overrides base1_2, like D1. -# The order of inheritace in F is also reversed ([D1, B2] instead of [B2, D1]) -# Since the last override of base1_2 in inheritance order is in B2, base1_2 must now -# have the value that was overriden in B2, not in D1. -# This test also shows that multiple inheritance works for a simple diamond shaped inheritance pattern - -expected_results = { - "f": { - "desc": "test multiple target inheritance (diamond shape)", - "target.base1_1": "v_base1_1_f", - "target.base1_2": "v_base1_2_b2", - "target.base1_3": "v_base1_3_b1", - "target.derived1": "v_derived1_d1", - "target.derived2": "v_derived2_f", - "target.base2_1": "v_base2_1_f", - "target.base2_2": "v_base2_2_b2", - "target.f1_1": "v_f1_1_f_override", - "target.f1_2": "v_f1_2_f" - }, - "b2": { - "desc": "another single inheritance test", - "target.base1_1": "v_base1_1_b1", - "target.base1_2": "v_base1_2_b2", - "target.base1_3": "v_base1_3_b1", - "target.base2_1": "v_base2_1_b2", - "target.base2_2": "v_base2_2_b2" - } -} - diff --git a/tools/test/config_test/test03/test_data.py b/tools/test/config_test/test03/test_data.py deleted file mode 100644 index 3540131961a..00000000000 --- a/tools/test/config_test/test03/test_data.py +++ /dev/null @@ -1,18 +0,0 @@ -# Similar to test1, but this time B2 attempt to override base1_1. Since B2 doesn't directly inherit -# from B1, this must raise an error - -expected_results = { - "f": { - "desc": "attempt to override undefined parameter in inherited target", - "exception_msg": "Attempt to override undefined parameter 'base1_1' in 'target:b2'" - }, - "d1": { - "desc": "single target inheritance again", - "target.base1_1": "v_base1_1_d1", - "target.base1_2": "v_base1_2_d1", - "target.base1_3": "v_base1_3_b1", - "target.derived1": "v_derived1_d1", - "target.derived2": "v_derived2_d1" - } -} - diff --git a/tools/test/config_test/test04/test_data.py b/tools/test/config_test/test04/test_data.py deleted file mode 100644 index 50fbfcdb068..00000000000 --- a/tools/test/config_test/test04/test_data.py +++ /dev/null @@ -1,18 +0,0 @@ -# Similar to test1, but this time B2 attempt to define base1_1. Since base1_1 -# is already defined in B1 and F derives from both B1 and B2, this results -# in an error. However, when building for B2 instead of F, defining base1_1 -# should be OK. - -expected_results = { - "f": { - "desc": "attempt to redefine parameter in target inheritance tree", - "exception_msg": "Parameter name 'base1_1' defined in both 'target:b2' and 'target:b1'" - }, - "b2": { - "desc": "it should be OK to define parameters with the same name in non-related targets", - "target.base2_1": "v_base2_1_b2", - "target.base2_2": "v_base2_2_b2", - "target.base1_1": "v_base1_1_b2" - } -} - diff --git a/tools/test/config_test/test05/test_data.py b/tools/test/config_test/test05/test_data.py deleted file mode 100644 index 65ac4cd7180..00000000000 --- a/tools/test/config_test/test05/test_data.py +++ /dev/null @@ -1,29 +0,0 @@ -# This tests overriding configuration values based on target labels. -# Four targets are defined: -# - "base" is the base target, it doesn't define any extra labels -# - "b1" inherits from "base" and adds the "b1_label" label -# - "b2" inherits from "base" and adds the "b2_label" label -# - "both" inherits from both "b1" and "b2", so it inherits both labels - -expected_results = { - "b1": { - "desc": "override values based on labels (first label)", - "app.app1": "v_app1[b1_label]", - "app.app2": "v_app2" - }, - "b2": { - "desc": "override values based on labels (second label)", - "app.app1": "v_app1", - "app.app2": "v_app2[b2_label]" - }, - "both": { - "desc": "override values based on labels (both labels)", - "app.app1": "v_app1[b1_label]", - "app.app2": "v_app2[b2_label]" - }, - "base": { - "desc": "override values based on labels (no labels)", - "app.app1": "v_app1", - "app.app2": "v_app2" - } -} diff --git a/tools/test/config_test/test07/targets.json b/tools/test/config_test/test07/targets.json deleted file mode 100644 index d045de8670f..00000000000 --- a/tools/test/config_test/test07/targets.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "base": { - "extra_labels": [], - "default_lib": "std", - "core": "Cortex-M0" - }, - "b1": { - "inherits": ["base"], - "extra_labels_add": ["b1_label"] - }, - "b2": { - "inherits": ["base"], - "extra_labels_add": ["b2_label"] - }, - "both": { - "inherits": ["b1", "b2"] - } -} diff --git a/tools/test/config_test/test11/test_data.py b/tools/test/config_test/test11/test_data.py deleted file mode 100644 index 6bcaed1091e..00000000000 --- a/tools/test/config_test/test11/test_data.py +++ /dev/null @@ -1,9 +0,0 @@ -# Two libraries (lib1 and lib2) define their own configuration parameters -# lib1 tries to override a configuration parameter in lib2, which raises an error - -expected_results = { - "K64F": { - "desc": "lib1 trying to override a config parameter in lib2", - "exception_msg": "Invalid prefix 'lib2' for parameter name 'lib2.p1' in 'library:lib1[K64F]'" - } -} diff --git a/tools/test/config_test/test12/test_data.py b/tools/test/config_test/test12/test_data.py deleted file mode 100644 index d2489dc7732..00000000000 --- a/tools/test/config_test/test12/test_data.py +++ /dev/null @@ -1,14 +0,0 @@ -# Two libraries (lib1 and lib2) define their own configuration parameters -# The application config doesn't have any parameters itself, it just overrides the parameter -# named p1 from both lib1 and lib2. - -expected_results = { - "test_target": { - "desc": "app without its own parameters overrides parameters in other libs", - "lib1.p1": "v_p1_lib1_app", - "lib1.p2": "v_p2_lib1", - "lib1.p3": "v_p3_lib1", - "lib2.p1": "v_p1_lib2_app", - "lib2.p2": "v_p2_lib2" - } -} diff --git a/tools/test/config_test/test13/test_data.py b/tools/test/config_test/test13/test_data.py deleted file mode 100644 index 7d394e84ec1..00000000000 --- a/tools/test/config_test/test13/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Create two libraries named "lib1", which must raise an error - -expected_results = { - "K64F": { - "desc": "attempt to configure two libraries named 'lib1'", - "exception_msg": "Library name 'lib1' is not unique" - } -} diff --git a/tools/test/config_test/test14/test_data.py b/tools/test/config_test/test14/test_data.py deleted file mode 100644 index 1db33cd6d4c..00000000000 --- a/tools/test/config_test/test14/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Put an invalid key in the application configuration - -expected_results = { - "K64F": { - "desc": "invalid key in mbed_app_config.json", - "exception_msg": "Unknown key(s)" - } -} diff --git a/tools/test/config_test/test15/test_data.py b/tools/test/config_test/test15/test_data.py deleted file mode 100644 index 4518f78783f..00000000000 --- a/tools/test/config_test/test15/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Put an invalid key in the library configuration - -expected_results = { - "K64F": { - "desc": "invalid key in mbed_lib_config.json", - "exception_msg": "Unknown key(s)" - } -} diff --git a/tools/test/config_test/test16/test_data.py b/tools/test/config_test/test16/test_data.py deleted file mode 100644 index 5a106b742b9..00000000000 --- a/tools/test/config_test/test16/test_data.py +++ /dev/null @@ -1,12 +0,0 @@ -# Macro test: defined macros in the top level app and 2 libs, check if they -# are reported properly. -# The app defines one macro with value the same as lib2, while lib2 defined -# the same macro without value as lib1. Since the definitions are comptabile, -# no error should be raised - -expected_results = { - "test_target": { - "desc": "test macro definitions", - "expected_macros": ["APP1=10", "APP2", "LIB1_1=1","LIB1_2", "LIB2_1=5"] - } -} diff --git a/tools/test/config_test/test17/test_data.py b/tools/test/config_test/test17/test_data.py deleted file mode 100644 index b55da016d1c..00000000000 --- a/tools/test/config_test/test17/test_data.py +++ /dev/null @@ -1,9 +0,0 @@ -# Build on top of test16 -# Adds an invalid macro redefinition in the app - -expected_results = { - "K64F": { - "desc": "test invalid macro re-definition in the app", - "exception_msg": "Macro 'LIB2_1' defined in both 'library:lib2' and 'application' with incompatible values" - } -} diff --git a/tools/test/config_test/test18/test_data.py b/tools/test/config_test/test18/test_data.py deleted file mode 100644 index e2288333817..00000000000 --- a/tools/test/config_test/test18/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Like test17, but this time the invalid re-definition is in lib2, not in the app - -expected_results = { - "K64F": { - "desc": "test invalid macro re-definition in a library", - "exception_msg": "defined in both" - } -} diff --git a/tools/test/config_test/test19/mbed_app.json b/tools/test/config_test/test19/mbed_app.json deleted file mode 100644 index 6970156cd2a..00000000000 --- a/tools/test/config_test/test19/mbed_app.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "macros": [], - "invalid_key": "invalid_value" -} diff --git a/tools/test/config_test/test19/test_data.py b/tools/test/config_test/test19/test_data.py deleted file mode 100644 index 40e250b8653..00000000000 --- a/tools/test/config_test/test19/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Test that invalid keys in application configuration are not allowed - -expected_results = { - "K64F": { - "desc": "test invalid key in application config", - "exception_msg": "Unknown key(s) 'invalid_key'" - } -} diff --git a/tools/test/config_test/test20/lib1/mbed_lib.json b/tools/test/config_test/test20/lib1/mbed_lib.json deleted file mode 100644 index a42cdd3eba8..00000000000 --- a/tools/test/config_test/test20/lib1/mbed_lib.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "lib1", - "macros": [], - "invalid_key": "invalid_value" -} diff --git a/tools/test/config_test/test20/test_data.py b/tools/test/config_test/test20/test_data.py deleted file mode 100644 index 7e9f6461b93..00000000000 --- a/tools/test/config_test/test20/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Like test19, but this time check invalid key in a library configuration - -expected_results = { - "K64F": { - "desc": "test invalid key in lib config", - "exception_msg": "Unknown key(s) 'invalid_key'" - } -} diff --git a/tools/test/config_test/test21/test_data.py b/tools/test/config_test/test21/test_data.py deleted file mode 100644 index 4f7ae443e96..00000000000 --- a/tools/test/config_test/test21/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Testing basic features - -expected_results = { - "test_target": { - "desc": "test basic features", - "expected_features": ["IPV4"] - } -} diff --git a/tools/test/config_test/test22/test_data.py b/tools/test/config_test/test22/test_data.py deleted file mode 100644 index 5edfe17891e..00000000000 --- a/tools/test/config_test/test22/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Testing when adding two features - -expected_results = { - "test_target": { - "desc": "test composing features", - "expected_features": ["IPV4", "STORAGE"] - } -} diff --git a/tools/test/config_test/test24/test_data.py b/tools/test/config_test/test24/test_data.py deleted file mode 100644 index a77f0267589..00000000000 --- a/tools/test/config_test/test24/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Testing if features can enable other features - -expected_results = { - "test_target": { - "desc": "test recursive features", - "expected_features": ["IPV4", "STORAGE", "UVISOR"] - } -} diff --git a/tools/test/config_test/test25/test_data.py b/tools/test/config_test/test25/test_data.py deleted file mode 100644 index 360d392130e..00000000000 --- a/tools/test/config_test/test25/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Testing if feature collisions are detected accross recursive features - -expected_results = { - "K64F": { - "desc": "test recursive feature collisions", - "exception_msg": "Configuration conflict. The feature UVISOR both added and removed." - } -} diff --git a/tools/test/config_test/test26/test_data.py b/tools/test/config_test/test26/test_data.py deleted file mode 100644 index 2d16a8bf347..00000000000 --- a/tools/test/config_test/test26/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Testing if config settings work in recursive features - -expected_results = { - "test_target": { - "desc": "test recursive feature configurations", - "lib2.test": "GOOD" - } -} diff --git a/tools/test/config_test/test27/test_data.py b/tools/test/config_test/test27/test_data.py deleted file mode 100644 index 53853318a43..00000000000 --- a/tools/test/config_test/test27/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Testing when adding two features - -expected_results = { - "test_target": { - "desc": "test removing features", - "expected_features": [] - } -} diff --git a/tools/test/config_test/test28/test_data.py b/tools/test/config_test/test28/test_data.py deleted file mode 100644 index 4f69bfceef4..00000000000 --- a/tools/test/config_test/test28/test_data.py +++ /dev/null @@ -1,8 +0,0 @@ -# Testing when adding two features - -expected_results = { - "test_target": { - "desc": "test uvisor feature", - "expected_features": ["UVISOR"] - } -} diff --git a/tools/test/config_test/test29/test_data.py b/tools/test/config_test/test29/test_data.py deleted file mode 100644 index 935d3d9037a..00000000000 --- a/tools/test/config_test/test29/test_data.py +++ /dev/null @@ -1,6 +0,0 @@ -expected_results = { - "K64F": { - "desc": "error when bootloader not found", - "exception_msg": "not found" - } -} diff --git a/tools/test/memap/memap_test.py b/tools/test/memap/memap_test.py index 13fed8b73e8..a0c84dda51d 100644 --- a/tools/test/memap/memap_test.py +++ b/tools/test/memap/memap_test.py @@ -1,6 +1,6 @@ """ mbed SDK -Copyright (c) 2016 ARM Limited +Copyright (c) 2017 ARM Limited Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,13 +15,11 @@ limitations under the License. """ import sys -import os +from os.path import isfile, join import json -ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) -sys.path.insert(0, ROOT) +import pytest -import unittest from tools.memap import MemapParser from copy import deepcopy @@ -29,190 +27,184 @@ Tests for test_api.py """ -class MemapParserTests(unittest.TestCase): +@pytest.fixture +def memap_parser(): """ - Test cases for Test Api + Called before each test case + + :return: + """ + memap_parser = MemapParser() + + memap_parser.modules = { + "mbed-os/targets/TARGET/TARGET_MCUS/api/pinmap.o": { + ".text": 1, + ".data": 2, + ".bss": 3, + ".heap": 0, + ".stack": 0, + ".interrupts_ram":0, + ".init":0, + ".ARM.extab":0, + ".ARM.exidx":0, + ".ARM.attributes":0, + ".eh_frame":0, + ".init_array":0, + ".fini_array":0, + ".jcr":0, + ".stab":0, + ".stabstr":0, + ".ARM.exidx":0, + ".ARM":0, + ".interrupts":0, + ".flash_config":0, + "unknown":0, + "OUTPUT":0, + }, + "[lib]/libc.a/lib_a-printf.o": { + ".text": 4, + ".data": 5, + ".bss": 6, + ".heap": 0, + ".stack": 0, + ".interrupts_ram":0, + ".init":0, + ".ARM.extab":0, + ".ARM.exidx":0, + ".ARM.attributes":0, + ".eh_frame":0, + ".init_array":0, + ".fini_array":0, + ".jcr":0, + ".stab":0, + ".stabstr":0, + ".ARM.exidx":0, + ".ARM":0, + ".interrupts":0, + ".flash_config":0, + "unknown":0, + "OUTPUT":0, + }, + "main.o": { + ".text": 7, + ".data": 8, + ".bss": 0, + ".heap": 0, + ".stack": 0, + ".interrupts_ram":0, + ".init":0, + ".ARM.extab":0, + ".ARM.exidx":0, + ".ARM.attributes":0, + ".eh_frame":0, + ".init_array":0, + ".fini_array":0, + ".jcr":0, + ".stab":0, + ".stabstr":0, + ".ARM.exidx":0, + ".ARM":0, + ".interrupts":0, + ".flash_config":0, + "unknown":0, + "OUTPUT":0, + }, + "test.o": { + ".text": 0, + ".data": 0, + ".bss": 0, + ".heap": 0, + ".stack": 0, + ".interrupts_ram":0, + ".init":0, + ".ARM.extab":0, + ".ARM.exidx":0, + ".ARM.attributes":0, + ".eh_frame":0, + ".init_array":0, + ".fini_array":0, + ".jcr":0, + ".stab":0, + ".stabstr":0, + ".ARM.exidx":0, + ".ARM":0, + ".interrupts":0, + ".flash_config":0, + "unknown":0, + "OUTPUT":0, + }, + } + return memap_parser + + +def generate_test_helper(memap_parser, format, depth, file_output=None): + """ + Helper that tests that the member variables "modules" is + unchanged after calling "generate_output" + + :param memap_parser: the parser object + :param depth: how much detail to put in the report + :param format: the file type to output + :param file_output: the file to output to + """ + + old_modules = deepcopy(memap_parser.modules) + + memap_parser.generate_output(format, depth, file_output=file_output) + + assert memap_parser.modules == old_modules,\ + "generate_output modified the 'modules' property" + + +@pytest.mark.parametrize("depth", [1, 2, 20]) +def test_report_computed(memap_parser, depth): + """ + Test that a report and summary are computed + + :param memap_parser: Mocked parser + :param depth: the detail of the output + """ + + memap_parser.generate_output('table', depth) + + # Report is created after generating output + assert memap_parser.mem_summary + assert memap_parser.mem_report + + +@pytest.mark.parametrize("depth", [1, 2, 20]) +def test_generate_output_table(memap_parser, depth): """ + Test that an output of type "table" can be generated correctly + :param memap_parser: Mocked parser + :param depth: the detail of the output + """ + generate_test_helper(memap_parser, 'table', depth) + - def setUp(self): - """ - Called before each test case - - :return: - """ - self.memap_parser = MemapParser() - - self.memap_parser.modules = { - "mbed-os/targets/TARGET/TARGET_MCUS/api/pinmap.o": { - ".text": 1, - ".data": 2, - ".bss": 3, - ".heap": 0, - ".stack": 0, - ".interrupts_ram":0, - ".init":0, - ".ARM.extab":0, - ".ARM.exidx":0, - ".ARM.attributes":0, - ".eh_frame":0, - ".init_array":0, - ".fini_array":0, - ".jcr":0, - ".stab":0, - ".stabstr":0, - ".ARM.exidx":0, - ".ARM":0, - ".interrupts":0, - ".flash_config":0, - "unknown":0, - "OUTPUT":0, - }, - "[lib]/libc.a/lib_a-printf.o": { - ".text": 4, - ".data": 5, - ".bss": 6, - ".heap": 0, - ".stack": 0, - ".interrupts_ram":0, - ".init":0, - ".ARM.extab":0, - ".ARM.exidx":0, - ".ARM.attributes":0, - ".eh_frame":0, - ".init_array":0, - ".fini_array":0, - ".jcr":0, - ".stab":0, - ".stabstr":0, - ".ARM.exidx":0, - ".ARM":0, - ".interrupts":0, - ".flash_config":0, - "unknown":0, - "OUTPUT":0, - }, - "main.o": { - ".text": 7, - ".data": 8, - ".bss": 0, - ".heap": 0, - ".stack": 0, - ".interrupts_ram":0, - ".init":0, - ".ARM.extab":0, - ".ARM.exidx":0, - ".ARM.attributes":0, - ".eh_frame":0, - ".init_array":0, - ".fini_array":0, - ".jcr":0, - ".stab":0, - ".stabstr":0, - ".ARM.exidx":0, - ".ARM":0, - ".interrupts":0, - ".flash_config":0, - "unknown":0, - "OUTPUT":0, - }, - "test.o": { - ".text": 0, - ".data": 0, - ".bss": 0, - ".heap": 0, - ".stack": 0, - ".interrupts_ram":0, - ".init":0, - ".ARM.extab":0, - ".ARM.exidx":0, - ".ARM.attributes":0, - ".eh_frame":0, - ".init_array":0, - ".fini_array":0, - ".jcr":0, - ".stab":0, - ".stabstr":0, - ".ARM.exidx":0, - ".ARM":0, - ".interrupts":0, - ".flash_config":0, - "unknown":0, - "OUTPUT":0, - }, - } - - def tearDown(self): - """ - Called after each test case - - :return: - """ - pass - - def generate_test_helper(self, output_type, depth, file_output=None): - """ - Helper that ensures that the member variables "modules" is - unchanged after calling "generate_output" - - :param output_type: type string that is passed to "generate_output" - :param file_output: path to output file that is passed to "generate_output" - :return: - """ - - old_modules = deepcopy(self.memap_parser.modules) - - self.memap_parser.generate_output(output_type, depth, file_output) - - self.assertEqual(self.memap_parser.modules, old_modules, - "generate_output modified the 'modules' property") - - - def test_report_computed(self): - """ - Test ensures the report and summary are computed - - :return: - """ - - self.memap_parser.generate_output('table', 2) - - # Report is created after generating output - self.assertTrue(self.memap_parser.mem_summary) - self.assertTrue(self.memap_parser.mem_report) - - def test_generate_output_table(self): - """ - Test ensures that an output of type "table" can be generated correctly - - :return: - """ - depth = 2 - self.generate_test_helper('table', depth) - - def test_generate_output_json(self): - """ - Test ensures that an output of type "json" can be generated correctly - - :return: - """ - file_name = '.json_test_output.json' - depth = 2 - self.generate_test_helper('json', depth, file_output=file_name) - self.assertTrue(os.path.exists(file_name), "Failed to create json file") - os.remove(file_name) - - def test_generate_output_csv_ci(self): - """ - Test ensures that an output of type "csv-ci" can be generated correctly - - :return: - """ - file_name = '.csv_ci_test_output.csv' - depth = 2 - self.generate_test_helper('csv-ci', depth, file_output=file_name) - self.assertTrue(os.path.exists(file_name), "Failed to create csv-ci file") - os.remove(file_name) - - -if __name__ == '__main__': - unittest.main() +@pytest.mark.parametrize("depth", [1, 2, 20]) +def test_generate_output_json(memap_parser, tmpdir, depth): + """ + Test that an output of type "json" can be generated correctly + :param memap_parser: Mocked parser + :param tmpdir: a unique location to place an output file + :param depth: the detail of the output + """ + file_name = str(tmpdir.join('output.json').realpath()) + generate_test_helper(memap_parser, 'json', depth, file_name) + assert isfile(file_name), "Failed to create json file" + json.load(open(file_name)) + + +@pytest.mark.parametrize("depth", [1, 2, 20]) +def test_generate_output_csv_ci(memap_parser, tmpdir, depth): + """ + Test ensures that an output of type "csv-ci" can be generated correctly + + :param memap_parser: Mocked parser + :param tmpdir: a unique location to place an output file + :param depth: the detail of the output + """ + file_name = str(tmpdir.join('output.csv').realpath()) + generate_test_helper(memap_parser, 'csv-ci', depth, file_name) + assert isfile(file_name), "Failed to create csv-ci file" diff --git a/tools/test/targets/target_test.py b/tools/test/targets/target_test.py index 0e555ca74b7..eff7b3f305e 100644 --- a/tools/test/targets/target_test.py +++ b/tools/test/targets/target_test.py @@ -21,121 +21,113 @@ import tempfile from os.path import join, abspath, dirname from contextlib import contextmanager -import unittest - -# Be sure that the tools directory is in the search path - -ROOT = abspath(join(dirname(__file__), "..", "..", "..")) -sys.path.insert(0, ROOT) +import pytest from tools.targets import TARGETS, TARGET_MAP, Target, update_target_data from tools.arm_pack_manager import Cache -class TestTargets(unittest.TestCase): - - def test_device_name(self): - """Assert device name is in a pack""" - cache = Cache(True, True) - named_targets = (target for target in TARGETS if - hasattr(target, "device_name")) - for target in named_targets: - self.assertTrue(target.device_name in cache.index, - "Target %s contains invalid device_name %s" % - (target.name, target.device_name)) +def test_device_name(): + """Assert device name is in a pack""" + cache = Cache(True, True) + named_targets = (target for target in TARGETS if + hasattr(target, "device_name")) + for target in named_targets: + assert target.device_name in cache.index,\ + ("Target %s contains invalid device_name %s" % + (target.name, target.device_name)) + +@contextmanager +def temp_target_file(extra_target, json_filename='custom_targets.json'): + """Create an extra targets temp file in a context manager + + :param extra_target: the contents of the extra targets temp file + """ + tempdir = tempfile.mkdtemp() + try: + targetfile = os.path.join(tempdir, json_filename) + with open(targetfile, 'w') as f: + f.write(extra_target) + yield tempdir + finally: + # Reset extra targets + Target.set_targets_json_location() + # Delete temp files + shutil.rmtree(tempdir) + +def test_add_extra_targets(): + """Search for extra targets json in a source folder""" + test_target_json = """ + { + "Test_Target": { + "inherits": ["Target"] + } + } + """ + with temp_target_file(test_target_json) as source_dir: + Target.add_extra_targets(source_dir=source_dir) + update_target_data() + + assert 'Test_Target' in TARGET_MAP + assert TARGET_MAP['Test_Target'].core is None, \ + "attributes should be inherited from Target" + +def test_modify_existing_target(): + """Set default targets file, then override base Target definition""" + initial_target_json = """ + { + "Target": { + "core": null, + "default_toolchain": "ARM", + "supported_toolchains": null, + "extra_labels": [], + "is_disk_virtual": false, + "macros": [], + "device_has": [], + "features": [], + "detect_code": [], + "public": false, + "default_lib": "std", + "bootloader_supported": false + }, + "Test_Target": { + "inherits": ["Target"], + "core": "Cortex-M4", + "supported_toolchains": ["ARM"] + } + }""" + + test_target_json = """ + { + "Target": { + "core": "Cortex-M0", + "default_toolchain": "GCC_ARM", + "supported_toolchains": null, + "extra_labels": [], + "is_disk_virtual": false, + "macros": [], + "device_has": [], + "features": [], + "detect_code": [], + "public": false, + "default_lib": "std", + "bootloader_supported": true + } + } + """ - @contextmanager - def temp_target_file(self, extra_target, json_filename='custom_targets.json'): - """Create an extra targets temp file in a context manager""" - tempdir = tempfile.mkdtemp() - try: - targetfile = os.path.join(tempdir, json_filename) - with open(targetfile, 'w') as f: - f.write(extra_target) - yield tempdir - finally: - # Reset extra targets - Target.set_targets_json_location() - # Delete temp files - shutil.rmtree(tempdir) + with temp_target_file(initial_target_json, json_filename="targets.json") as targets_dir: + Target.set_targets_json_location(os.path.join(targets_dir, "targets.json")) + update_target_data() + assert TARGET_MAP["Test_Target"].core == "Cortex-M4" + assert TARGET_MAP["Test_Target"].default_toolchain == 'ARM' + assert TARGET_MAP["Test_Target"].bootloader_supported == False - def test_add_extra_targets(self): - """Search for extra targets json in a source folder""" - test_target_json = """ - { - "Test_Target": { - "inherits": ["Target"] - } - } - """ - with self.temp_target_file(test_target_json) as source_dir: + with temp_target_file(test_target_json) as source_dir: Target.add_extra_targets(source_dir=source_dir) update_target_data() - assert 'Test_Target' in TARGET_MAP - assert TARGET_MAP['Test_Target'].core is None, \ - "attributes should be inherited from Target" - - def test_modify_existing_target(self): - """Set default targets file, then override base Target definition""" - initial_target_json = """ - { - "Target": { - "core": null, - "default_toolchain": "ARM", - "supported_toolchains": null, - "extra_labels": [], - "is_disk_virtual": false, - "macros": [], - "device_has": [], - "features": [], - "detect_code": [], - "public": false, - "default_lib": "std", - "bootloader_supported": false - }, - "Test_Target": { - "inherits": ["Target"], - "core": "Cortex-M4", - "supported_toolchains": ["ARM"] - } - }""" - - test_target_json = """ - { - "Target": { - "core": "Cortex-M0", - "default_toolchain": "GCC_ARM", - "supported_toolchains": null, - "extra_labels": [], - "is_disk_virtual": false, - "macros": [], - "device_has": [], - "features": [], - "detect_code": [], - "public": false, - "default_lib": "std", - "bootloader_supported": true - } - } - """ - - with self.temp_target_file(initial_target_json, json_filename="targets.json") as targets_dir: - Target.set_targets_json_location(os.path.join(targets_dir, "targets.json")) - update_target_data() assert TARGET_MAP["Test_Target"].core == "Cortex-M4" - assert TARGET_MAP["Test_Target"].default_toolchain == 'ARM' - assert TARGET_MAP["Test_Target"].bootloader_supported == False - - with self.temp_target_file(test_target_json) as source_dir: - Target.add_extra_targets(source_dir=source_dir) - update_target_data() - - assert TARGET_MAP["Test_Target"].core == "Cortex-M4" - # The existing target should not be modified by custom targets - assert TARGET_MAP["Test_Target"].default_toolchain != 'GCC_ARM' - assert TARGET_MAP["Test_Target"].bootloader_supported != True - - -if __name__ == '__main__': - unittest.main() + # The existing target should not be modified by custom targets + assert TARGET_MAP["Test_Target"].default_toolchain != 'GCC_ARM' + assert TARGET_MAP["Test_Target"].bootloader_supported != True diff --git a/tools/test/test_api/test_api_test.py b/tools/test/test_api/test_api_test.py index 9f16941b04d..ef3a977c326 100644 --- a/tools/test/test_api/test_api_test.py +++ b/tools/test/test_api/test_api_test.py @@ -15,127 +15,79 @@ limitations under the License. """ -import unittest +import pytest from mock import patch +from tools.targets import set_targets_json_location from tools.test_api import find_tests, build_tests """ Tests for test_api.py """ -class TestApiTests(unittest.TestCase): +def setUp(self): """ - Test cases for Test Api + Called before each test case + + :return: + """ + self.base_dir = 'base_dir' + self.target = "K64F" + self.toolchain_name = "ARM" + +@pytest.mark.parametrize("base_dir", ["base_dir"]) +@pytest.mark.parametrize("target", ["K64F"]) +@pytest.mark.parametrize("toolchain_name", ["ARM"]) +@pytest.mark.parametrize("app_config", ["app_config", None]) +def test_find_tests_app_config(base_dir, target, toolchain_name, app_config): """ + Test find_tests for correct use of app_config - def setUp(self): - """ - Called before each test case - - :return: - """ - self.base_dir = 'base_dir' - self.target = "K64F" - self.toolchain_name = "ARM" - - def tearDown(self): - """ - Called after each test case - - :return: - """ - pass - - @patch('tools.test_api.scan_resources') - @patch('tools.test_api.prepare_toolchain') - def test_find_tests_app_config(self, mock_prepare_toolchain, mock_scan_resources): - """ - Test find_tests for correct use of app_config - - :param mock_prepare_toolchain: mock of function prepare_toolchain - :param mock_scan_resources: mock of function scan_resources - :return: - """ - app_config = "app_config" + :param base_dir: dummy value for the test base directory + :param target: the target to "test" for + :param toolchain_name: the toolchain to use for "testing" + :param app_config: Application configuration parameter to find tests + """ + set_targets_json_location() + with patch('tools.test_api.scan_resources') as mock_scan_resources,\ + patch('tools.test_api.prepare_toolchain') as mock_prepare_toolchain: mock_scan_resources().inc_dirs.return_value = [] - find_tests(self.base_dir, self.target, self.toolchain_name, app_config=app_config) + find_tests(base_dir, target, toolchain_name, app_config=app_config) args = mock_prepare_toolchain.call_args - self.assertTrue('app_config' in args[1], - "prepare_toolchain was not called with app_config") - self.assertEqual(args[1]['app_config'], app_config, - "prepare_toolchain was called with an incorrect app_config") - - @patch('tools.test_api.scan_resources') - @patch('tools.test_api.prepare_toolchain') - def test_find_tests_no_app_config(self, mock_prepare_toolchain, mock_scan_resources): - """ - Test find_tests correctly deals with no app_config - - :param mock_prepare_toolchain: mock of function prepare_toolchain - :param mock_scan_resources: mock of function scan_resources - :return: - """ - mock_scan_resources().inc_dirs.return_value = [] + assert 'app_config' in args[1],\ + "prepare_toolchain was not called with app_config" + assert args[1]['app_config'] == app_config,\ + "prepare_toolchain was called with an incorrect app_config" - find_tests(self.base_dir, self.target, self.toolchain_name) - args = mock_prepare_toolchain.call_args - self.assertTrue('app_config' in args[1], - "prepare_toolchain was not called with app_config") - self.assertEqual(args[1]['app_config'], None, - "prepare_toolchain was called with an incorrect app_config") - - @patch('tools.test_api.scan_resources') - @patch('tools.test_api.build_project') - def test_build_tests_app_config(self, mock_build_project, mock_scan_resources): - """ - Test build_tests for correct use of app_config - - :param mock_prepare_toolchain: mock of function prepare_toolchain - :param mock_scan_resources: mock of function scan_resources - :return: - """ - tests = {'test1': 'test1_path','test2': 'test2_path'} - src_paths = ['.'] - build_path = "build_path" - app_config = "app_config" - mock_build_project.return_value = "build_project" - - build_tests(tests, src_paths, build_path, self.target, self.toolchain_name, - app_config=app_config) +@pytest.mark.parametrize("build_path", ["build_path"]) +@pytest.mark.parametrize("target", ["K64F"]) +@pytest.mark.parametrize("toolchain_name", ["ARM"]) +@pytest.mark.parametrize("app_config", ["app_config", None]) +def test_find_tests_app_config(build_path, target, toolchain_name, app_config): + """ + Test find_tests for correct use of app_config - arg_list = mock_build_project.call_args_list - for args in arg_list: - self.assertTrue('app_config' in args[1], - "build_tests was not called with app_config") - self.assertEqual(args[1]['app_config'], app_config, - "build_tests was called with an incorrect app_config") - - @patch('tools.test_api.scan_resources') - @patch('tools.test_api.build_project') - def test_build_tests_no_app_config(self, mock_build_project, mock_scan_resources): - """ - Test build_tests correctly deals with no app_config - - :param mock_prepare_toolchain: mock of function prepare_toolchain - :param mock_scan_resources: mock of function scan_resources - :return: - """ - tests = {'test1': 'test1_path', 'test2': 'test2_path'} - src_paths = ['.'] - build_path = "build_path" + :param base_dir: dummy value for the test base directory + :param target: the target to "test" for + :param toolchain_name: the toolchain to use for "testing" + :param app_config: Application configuration parameter to find tests + """ + tests = {'test1': 'test1_path','test2': 'test2_path'} + src_paths = ['.'] + set_targets_json_location() + with patch('tools.test_api.scan_resources') as mock_scan_resources,\ + patch('tools.test_api.build_project') as mock_build_project: mock_build_project.return_value = "build_project" + mock_scan_resources().inc_dirs.return_value = [] - build_tests(tests, src_paths, build_path, self.target, self.toolchain_name) + build_tests(tests, src_paths, build_path, target, toolchain_name, + app_config=app_config) arg_list = mock_build_project.call_args_list for args in arg_list: - self.assertTrue('app_config' in args[1], - "build_tests was not called with app_config") - self.assertEqual(args[1]['app_config'], None, - "build_tests was called with an incorrect app_config") - -if __name__ == '__main__': - unittest.main() + assert 'app_config' in args[1],\ + "build_tests was not called with app_config" + assert args[1]['app_config'] == app_config,\ + "build_tests was called with an incorrect app_config" diff --git a/tools/test/toolchains/api.py b/tools/test/toolchains/api_test.py similarity index 100% rename from tools/test/toolchains/api.py rename to tools/test/toolchains/api_test.py diff --git a/tools/test_api.py b/tools/test_api.py index 70cc6d234d1..91cbcd9506e 100644 --- a/tools/test_api.py +++ b/tools/test_api.py @@ -2198,9 +2198,10 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name, results.remove(r) # Take report from the kwargs and merge it into existing report - report_entry = worker_result['kwargs']['report'][target_name][toolchain_name] - for test_key in report_entry.keys(): - report[target_name][toolchain_name][test_key] = report_entry[test_key] + if report: + report_entry = worker_result['kwargs']['report'][target_name][toolchain_name] + for test_key in report_entry.keys(): + report[target_name][toolchain_name][test_key] = report_entry[test_key] # Set the overall result to a failure if a build failure occurred if ('reason' in worker_result and @@ -2224,7 +2225,8 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name, } test_key = worker_result['kwargs']['project_id'].upper() - print report[target_name][toolchain_name][test_key][0][0]['output'].rstrip() + if report: + print report[target_name][toolchain_name][test_key][0][0]['output'].rstrip() print 'Image: %s\n' % bin_file except: