Beispiel #1
0
    def test_correct_arguments_passed(self):
        target = dict()
        target["labels"] = ["foo"]
        target["extra_labels"] = ["morefoo"]
        target["features"] = ["bar"]
        target["components"] = ["baz"]
        target["macros"] = ["macbaz"]
        target["device_has"] = ["stuff"]
        target["c_lib"] = ["c_lib"]
        target["core"] = ["core"]
        target["printf_lib"] = ["printf_lib"]
        target["supported_form_factors"] = ["arduino"]
        config = ConfigFactory()
        mbed_target = "K64F"
        toolchain_name = "GCC"
        target["supported_c_libs"] = {toolchain_name.lower(): ["small", "std"]}

        result = generate_mbed_config_cmake_file(mbed_target, target, config,
                                                 toolchain_name)

        self.assertEqual(
            result,
            _render_mbed_config_cmake_template(
                target,
                config,
                toolchain_name,
                mbed_target,
            ),
        )
Beispiel #2
0
    def test_returns_rendered_content(self):
        target = dict()
        target["labels"] = ["foo"]
        target["extra_labels"] = ["morefoo"]
        target["features"] = ["bar"]
        target["components"] = ["baz"]
        target["macros"] = ["macbaz"]
        target["device_has"] = ["stuff"]
        target["core"] = ["core"]
        target["c_lib"] = ["c_lib"]
        target["printf_lib"] = ["printf_lib"]
        target["supported_form_factors"] = ["arduino"]
        config = ConfigFactory()
        toolchain_name = "baz"
        target["supported_c_libs"] = {toolchain_name.lower(): ["small", "std"]}
        result = _render_mbed_config_cmake_template(target, config,
                                                    toolchain_name,
                                                    "target_name")

        for label in target["labels"] + target["extra_labels"]:
            self.assertIn(label, result)

        for macro in target["features"] + target["components"] + [
                toolchain_name
        ]:
            self.assertIn(macro, result)

        for toolchain in target["supported_c_libs"]:
            self.assertIn(toolchain, result)
            for supported_c_libs in toolchain:
                self.assertIn(supported_c_libs, result)
Beispiel #3
0
    def test_correct_arguments_passed(self, get_target_by_name,
                                      assemble_config, datetime):
        target = mock.Mock()
        target.labels = ["foo"]
        target.features = ["bar"]
        target.components = ["baz"]
        target.macros = ["macbaz"]
        target.device_has = ["stuff"]
        target.core = ["core"]
        target.supported_form_factors = ["arduino"]
        datetime = mock.Mock()
        datetime.datetime.now.return_value.timestamp.return_value = 2
        config = ConfigFactory()
        assemble_config.return_value = config
        get_target_by_name.return_value = target
        mbed_target = "K64F"
        program_path = "blinky"
        toolchain_name = "GCC"

        result = generate_mbed_config_cmake_file(mbed_target, program_path,
                                                 toolchain_name)

        get_target_by_name.assert_called_once_with(mbed_target, program_path)
        assemble_config.assert_called_once_with(mbed_target,
                                                pathlib.Path(program_path))
        self.assertEqual(
            result,
            _render_mbed_config_cmake_template(
                target,
                config,
                toolchain_name,
                mbed_target,
            ),
        )
Beispiel #4
0
    def test_returns_quoted_content(self, fake_target):
        config = ConfigFactory()
        source = SourceFactory()

        # Add an option whose value contains quotes to the config.
        _create_config_option(config, "iotc-mqtt-host",
                              '{"mqtt.2030.ltsapis.goog", IOTC_MQTT_PORT}',
                              source)

        result = _render_mbed_config_cmake_template(fake_target, config,
                                                    TOOLCHAIN_NAME,
                                                    "target_name")
        assert '"-DMBED_CONF_IOTC_MQTT_HOST={\\"mqtt.2030.ltsapis.goog\\", IOTC_MQTT_PORT}"' in result
Beispiel #5
0
    def test_correct_arguments_passed(self, fake_target):
        config = ConfigFactory()
        mbed_target = "K64F"

        result = generate_mbed_config_cmake_file(mbed_target, fake_target,
                                                 config, TOOLCHAIN_NAME)

        assert result == _render_mbed_config_cmake_template(
            fake_target,
            config,
            TOOLCHAIN_NAME,
            mbed_target,
        )
Beispiel #6
0
    def test_returns_rendered_content(self):
        target = mock.Mock()
        target.labels = ["foo"]
        target.features = ["bar"]
        target.components = ["baz"]
        target.macros = ["macbaz"]
        target.device_has = ["stuff"]
        target.core = ["core"]
        target.supported_form_factors = ["arduino"]
        config = ConfigFactory()
        toolchain_name = "baz"
        result = _render_mbed_config_cmake_template(target, config,
                                                    toolchain_name,
                                                    "target_name")

        for label in target.labels:
            self.assertIn(label, result)

        for macro in target.features + target.components + [toolchain_name]:
            self.assertIn(macro.upper(), result)
Beispiel #7
0
    def test_returns_rendered_content(self, fake_target):
        config = ConfigFactory()
        result = _render_mbed_config_cmake_template(fake_target, config,
                                                    TOOLCHAIN_NAME,
                                                    "target_name")

        for label in fake_target["labels"] + fake_target["extra_labels"]:
            assert label in result

        for macro in fake_target["features"] + fake_target["components"] + [
                TOOLCHAIN_NAME
        ]:
            assert macro in result

        for toolchain in fake_target["supported_c_libs"]:
            assert toolchain in result
            for supported_c_libs in toolchain:
                assert supported_c_libs in result

        for supported_application_profiles in fake_target[
                "supported_application_profiles"]:
            assert supported_application_profiles in result