From 627926869fef97b47070dcd3b339abfb1be0d152 Mon Sep 17 00:00:00 2001 From: Mihai Renea Date: Mon, 8 Apr 2024 09:40:52 +0200 Subject: [PATCH] tests/drivers/at_unit: fix unit tests on native --- .../tests-with-config => at_unit}/test_all_configs.sh | 10 +++------- tests/drivers/at_unit/tests-at.c | 9 ++++++++- 2 files changed, 11 insertions(+), 8 deletions(-) rename tests/drivers/{at/tests-with-config => at_unit}/test_all_configs.sh (90%) diff --git a/tests/drivers/at/tests-with-config/test_all_configs.sh b/tests/drivers/at_unit/test_all_configs.sh similarity index 90% rename from tests/drivers/at/tests-with-config/test_all_configs.sh rename to tests/drivers/at_unit/test_all_configs.sh index d0dc78621fa8..2bd85e019dbd 100755 --- a/tests/drivers/at/tests-with-config/test_all_configs.sh +++ b/tests/drivers/at_unit/test_all_configs.sh @@ -7,6 +7,7 @@ rcv_eol_2="" send_eol="" run_test() { + echo "=================================" echo "Running test with:" echo " URC handling = $handle_urc" echo " echo = $echo" @@ -14,12 +15,12 @@ run_test() { echo " rcv EOL 1 = $rcv_eol_1" echo " rcv EOL 2 = $rcv_eol_2" - make -j --silent BOARD=native "HANDLE_URC=$handle_urc" "ECHO_ON=$echo" "SEND_EOL=\"$send_eol\"" "RECV_EOL_1=\"$rcv_eol_1\"" "RECV_EOL_2=\"$rcv_eol_2\"" tests-at + make -j --silent BOARD=native "HANDLE_URC=$handle_urc" "ECHO_ON=$echo" "SEND_EOL=\"$send_eol\"" "RECV_EOL_1=\"$rcv_eol_1\"" "RECV_EOL_2=\"$rcv_eol_2\"" # take /dev/ttyS0 as serial interface. It is only required s.t. UART # initialization succeeds and it gets turned off right away. set +e - if ! ./bin/native/tests_unittests.elf -c /dev/ttyS0 <<< "s\n"; + if ! ./bin/native/tests_at_unit.elf -c /dev/ttyS0 <<< "s\n"; then echo "================================================================================" echo "Test failed! Generating compile-commands.json of the last build configuration..." @@ -33,11 +34,6 @@ run_test() { # set -x set -e -SCRIPT=$(readlink -f "$0") -BASEDIR=$(dirname "$SCRIPT")/../../../unittests - -cd "$BASEDIR" - for urc_i in 0 1; do handle_urc=$urc_i for echo_i in 0 1; do diff --git a/tests/drivers/at_unit/tests-at.c b/tests/drivers/at_unit/tests-at.c index 4a708650ef2b..4ff32ed72a8e 100644 --- a/tests/drivers/at_unit/tests-at.c +++ b/tests/drivers/at_unit/tests-at.c @@ -50,6 +50,13 @@ at_urc_t urc_short = { }; #endif +#ifdef BOARD_NATIVE +#define AT_UNIT_UART_DEV 0 +#else +/* Most non-native boards have stdout mapped to device 0 */ +#define AT_UNIT_UART_DEV 1 +#endif + static void set_up(void) { at_dev_init_t at_init_params = { @@ -58,7 +65,7 @@ static void set_up(void) .rp_buf_size = sizeof(rp_buf), .rx_buf = buf, .rx_buf_size = sizeof(buf), - .uart = UART_DEV(1), + .uart = UART_DEV(AT_UNIT_UART_DEV), }; int res = at_dev_init(&at_dev, &at_init_params); /* check the UART initialization return value and respond as needed */