Skip to content

Commit

Permalink
Print the command when a greentea test is being run. Also fix mbedhtr…
Browse files Browse the repository at this point in the history
…un not being on PATH causing all tests to pass! (ARMmbed#51)

* Print the command when a greentea test is being run.  Also fix mbedhtrun not being on PATH causing all tests to pass!

* Also remove useless -f argument to mbedhtrun (not used with --skip-flashing)
  • Loading branch information
multiplemonomials authored Sep 20, 2022
1 parent 7e5066d commit f317dbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
11 changes: 10 additions & 1 deletion tools/cmake/mbed-run-greentea-test.in.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# This file is configured by CMake to create the script used to execute each Greentea test.

# First flash the target using its configured Mbed OS upload method
# -----------------------------------------------------------------------
execute_process(
# Note: we don't use cmake --build because that performs a reconfigure of the build system each time
COMMAND @CMAKE_MAKE_PROGRAM@ flash-@MBED_GREENTEA_TEST_NAME@
WORKING_DIRECTORY @CMAKE_BINARY_DIR@
COMMAND_ERROR_IS_FATAL ANY)

# Then run and communicate with the test
# -----------------------------------------------------------------------
set(MBEDHTRUN_ARGS --skip-flashing @MBED_HTRUN_ARGUMENTS@) # filled in by configure script

# Print out command
string(REPLACE ";" " " MBEDHTRUN_ARGS_FOR_DISPLAY "${MBEDHTRUN_ARGS}")
message("Executing: mbedhtrun ${MBEDHTRUN_ARGS_FOR_DISPLAY}")

# Note: For this command, we need to survive mbedhtrun not being on the PATH, so we import the package and call the main function using "python -c"
execute_process(
COMMAND mbedhtrun --skip-flashing -f @MBED_GREENTEA_TEST_IMAGE_NAME@ @MBED_HTRUN_ARGUMENTS@
COMMAND @Python3_EXECUTABLE@ -c "import mbed_host_tests.mbedhtrun; mbed_host_tests.mbedhtrun.main()" ${MBEDHTRUN_ARGS}
WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@"
COMMAND_ERROR_IS_FATAL ANY)
13 changes: 0 additions & 13 deletions tools/cmake/mbed_greentea.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ function(mbed_greentea_add_test)

mbed_set_post_build(${MBED_GREENTEA_TEST_NAME})

if(NOT ${MBED_OUTPUT_EXT} STREQUAL "")
set(MBED_GREENTEA_TEST_IMAGE_NAME "${MBED_GREENTEA_TEST_NAME}.${MBED_OUTPUT_EXT}")
else()
set(MBED_GREENTEA_TEST_IMAGE_NAME "${MBED_GREENTEA_TEST_NAME}.bin")
endif()

# User can set this cache variable to supply extra arguments to greentea.
# such as: -d to set the drive path
list(APPEND MBED_HTRUN_ARGUMENTS -p ${MBED_GREENTEA_SERIAL_PORT})
Expand Down Expand Up @@ -139,13 +133,6 @@ function(mbed_greentea_add_test)
endif()


list(APPEND CONFIG_DEFS_COPY ${MBED_CONFIG_DEFINITIONS})
list(FILTER CONFIG_DEFS_COPY INCLUDE REGEX "MBED_CONF_PLATFORM_STDIO_BAUD_RATE")
if(NOT ${CONFIG_DEFS_COPY} STREQUAL "")
string(REGEX MATCH "[0-9]*$" BAUD_RATE ${CONFIG_DEFS_COPY})
list(APPEND MBED_HTRUN_ARGUMENTS "--baud-rate=${BAUD_RATE}")
endif()

# Configure the CMake script which runs the test.
# We have to use a helper script in order to run both the flashing and htrun in one test
configure_file(
Expand Down

0 comments on commit f317dbc

Please sign in to comment.