Skip to content

Commit 50f1c17

Browse files
committed
Review comments: Re-implemented utest_printf to use RawSerial.
Re-implemented utest_safe_putc() to use Rawserial. Minor cosmetic changes.
1 parent 0ccdfe3 commit 50f1c17

File tree

12 files changed

+68
-31
lines changed

12 files changed

+68
-31
lines changed

frameworks/utest/source/case.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "utest/case.h"
20+
#include "utest/utest_serial.h"
2021

2122
using namespace utest::v1;
2223

frameworks/utest/source/default_handlers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "utest/default_handlers.h"
2020
#include "utest/case.h"
2121
#include "utest/stack_trace.h"
22-
22+
#include "utest/utest_serial.h"
2323

2424
using namespace utest::v1;
2525

frameworks/utest/source/greentea_handlers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "utest/case.h"
2121
#include "greentea-client/test_env.h"
2222
#include "utest/stack_trace.h"
23+
#include "utest/utest_serial.h"
2324

2425
using namespace utest::v1;
2526

@@ -56,7 +57,7 @@ const handlers_t utest::v1::selftest_handlers = {
5657
};
5758

5859

59-
// --- SPECIAL HANDLERS ---
60+
// --- SPECIAL HANDLERS ---
6061
static utest::v1::status_t unknown_test_setup_handler(const size_t) {
6162
UTEST_LOG_FUNCTION();
6263
utest_printf(">>> I do not know how to tell greentea that the test started, since\n");

frameworks/utest/source/harness.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "utest/harness.h"
2020
#include "utest/stack_trace.h"
21+
#include "utest/utest_serial.h"
2122

2223
#include <stdlib.h>
2324

frameworks/utest/source/shim.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,6 @@ static int32_t utest_us_ticker_run()
124124
return 0;
125125
}
126126

127-
int utest_printf(char *str, ...)
128-
{
129-
volatile uint32_t primask = __get_PRIMASK();\
130-
if ( (primask & 0x1) == 0){ \
131-
va_list vargs;
132-
133-
va_start(vargs, str);
134-
vprintf(str, vargs);
135-
va_end(vargs);
136-
}
137-
138-
return 0;
139-
}
140-
141127

142128
extern "C" {
143129
static const utest_v1_scheduler_t utest_v1_scheduler =

frameworks/utest/source/stack_trace.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
#include "utest.h"
2222
#include "unity.h"
2323
#include "utest/stack_trace.h"
24-
25-
#include <stdio.h>
24+
#include "utest/utest_serial.h"
2625

2726
using namespace utest::v1;
2827

frameworks/utest/source/unity_handler.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
****************************************************************************
1717
*/
1818

19-
#include "utest/harness.h"
20-
#include "utest/stack_trace.h"
21-
#include "utest/unity_handler.h"
22-
19+
#include "utest/harness.h"
20+
#include "utest/stack_trace.h"
21+
#include "utest/unity_handler.h"
22+
#include "utest/utest_serial.h"
2323

2424
void utest_unity_assert_failure(void)
2525
{
@@ -35,11 +35,7 @@ void utest_unity_ignore_failure(void)
3535

3636
void utest_safe_putc(int chr)
3737
{
38-
volatile uint32_t primask = __get_PRIMASK();
39-
if ( (primask & 0x1) == 0){
40-
(void)putchar(chr);
41-
}
42-
38+
utest_serial.putc(chr);
4339
}
4440

4541

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/****************************************************************************
2+
* Copyright (c) 2015, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
****************************************************************************
17+
*/
18+
19+
#include "utest/utest_serial.h"
20+
21+
RawSerial utest_serial(USBTX, USBRX);
22+
23+
void utest_safe_putc(int chr)
24+
{
25+
utest_serial.putc(chr);
26+
}
27+
28+

frameworks/utest/utest/shim.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ extern "C" {
7676
/// must be implemented by the port
7777
void utest_v1_enter_critical_section(void);
7878
void utest_v1_leave_critical_section(void);
79-
int utest_printf(char *str, ...);
8079

8180
/// This is the default scheduler implementation used by the harness.
8281
utest_v1_scheduler_t utest_v1_get_scheduler(void);

frameworks/utest/utest/unity_handler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#define UTEST_UNITY_ASSERT_FAILURE_H
2121

2222
#include <stdint.h>
23-
#include <stdio.h>
24-
#include "cmsis.h"
2523

2624
#ifdef __cplusplus
2725
extern "C" {

frameworks/utest/utest/utest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
#include "case.h"
2424
#include "default_handlers.h"
2525
#include "harness.h"
26-
26+
#include "utest/utest_serial.h"
2727

2828
#endif // UTEST_H

frameworks/utest/utest/utest_serial.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/****************************************************************************
2+
* Copyright (c) 2016, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
****************************************************************************
17+
*/
18+
19+
#ifndef UTEST_SERIAL_H
20+
#define UTEST_SERIAL_H
21+
22+
#include "mbed.h"
23+
24+
extern RawSerial utest_serial;
25+
26+
#define utest_printf(...) utest_serial.printf(__VA_ARGS__)
27+
28+
#endif // UTEST_SERIAL_H

0 commit comments

Comments
 (0)