Fixed the build tools test case failure,incorporated review comments

pull/12068/head
Rajkumar Kanagaraj 2019-12-10 09:20:34 -08:00
parent 957dca2082
commit 6d081eeb70
36 changed files with 240 additions and 54 deletions

View File

@ -36,8 +36,25 @@
],
"target_overrides": {
"*": {
"target.default_lib": "small",
"mbed-trace.fea-ipv6": false
},
"K64F": {
"target.default_lib": "small"
},
"K66F": {
"target.default_lib": "small"
},
"NUCLEO_F303RE": {
"target.default_lib": "small"
},
"NUCLEO_F411RE": {
"target.default_lib": "small"
},
"NUCLEO_F429ZI": {
"target.default_lib": "small"
},
"DISCO_L475VG_IOT01A": {
"target.default_lib": "small"
}
}
}

View File

@ -116,6 +116,8 @@ Case cases[] = {
Case("C strings: %u %d integer formatting", test_case_c_string_u_d, greentea_failure_handler),
Case("C strings: %x %E integer formatting", test_case_c_string_x_X, greentea_failure_handler),
#if !defined(__NEWLIB_NANO)
//In build tools, GCC with Newlib-nano linker option "-u _printf_float" is not configured
//to enable printf floating format. So disabling floating format test case.
Case("C strings: %f %f float formatting", test_case_c_string_f_f, greentea_failure_handler),
#ifndef MBED_MINIMAL_PRINTF
Case("C strings: %e %E float formatting", test_case_c_string_e_E, greentea_failure_handler),

View File

@ -52,6 +52,7 @@ static control_t test_printf_d(const size_t call_count)
/*************************************************************************/
/*************************************************************************/
#if !defined(__NEWLIB_NANO)
// The format specifier %hhd is not supported by Newlib-Nano
result_minimal = mbed_printf("hhd: %hhd\r\n", SCHAR_MIN);
result_file = mbed_fprintf(stderr, "hhd: %hhd\r\n", SCHAR_MIN);
result_baseline = printf("hhd: %hhd\r\n", SCHAR_MIN);
@ -102,6 +103,7 @@ static control_t test_printf_d(const size_t call_count)
TEST_ASSERT_EQUAL_INT(result_baseline, result_file);
#if !defined(__NEWLIB_NANO)
// The format specifier %lld is not supported by Newlib-Nano
result_minimal = mbed_printf("lld: %lld\r\n", LLONG_MIN);
result_file = mbed_fprintf(stderr, "lld: %lld\r\n", LLONG_MIN);
result_baseline = printf("lld: %lld\r\n", LLONG_MIN);
@ -175,6 +177,7 @@ static control_t test_printf_u(const size_t call_count)
/*************************************************************************/
/*************************************************************************/
#if !defined(__NEWLIB_NANO)
// The format specifier %hhu is not supported by Newlib-Nano
result_minimal = mbed_printf("hhu: %hhu\r\n", 0);
result_file = mbed_fprintf(stderr, "hhu: %hhu\r\n", 0);
result_baseline = printf("hhu: %hhu\r\n", 0);
@ -224,6 +227,7 @@ static control_t test_printf_u(const size_t call_count)
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
TEST_ASSERT_EQUAL_INT(result_baseline, result_file);
#if !defined(__NEWLIB_NANO)
// The format specifier %llu is not supported by Newlib-Nano
result_minimal = mbed_printf("llu: %llu\r\n", 0ULL);
result_file = mbed_fprintf(stderr, "llu: %llu\r\n", 0ULL);
result_baseline = printf("llu: %llu\r\n", 0ULL);
@ -297,6 +301,7 @@ static control_t test_printf_x(const size_t call_count)
/*************************************************************************/
/*************************************************************************/
#if !defined(__NEWLIB_NANO)
// The format specifier %hhX is not supported by Newlib-Nano
result_minimal = mbed_printf("hhX: %hhX\r\n", 0);
result_file = mbed_fprintf(stderr, "hhX: %hhX\r\n", 0);
result_baseline = printf("hhX: %hhX\r\n", 0);
@ -346,6 +351,7 @@ static control_t test_printf_x(const size_t call_count)
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
TEST_ASSERT_EQUAL_INT(result_baseline, result_file);
#if !defined(__NEWLIB_NANO)
// The format specifier %llX is not supported by Newlib-Nano
result_minimal = mbed_printf("llX: %llX\r\n", 0ULL);
result_file = mbed_fprintf(stderr, "llX: %llX\r\n", 0ULL);
result_baseline = printf("llX: %llX\r\n", 0ULL);
@ -445,6 +451,7 @@ static control_t test_snprintf_d(const size_t call_count)
/*************************************************************************/
/*************************************************************************/
#if !defined(__NEWLIB_NANO)
// The format specifier %hhd is not supported by Newlib-Nano
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "hhd: %hhd\r\n", SCHAR_MIN);
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "hhd: %hhd\r\n", SCHAR_MIN);
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@ -487,6 +494,7 @@ static control_t test_snprintf_d(const size_t call_count)
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
#if !defined(__NEWLIB_NANO)
// The format specifier %lld is not supported by Newlib-Nano
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "lld: %lld\r\n", LLONG_MIN);
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "lld: %lld\r\n", LLONG_MIN);
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@ -553,6 +561,7 @@ static control_t test_snprintf_u(const size_t call_count)
/*************************************************************************/
/*************************************************************************/
#if !defined(__NEWLIB_NANO)
// The format specifier %hhu is not supported by Newlib-Nano
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "hhu: %hhu\r\n", 0);
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "hhu: %hhu\r\n", 0);
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@ -594,6 +603,7 @@ static control_t test_snprintf_u(const size_t call_count)
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
#if !defined(__NEWLIB_NANO)
// The format specifier %llu is not supported by Newlib-Nano
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "llu: %llu\r\n", 0ULL);
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "llu: %llu\r\n", 0ULL);
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@ -660,6 +670,7 @@ static control_t test_snprintf_x(const size_t call_count)
/*************************************************************************/
/*************************************************************************/
#if !defined(__NEWLIB_NANO)
// The format specifier %hhX is not supported by Newlib-Nano
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "hhX: %hhX\r\n", 0);
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "hhX: %hhX\r\n", 0);
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@ -700,6 +711,7 @@ static control_t test_snprintf_x(const size_t call_count)
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
#if !defined(__NEWLIB_NANO)
// The format specifier %llX is not supported by Newlib-Nano
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "llX: %llX\r\n", 0ULL);
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "llX: %llX\r\n", 0ULL);
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@ -923,6 +935,7 @@ static control_t test_snprintf_buffer_overflow_ld(const size_t call_count)
}
#if !defined(__NEWLIB_NANO)
// The format specifier %lld is not supported by Newlib-Nano
static control_t test_snprintf_buffer_overflow_lld(const size_t call_count)
{
return test_snprintf_buffer_overflow_generic<long long, sizeof("lld: -1099511627776")>("lld: %lld", -1099511627776LL);
@ -940,6 +953,7 @@ static control_t test_snprintf_buffer_overflow_lu(const size_t call_count)
}
#if !defined(__NEWLIB_NANO)
// The format specifier %llu is not supported by Newlib-Nano
static control_t test_snprintf_buffer_overflow_llu(const size_t call_count)
{
return test_snprintf_buffer_overflow_generic<unsigned long long, sizeof("llu: 1099511627776")>("llu: %llu", 1099511627776ULL);
@ -957,6 +971,7 @@ static control_t test_snprintf_buffer_overflow_lx(const size_t call_count)
}
#if !defined(__NEWLIB_NANO)
// The format specifier %llx is not supported by Newlib-Nano
static control_t test_snprintf_buffer_overflow_llx(const size_t call_count)
{
return test_snprintf_buffer_overflow_generic<unsigned long long, sizeof("llx: 0x10000000000")>("llx: 0x%llx", 0x10000000000ULL);
@ -990,6 +1005,7 @@ Case cases[] = {
Case("snprintf buffer overflow %x", test_snprintf_buffer_overflow_x),
Case("snprintf buffer overflow %lx", test_snprintf_buffer_overflow_lx),
#if !defined(__NEWLIB_NANO)
// The format specifiers %lld,%llu,%llx are not supported by Newlib-Nano
Case("snprintf buffer overflow %lld", test_snprintf_buffer_overflow_lld),
Case("snprintf buffer overflow %llu", test_snprintf_buffer_overflow_llu),
Case("snprintf buffer overflow %llx", test_snprintf_buffer_overflow_llx),

View File

@ -2136,12 +2136,7 @@
"init-us-ticker-at-boot": true
},
"OUTPUT_EXT": "hex",
"bootloader_supported": true,
"supported_c_libs": {
"arm": ["std", "small"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
"bootloader_supported": true
},
"LPC55S69_S": {
"inherits": ["SPE_Target", "LPC55S69"],
@ -3569,12 +3564,7 @@
],
"release_versions": ["2", "5"],
"bootloader_supported": true,
"device_name": "STM32L073RZ",
"supported_c_libs": {
"arm": ["std", "small"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
"device_name": "STM32L073RZ"
},
"NUCLEO_L152RE": {
"inherits": ["FAMILY_STM32"],

View File

@ -4,6 +4,11 @@
"extra_labels": [],
"features": [],
"default_lib": "std",
"supported_toolchains": ["GCC_ARM"]
"supported_toolchains": ["GCC_ARM"],
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -3,6 +3,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",

View File

@ -3,6 +3,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",
@ -14,6 +19,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0",
"config": {
"base2_1": "v_base2_1_b2",

View File

@ -4,6 +4,11 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,6 +4,11 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,6 +4,11 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,6 +4,11 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": ["BOOTLOADER"],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,6 +4,11 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,6 +4,11 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -3,6 +3,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0"
},
"b1": {

View File

@ -3,6 +3,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0"
},
"b1": {

View File

@ -3,6 +3,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0",
"config": {
"par1": "v_par1_base",

View File

@ -8,6 +8,11 @@
"par1": "v_par1_base",
"par2": "v_par2_base",
"par3": "v_par3_base"
},
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
},
"b1": {

View File

@ -3,6 +3,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",

View File

@ -3,6 +3,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0"
},
"left_intermediate": {

View File

@ -3,6 +3,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0"
},
"left_intermediate": {

View File

@ -4,6 +4,11 @@
"extra_labels": [],
"features": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"supported_toolchains": ["GCC_ARM"]
}
}

View File

@ -4,6 +4,11 @@
"extra_labels": [],
"features": [],
"default_lib": "std",
"supported_toolchains": ["GCC_ARM"]
"supported_toolchains": ["GCC_ARM"],
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,6 +4,11 @@
"extra_labels": [],
"features": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"supported_toolchains": ["GCC_ARM"]
}
}

View File

@ -4,13 +4,23 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
},
"should_pass": {
"supported_toolchains": ["GCC_ARM"],
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,6 +4,11 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,13 +4,23 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
},
"should_pass": {
"supported_toolchains": ["GCC_ARM"],
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,13 +4,23 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
},
"should_pass": {
"supported_toolchains": ["GCC_ARM"],
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -4,6 +4,11 @@
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
}
}
}

View File

@ -3,6 +3,11 @@
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [],
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",

View File

@ -103,6 +103,11 @@ def test_modify_existing_target():
"detect_code": [],
"public": false,
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"bootloader_supported": false
},
"Test_Target": {
@ -113,7 +118,7 @@ def test_modify_existing_target():
}"""
test_target_json = """
{
{
"Target": {
"core": "Cortex-M0",
"default_toolchain": "GCC_ARM",
@ -126,6 +131,11 @@ def test_modify_existing_target():
"detect_code": [],
"public": false,
"default_lib": "std",
"supported_c_libs": {
"arm": ["std"],
"gcc_arm": ["std", "small"],
"iar": ["std"]
},
"bootloader_supported": true
}
}

View File

@ -20,7 +20,7 @@ sys.path.insert(0, ROOT)
from tools.toolchains.arm import ARM_STD, ARM_MICRO, ARMC6
from tools.toolchains.gcc import GCC_ARM
from tools.toolchains.iar import IAR
from tools.toolchains.mbed_toolchain import UNSUPPORTED_C_LIB_EXECPTION_STRING
from tools.toolchains.mbed_toolchain import UNSUPPORTED_C_LIB_EXCEPTION_STRING
from tools.utils import NotSupportedException
class TestArmToolchain(TestCase):
@ -69,31 +69,31 @@ class TestArmToolchain(TestCase):
self.assertIn("--library_type=microlib", arm_c6_obj.flags["asm"])
def test_arm_default_lib_std_exception(self):
"""Test that exception raised when default_lib is std but supported_c_libs parameter arm is not suppoted std lib."""
"""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.default_lib = "std"
mock_target.supported_c_libs = {"arm": ["small"]}
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXECPTION_STRING.format(mock_target.default_lib)):
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.default_lib)):
ARM_STD(mock_target)
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXECPTION_STRING.format(mock_target.default_lib)):
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.default_lib)):
ARMC6(mock_target)
def test_arm_default_lib_small_exception(self):
"""Test that exception raised when default_lib is small but supported_c_libs parameter arm is not suppoted small lib."""
"""Test that an exception is raised if the small C library is not supported for a target on the ARM toolchain."""
mock_target = mock.MagicMock()
mock_target.core = "Cortex-M4"
mock_target.default_lib = "small"
mock_target.supported_c_libs = {"arm": ["std"]}
mock_target.default_toolchain = "ARM"
mock_target.supported_toolchains = ["ARM", "uARM", "ARMC5"]
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXECPTION_STRING.format(mock_target.default_lib)):
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.default_lib)):
ARM_STD(mock_target)
mock_target.default_toolchain = "ARMC6"
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXECPTION_STRING.format(mock_target.default_lib)):
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.default_lib)):
ARMC6(mock_target)
class TestGccToolchain(TestCase):
@ -141,24 +141,24 @@ class TestGccToolchain(TestCase):
self.assertIn("--specs=nano.specs", gcc_arm_obj.flags["ld"])
def test_gcc_arm_default_lib_std_exception(self):
"""Test that exception raised when default_lib is std but supported_c_libs parameter arm is not suppoted std lib."""
"""Test that an exception is raised if the std C library is not supported for a target on the GCC_ARM toolchain."""
mock_target = mock.MagicMock()
mock_target.core = "Cortex-M4"
mock_target.default_toolchain = "ARM"
mock_target.default_lib = "std"
mock_target.supported_c_libs = {"arm": ["small"]}
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXECPTION_STRING.format(mock_target.default_lib)):
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.default_lib)):
GCC_ARM(mock_target)
def test_gcc_arm_default_lib_small_exception(self):
"""Test that exception raised when default_lib is small but supported_c_libs parameter arm is not suppoted small lib."""
"""Test that an exception is raised if the small C library is not supported for a target on the GCC_ARM toolchain."""
mock_target = mock.MagicMock()
mock_target.core = "Cortex-M4"
mock_target.default_lib = "small"
mock_target.supported_c_libs = {"arm": ["std"]}
mock_target.default_toolchain = "ARM"
mock_target.supported_toolchains = ["ARM", "uARM", "ARMC5"]
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXECPTION_STRING.format(mock_target.default_lib)):
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.default_lib)):
GCC_ARM(mock_target)
class TestIarToolchain(TestCase):
@ -179,7 +179,7 @@ class TestIarToolchain(TestCase):
self.assertIn("-DMBED_MINIMAL_PRINTF", iar_obj.flags["common"])
def test_iar_default_lib(self):
"""Test that linker flags are correctly added to an instance of IAR."""
"""Test that no exception is raised when a supported c library is specified."""
mock_target = mock.MagicMock()
mock_target.core = "Cortex-M4"
mock_target.supported_c_libs = {"iar": ["std"]}
@ -189,26 +189,26 @@ class TestIarToolchain(TestCase):
try:
IAR(mock_target)
except NotSupportedException:
self.fail(UNSUPPORTED_C_LIB_EXECPTION_STRING.format(mock_target.default_lib))
self.fail(UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.default_lib))
def test_iar_default_lib_std_exception(self):
"""Test that exception raised when default_lib is small but supported_c_libs parameter iar is not supported small lib."""
"""Test that an exception is raised if the std C library is not supported for a target on the IAR toolchain."""
mock_target = mock.MagicMock()
mock_target.core = "Cortex-M4"
mock_target.microlib_supported = False
mock_target.default_lib = "std"
mock_target.supported_c_libs = {"iar": ["small"]}
mock_target.supported_toolchains = ["IAR"]
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXECPTION_STRING.format(mock_target.default_lib)):
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.default_lib)):
IAR(mock_target)
def test_iar_default_lib_small_exception(self):
"""Test that exception raised when default_lib is small but supported_c_libs parameter iar is not supported small lib."""
"""Test that an exception is raised if the small C library is not supported for a target on the IAR toolchain."""
mock_target = mock.MagicMock()
mock_target.core = "Cortex-M4"
mock_target.microlib_supported = False
mock_target.default_lib = "small"
mock_target.supported_c_libs = {"iar": ["std"]}
mock_target.supported_toolchains = ["IAR"]
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXECPTION_STRING.format(mock_target.default_lib)):
with self.assertRaisesRegexp(NotSupportedException, UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(mock_target.default_lib)):
IAR(mock_target)

View File

@ -39,7 +39,7 @@ ARMC5_MIGRATION_WARNING = (
UARM_TOOLCHAIN_WARNING = (
"Warning: We noticed that you are using uARM Toolchain. "
"We are deprecating the uARM Toolchain. "
"We are deprecating the use of uARM Toolchain. "
"For more information on how to use the ARM toolchain with small C libraries, "
"please visit https://os.mbed.com/docs/mbed-os/latest/reference/using-small-c-libraries.html"
)
@ -79,7 +79,10 @@ class ARM(mbedToolchain):
self.check_c_lib_supported(target, "arm")
if getattr(target, "default_toolchain", "ARM") == "uARM" or getattr(target, "default_lib", "std") == "small":
if (
getattr(target, "default_toolchain", "ARM") == "uARM"
or getattr(target, "default_lib", "std") == "small"
):
if "-DMBED_RTOS_SINGLE_THREAD" not in self.flags['common']:
self.flags['common'].append("-DMBED_RTOS_SINGLE_THREAD")
if "-D__MICROLIB" not in self.flags['common']:
@ -566,7 +569,10 @@ class ARMC6(ARM_STD):
self.check_c_lib_supported(target, "arm")
if getattr(target, "default_toolchain", "ARMC6") == "uARM" or getattr(target, "default_lib", "std") == "small":
if (
getattr(target, "default_toolchain", "ARMC6") == "uARM"
or getattr(target, "default_lib", "std") == "small"
):
if "-DMBED_RTOS_SINGLE_THREAD" not in self.flags['common']:
self.flags['common'].append("-DMBED_RTOS_SINGLE_THREAD")
if "-D__MICROLIB" not in self.flags['common']:

View File

@ -48,7 +48,7 @@ class GCC(mbedToolchain):
tool_path = TOOLCHAIN_PATHS['GCC_ARM']
# Add flags for current size setting
default_lib = ""
default_lib = "std"
if hasattr(target, "default_lib"):
self.check_c_lib_supported(target, "gcc_arm")
default_lib = target.default_lib

View File

@ -109,7 +109,7 @@ CORTEX_SYMBOLS = {
"__MBED_CMSIS_RTOS_CM", "__DSP_PRESENT=1U"],
}
UNSUPPORTED_C_LIB_EXECPTION_STRING = "{} C library option not supported for this target."
UNSUPPORTED_C_LIB_EXCEPTION_STRING = "{} C library option not supported for this target."
class mbedToolchain(with_metaclass(ABCMeta, object)):
OFFICIALLY_SUPPORTED = False
@ -1104,7 +1104,7 @@ class mbedToolchain(with_metaclass(ABCMeta, object)):
Check and raise an exception if the requested C library is not supported,
target.default_lib is modified to have the lowercased string of its original string.
This is done to be case insensitvie when validating.
This is done to be case insensitive when validating.
"""
if hasattr(target, "default_lib"):
target.default_lib = target.default_lib.lower()
@ -1114,7 +1114,7 @@ class mbedToolchain(with_metaclass(ABCMeta, object)):
or target.default_lib not in target.supported_c_libs[toolchain]
):
raise NotSupportedException(
UNSUPPORTED_C_LIB_EXECPTION_STRING.format(target.default_lib)
UNSUPPORTED_C_LIB_EXCEPTION_STRING.format(target.default_lib)
)
@staticmethod