Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/drivers/at_unit: fix unit tests on native #20551

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ rcv_eol_2=""
send_eol=""

run_test() {
echo "================================="
echo "Running test with:"
echo " URC handling = $handle_urc"
echo " echo = $echo"
echo " send EOL = $send_eol"
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..."
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion tests/drivers/at_unit/tests-at.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 */
Expand Down
Loading