Skip to content

Commit e70d8c6

Browse files
authored
Merge pull request #14904 from rwalton-arm/greentea_client_io
CMake: greentea: Fix io issue with greentea-client
2 parents 0726db0 + e9747d7 commit e70d8c6

File tree

5 files changed

+45
-51
lines changed

5 files changed

+45
-51
lines changed

features/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ add_subdirectory(frameworks/COMPONENT_FPGA_CI_TEST_SHIELD)
1111
add_subdirectory(frameworks/mbed-client-cli)
1212
add_subdirectory(frameworks/unity)
1313
add_subdirectory(frameworks/utest)
14+
add_subdirectory(frameworks/mbed-greentea-io)

features/frameworks/greentea-client/source/greentea_test_env.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -239,22 +239,6 @@ static void greentea_write_postamble()
239239
greentea_putc('\n');
240240
}
241241

242-
/**
243-
* \brief Write a string to the serial port
244-
*
245-
* This function writes a '\0' terminated string from the target
246-
* to the host. It writes directly to the serial port using the
247-
* the write() method.
248-
*
249-
* \param str - string value
250-
*
251-
*/
252-
void greentea_write_string(const char *str)
253-
{
254-
write(STDOUT_FILENO, str, strlen(str));
255-
}
256-
257-
258242
/**
259243
* \brief Write an int to the serial port
260244
*
@@ -536,40 +520,6 @@ enum Token {
536520
tok_string = -5
537521
};
538522

539-
/**
540-
* \brief Read character from stream of data
541-
*
542-
* Closure for default "get character" function.
543-
* This function is used to read characters from the stream
544-
* (default is serial port RX). Key-value protocol tokenizer
545-
* will build stream of tokes used by key-value protocol to
546-
* detect valid messages.
547-
*
548-
* If EOF is received parser finishes parsing and stops. In
549-
* situation where we have serial port stream of data parsing
550-
* goes forever.
551-
*
552-
* \return Next character from the stream or EOF if stream has ended.
553-
*
554-
*/
555-
extern "C" int greentea_getc() {
556-
uint8_t c;
557-
read(STDOUT_FILENO, &c, 1);
558-
return c;
559-
}
560-
561-
562-
/**
563-
* \brief Write character from stream of data
564-
*
565-
* \return The number of bytes written
566-
*
567-
*/
568-
extern "C" void greentea_putc(int c) {
569-
uint8_t _c = c;
570-
write(STDOUT_FILENO, &_c, 1);
571-
}
572-
573523
/**
574524
* \brief parse input string for key-value pairs: {{key;value}}
575525
* This function should replace scanf() used to
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2021 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(mbed-greentea-io INTERFACE)
5+
target_sources(mbed-greentea-io INTERFACE mbed_io.cpp)
6+
target_link_libraries(mbed-greentea-io INTERFACE mbed-core)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2021, 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+
#include <cstdint>
18+
#include <cstring>
19+
#include "platform/mbed_retarget.h"
20+
21+
extern "C" void greentea_write_string(const char *str)
22+
{
23+
write(STDOUT_FILENO, str, strlen(str));
24+
}
25+
26+
extern "C" int greentea_getc()
27+
{
28+
uint8_t c;
29+
read(STDOUT_FILENO, &c, 1);
30+
return c;
31+
}
32+
33+
extern "C" void greentea_putc(int c)
34+
{
35+
uint8_t _c = c;
36+
write(STDOUT_FILENO, &_c, 1);
37+
}

tools/cmake/mbed_greentea.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ macro(mbed_greentea_add_test)
6161
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-os)
6262
endif()
6363

64-
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS greentea::client mbed-unity mbed-utest)
64+
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS greentea::client_userio mbed-greentea-io mbed-unity mbed-utest)
6565

6666
target_link_libraries(${MBED_GREENTEA_TEST_NAME}
6767
PRIVATE

0 commit comments

Comments
 (0)