Skip to content

Commit cb9b6d5

Browse files
committed
Incorporated review comments
1 parent d461197 commit cb9b6d5

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

TESTS/mbed_drivers/c_strings/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ Case cases[] = {
116116
Case("C strings: %u %d integer formatting", test_case_c_string_u_d, greentea_failure_handler),
117117
Case("C strings: %x %E integer formatting", test_case_c_string_x_X, greentea_failure_handler),
118118
#if !defined(__NEWLIB_NANO)
119+
//In build tools, GCC with Newlib-nano linker option "-u _printf_float" is not configured
120+
//to enable printf floating format. So disabling floating format test case.
119121
Case("C strings: %f %f float formatting", test_case_c_string_f_f, greentea_failure_handler),
120122
#ifndef MBED_MINIMAL_PRINTF
121123
Case("C strings: %e %E float formatting", test_case_c_string_e_E, greentea_failure_handler),

TESTS/mbed_platform/minimal-printf/compliance/main.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static control_t test_printf_d(const size_t call_count)
5252
/*************************************************************************/
5353
/*************************************************************************/
5454
#if !defined(__NEWLIB_NANO)
55+
//Printf with %hhd is not supported by Newlib-Nano
5556
result_minimal = mbed_printf("hhd: %hhd\r\n", SCHAR_MIN);
5657
result_file = mbed_fprintf(stderr, "hhd: %hhd\r\n", SCHAR_MIN);
5758
result_baseline = printf("hhd: %hhd\r\n", SCHAR_MIN);
@@ -102,6 +103,7 @@ static control_t test_printf_d(const size_t call_count)
102103
TEST_ASSERT_EQUAL_INT(result_baseline, result_file);
103104

104105
#if !defined(__NEWLIB_NANO)
106+
//Printf with %lld is not supported by Newlib-Nano
105107
result_minimal = mbed_printf("lld: %lld\r\n", LLONG_MIN);
106108
result_file = mbed_fprintf(stderr, "lld: %lld\r\n", LLONG_MIN);
107109
result_baseline = printf("lld: %lld\r\n", LLONG_MIN);
@@ -175,6 +177,7 @@ static control_t test_printf_u(const size_t call_count)
175177
/*************************************************************************/
176178
/*************************************************************************/
177179
#if !defined(__NEWLIB_NANO)
180+
//Printf with %hhu is not supported by Newlib-Nano
178181
result_minimal = mbed_printf("hhu: %hhu\r\n", 0);
179182
result_file = mbed_fprintf(stderr, "hhu: %hhu\r\n", 0);
180183
result_baseline = printf("hhu: %hhu\r\n", 0);
@@ -224,6 +227,7 @@ static control_t test_printf_u(const size_t call_count)
224227
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
225228
TEST_ASSERT_EQUAL_INT(result_baseline, result_file);
226229
#if !defined(__NEWLIB_NANO)
230+
//Printf with %llu is not supported by Newlib-Nano
227231
result_minimal = mbed_printf("llu: %llu\r\n", 0ULL);
228232
result_file = mbed_fprintf(stderr, "llu: %llu\r\n", 0ULL);
229233
result_baseline = printf("llu: %llu\r\n", 0ULL);
@@ -297,6 +301,7 @@ static control_t test_printf_x(const size_t call_count)
297301
/*************************************************************************/
298302
/*************************************************************************/
299303
#if !defined(__NEWLIB_NANO)
304+
//Printf with %hhX is not supported by Newlib-Nano
300305
result_minimal = mbed_printf("hhX: %hhX\r\n", 0);
301306
result_file = mbed_fprintf(stderr, "hhX: %hhX\r\n", 0);
302307
result_baseline = printf("hhX: %hhX\r\n", 0);
@@ -346,6 +351,7 @@ static control_t test_printf_x(const size_t call_count)
346351
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
347352
TEST_ASSERT_EQUAL_INT(result_baseline, result_file);
348353
#if !defined(__NEWLIB_NANO)
354+
//Printf with %llX is not supported by Newlib-Nano
349355
result_minimal = mbed_printf("llX: %llX\r\n", 0ULL);
350356
result_file = mbed_fprintf(stderr, "llX: %llX\r\n", 0ULL);
351357
result_baseline = printf("llX: %llX\r\n", 0ULL);
@@ -445,6 +451,7 @@ static control_t test_snprintf_d(const size_t call_count)
445451
/*************************************************************************/
446452
/*************************************************************************/
447453
#if !defined(__NEWLIB_NANO)
454+
//Printf with %hhd is not supported by Newlib-Nano
448455
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "hhd: %hhd\r\n", SCHAR_MIN);
449456
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "hhd: %hhd\r\n", SCHAR_MIN);
450457
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@@ -487,6 +494,7 @@ static control_t test_snprintf_d(const size_t call_count)
487494
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
488495

489496
#if !defined(__NEWLIB_NANO)
497+
//Printf with %lld is not supported by Newlib-Nano
490498
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "lld: %lld\r\n", LLONG_MIN);
491499
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "lld: %lld\r\n", LLONG_MIN);
492500
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@@ -553,6 +561,7 @@ static control_t test_snprintf_u(const size_t call_count)
553561
/*************************************************************************/
554562
/*************************************************************************/
555563
#if !defined(__NEWLIB_NANO)
564+
//Printf with %hhu is not supported by Newlib-Nano
556565
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "hhu: %hhu\r\n", 0);
557566
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "hhu: %hhu\r\n", 0);
558567
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@@ -594,6 +603,7 @@ static control_t test_snprintf_u(const size_t call_count)
594603
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
595604
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
596605
#if !defined(__NEWLIB_NANO)
606+
//Printf with %llu is not supported by Newlib-Nano
597607
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "llu: %llu\r\n", 0ULL);
598608
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "llu: %llu\r\n", 0ULL);
599609
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@@ -660,6 +670,7 @@ static control_t test_snprintf_x(const size_t call_count)
660670
/*************************************************************************/
661671
/*************************************************************************/
662672
#if !defined(__NEWLIB_NANO)
673+
//Printf with %hhX is not supported by Newlib-Nano
663674
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "hhX: %hhX\r\n", 0);
664675
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "hhX: %hhX\r\n", 0);
665676
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
@@ -700,6 +711,7 @@ static control_t test_snprintf_x(const size_t call_count)
700711
TEST_ASSERT_EQUAL_STRING(buffer_baseline, buffer_minimal);
701712
TEST_ASSERT_EQUAL_INT(result_baseline, result_minimal);
702713
#if !defined(__NEWLIB_NANO)
714+
//Printf with %llX is not supported by Newlib-Nano
703715
result_minimal = mbed_snprintf(buffer_minimal, sizeof(buffer_minimal), "llX: %llX\r\n", 0ULL);
704716
result_baseline = snprintf(buffer_baseline, sizeof(buffer_baseline), "llX: %llX\r\n", 0ULL);
705717
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)
923935
}
924936

925937
#if !defined(__NEWLIB_NANO)
938+
//Printf with %lld is not supported by Newlib-Nano
926939
static control_t test_snprintf_buffer_overflow_lld(const size_t call_count)
927940
{
928941
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)
940953
}
941954

942955
#if !defined(__NEWLIB_NANO)
956+
//Printf with %llu is not supported by Newlib-Nano
943957
static control_t test_snprintf_buffer_overflow_llu(const size_t call_count)
944958
{
945959
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)
957971
}
958972

959973
#if !defined(__NEWLIB_NANO)
974+
//Printf with %llx is not supported by Newlib-Nano
960975
static control_t test_snprintf_buffer_overflow_llx(const size_t call_count)
961976
{
962977
return test_snprintf_buffer_overflow_generic<unsigned long long, sizeof("llx: 0x10000000000")>("llx: 0x%llx", 0x10000000000ULL);
@@ -990,6 +1005,7 @@ Case cases[] = {
9901005
Case("snprintf buffer overflow %x", test_snprintf_buffer_overflow_x),
9911006
Case("snprintf buffer overflow %lx", test_snprintf_buffer_overflow_lx),
9921007
#if !defined(__NEWLIB_NANO)
1008+
//Printf with %lld,%llu,%llx is not supported by Newlib-Nano
9931009
Case("snprintf buffer overflow %lld", test_snprintf_buffer_overflow_lld),
9941010
Case("snprintf buffer overflow %llu", test_snprintf_buffer_overflow_llu),
9951011
Case("snprintf buffer overflow %llx", test_snprintf_buffer_overflow_llx),

tools/test/toolchains/test_toolchains.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def test_iar_minimal_printf(self):
179179
self.assertIn("-DMBED_MINIMAL_PRINTF", iar_obj.flags["common"])
180180

181181
def test_iar_default_lib(self):
182-
"""Test that linker flags are correctly added to an instance of IAR."""
182+
"""Test that no exception raised when a valid c library is specified."""
183183
mock_target = mock.MagicMock()
184184
mock_target.core = "Cortex-M4"
185185
mock_target.supported_c_libs = {"iar": ["std"]}

tools/toolchains/arm.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
UARM_TOOLCHAIN_WARNING = (
4141
"Warning: We noticed that you are using uARM Toolchain. "
42-
"We are deprecating the uARM Toolchain. "
42+
"We are deprecating the use of uARM Toolchain. "
4343
"For more information on how to use the ARM toolchain with small C libraries, "
4444
"please visit https://os.mbed.com/docs/mbed-os/latest/reference/using-small-c-libraries.html"
4545
)
@@ -79,7 +79,10 @@ def __init__(self, target, notify=None, macros=None,
7979

8080
self.check_c_lib_supported(target, "arm")
8181

82-
if getattr(target, "default_toolchain", "ARM") == "uARM" or getattr(target, "default_lib", "std") == "small":
82+
if (
83+
getattr(target, "default_toolchain", "ARM") == "uARM"
84+
or getattr(target, "default_lib", "std") == "small"
85+
):
8386
if "-DMBED_RTOS_SINGLE_THREAD" not in self.flags['common']:
8487
self.flags['common'].append("-DMBED_RTOS_SINGLE_THREAD")
8588
if "-D__MICROLIB" not in self.flags['common']:
@@ -566,7 +569,10 @@ def __init__(self, target, *args, **kwargs):
566569

567570
self.check_c_lib_supported(target, "arm")
568571

569-
if getattr(target, "default_toolchain", "ARMC6") == "uARM" or getattr(target, "default_lib", "std") == "small":
572+
if (
573+
getattr(target, "default_toolchain", "ARMC6") == "uARM"
574+
or getattr(target, "default_lib", "std") == "small"
575+
):
570576
if "-DMBED_RTOS_SINGLE_THREAD" not in self.flags['common']:
571577
self.flags['common'].append("-DMBED_RTOS_SINGLE_THREAD")
572578
if "-D__MICROLIB" not in self.flags['common']:

tools/toolchains/gcc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
5454
default_lib = target.default_lib
5555
elif hasattr(target, "default_build"):
5656
default_lib = target.default_build
57-
else:
58-
raise NotSupportedException("default_lib is an empty")
57+
58+
if not default_lib:
59+
raise NotSupportedException("default_lib is not set")
5960

6061
if default_lib == "small":
6162
common_flags = ["-DMBED_RTOS_SINGLE_THREAD", "-D__NEWLIB_NANO"]

0 commit comments

Comments
 (0)