Example #1
0
    def test_arm_c_lib(self):
        """Test that linker flags are correctly added to an instance of ARM."""
        mock_target = mock.MagicMock()
        mock_target.core = "Cortex-M4"
        mock_target.supported_c_libs = {"arm": ["small"]}
        mock_target.c_lib = "sMALL"
        del mock_target.default_lib
        mock_target.default_toolchain = "ARM"
        mock_target.supported_toolchains = ["ARM", "uARM", "ARMC5", "ARMC6"]
        arm_std_obj = ARM_STD(mock_target)
        arm_micro_obj = ARM_MICRO(mock_target)

        mock_target.default_toolchain = "ARMC6"
        arm_c6_obj = ARMC6(mock_target)

        self.assertIn("-D__MICROLIB", arm_std_obj.flags["common"])
        self.assertIn("-D__MICROLIB", arm_micro_obj.flags["common"])
        self.assertIn("-D__MICROLIB", arm_c6_obj.flags["common"])

        self.assertIn("--library_type=microlib", arm_std_obj.flags["ld"])
        self.assertIn("--library_type=microlib", arm_micro_obj.flags["ld"])
        self.assertIn("--library_type=microlib", arm_c6_obj.flags["ld"])

        self.assertIn("-Wl,--library_type=microlib", arm_c6_obj.flags["cxx"])
        self.assertIn("--library_type=microlib", arm_c6_obj.flags["asm"])
Example #2
0
def test_armc6(supported_toolchains, core):
    mock_target = MagicMock()
    mock_target.core = "Cortex-" + core
    mock_target.supported_toolchains = supported_toolchains
    try:
        ARMC6(mock_target)
        assert "ARM" in supported_toolchains or "ARMC6" in supported_toolchains
        assert mock_target.core in ARMC6_CORES
    except NotSupportedException:
        assert ("ARM" not in supported_toolchains and "ARMC6" not in supported_toolchains)\
            or mock_target.core not in ARMC6_CORES
Example #3
0
 def test_arm_c_lib_std_exception(self):
     """Test that an exception is raised if the std C library is not supported for a target on the ARM toolchain."""
     mock_target = mock.MagicMock()
     mock_target.core = "Cortex-M4"
     mock_target.supported_toolchains = ["ARM", "uARM", "ARMC5"]
     mock_target.default_toolchain = "ARM"
     mock_target.c_lib = "std"
     del mock_target.default_lib
     mock_target.supported_c_libs = {"arm": ["small"]}
     with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.c_lib)):
         ARM_STD(mock_target)
     with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.c_lib)):
         ARMC6(mock_target)
Example #4
0
    def test_arm_minimal_printf(self):
        """Test that linker flags are correctly added to an instance of ARM."""
        mock_target = mock.MagicMock()
        mock_target.core = "Cortex-M4"
        mock_target.printf_lib = "minimal-printf"
        mock_target.supported_toolchains = ["ARM", "uARM", "ARMC5"]

        arm_std_obj = ARM_STD(mock_target)
        arm_micro_obj = ARM_MICRO(mock_target)
        arm_c6_obj = ARMC6(mock_target)

        self.assertIn("-DMBED_MINIMAL_PRINTF", arm_std_obj.flags["common"])
        self.assertIn("-DMBED_MINIMAL_PRINTF", arm_micro_obj.flags["common"])
        self.assertIn("-DMBED_MINIMAL_PRINTF", arm_c6_obj.flags["common"])
Example #5
0
    def test_arm_small_c_lib_swap_std_lib(self):
        """Test that no exception is raised when small c lib is not supported but std lib is supported."""
        mock_target = mock.MagicMock()
        mock_target.core = "Cortex-M4"
        mock_target.c_lib = "small"
        del mock_target.default_lib
        mock_target.supported_c_libs = {"arm": ["std"]}
        mock_target.supported_toolchains = ["ARM", "uARM", "ARMC5"]

        mock_target.default_toolchain = "ARM"
        try:
            ARM_STD(mock_target)
        except NotSupportedException:
            self.fail(
                UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.c_lib))

        mock_target.default_toolchain = "ARMC6"
        try:
            ARMC6(mock_target)
        except NotSupportedException:
            self.fail(
                UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.c_lib))