Skip to content

Commit

Permalink
tests: bsim: bluetooth: host: use twister to compile tests
Browse files Browse the repository at this point in the history
Bluetooth host bsim tests are compiled with shell scripts, but it is
possible to use twister, which supports compilation (but not running
at the moment). Copiling with twister provides cleaner interface and
more flexible configuration.

Signed-off-by: Artur Dobrynin <[email protected]>
  • Loading branch information
ardo-nordic committed Nov 29, 2024
1 parent 065bd32 commit 08b5104
Show file tree
Hide file tree
Showing 239 changed files with 1,298 additions and 944 deletions.
1 change: 1 addition & 0 deletions tests/bsim/bluetooth/compile.nrf5340bsim_nrf5340_cpunet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export BOARD="${BOARD:-nrf5340bsim/nrf5340/cpunet}"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source

${ZEPHYR_BASE}/tests/bsim/bluetooth/ll/compile.sh
${ZEPHYR_BASE}/tests/bsim/bluetooth/host/compile.sh

wait_for_background_jobs
24 changes: 24 additions & 0 deletions tests/bsim/bluetooth/host/_tests.nrf5340bsim_nrf5340_cpunet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Copyright 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

# Run bluetooth/host tests that support nrf5340bsim/nrf5340/cpunet platform

set -ue

: "${ZEPHYR_BASE:?ZEPHYR_BASE must be set to point to the zephyr root directory}"

board=nrf5340bsim/nrf5340/cpunet
test_spec=testlist.json

west twister -T ${ZEPHYR_BASE}/tests/bsim/bluetooth/host/ -p ${board} -E ${test_spec}

parse_cmd="['${ZEPHYR_BASE}/' + it['path'] for it in json.load(open('${test_spec}'))['testsuites']]"
search_path=`python3 -c "import sys, json; print(' '.join(set(${parse_cmd})))"`

rm -f ${test_spec}

BOARD=${board} \
RESULTS_FILE=${ZEPHYR_BASE}/bsim_out/bsim_results.bt.host.53_cpunet.xml \
SEARCH_PATH=${search_path} \
${ZEPHYR_BASE}/tests/bsim/run_parallel.sh
11 changes: 11 additions & 0 deletions tests/bsim/bluetooth/host/adv/chain/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests:
bluetooth.host.adv.chain:
build_only: true
tags:
- bluetooth
platform_allow:
- nrf52_bsim
- nrf5340bsim/nrf5340/cpunet
harness: bsim
harness_config:
bsim_exe_name: tests_bsim_bluetooth_host_adv_chain_prj_conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ verbosity_level=2

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_chain_prj_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=adv

Expand Down
23 changes: 0 additions & 23 deletions tests/bsim/bluetooth/host/adv/compile.sh

This file was deleted.

15 changes: 0 additions & 15 deletions tests/bsim/bluetooth/host/adv/encrypted/css_sample_data/compile.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source

simulation_id="$(guess_test_long_name)"
verbosity_level=2
if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

test_exe="bs_${BOARD_TS}_$(guess_test_long_name)_prj_conf"

cd ${BSIM_OUT_PATH}/bin
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tests:
bluetooth.host.adv.encrypted.css_sample_data:
build_only: true
tags:
- bluetooth
platform_allow:
- nrf52_bsim
harness: bsim
harness_config:
bsim_exe_name: tests_bsim_bluetooth_host_adv_encrypted_css_sample_data_prj_conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ verbosity_level=2

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_encrypted_ead_sample_prj_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central -RealEncryption=1

Expand Down
10 changes: 10 additions & 0 deletions tests/bsim/bluetooth/host/adv/encrypted/ead_sample/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tests:
bluetooth.host.adv.encrypted.ead_sample:
build_only: true
tags:
- bluetooth
platform_allow:
- nrf52_bsim
harness: bsim
harness_config:
bsim_exe_name: tests_bsim_bluetooth_host_adv_encrypted_ead_sample_prj_conf
20 changes: 20 additions & 0 deletions tests/bsim/bluetooth/host/adv/extended/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
common:
build_only: true
tags:
- bluetooth
platform_allow:
- nrf52_bsim
- nrf5340bsim/nrf5340/cpunet
harness: bsim

tests:
bluetooth.host.adv.extended.advertiser:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_host_adv_extended_prj_advertiser_conf
extra_args:
CONF_FILE=prj_advertiser.conf
bluetooth.host.adv.extended.scanner:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_host_adv_extended_prj_scanner_conf
extra_args:
CONF_FILE=prj_scanner.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ verbosity_level=2

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_extended_prj_advertiser_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=ext_adv_advertiser -rs=23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ verbosity_level=2

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_extended_prj_advertiser_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=ext_adv_conn_advertiser -rs=23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ verbosity_level=2

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_extended_prj_advertiser_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=ext_adv_conn_advertiser_x5 -rs=23
Expand Down
13 changes: 0 additions & 13 deletions tests/bsim/bluetooth/host/adv/long_ad/compile.sh

This file was deleted.

4 changes: 4 additions & 0 deletions tests/bsim/bluetooth/host/adv/long_ad/test_scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ verbosity_level=2

SIM_LEN_US=$((2 * 1000 * 1000))

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

test_exe="${BSIM_OUT_PATH}/bin/bs_${BOARD_TS}_${test_name}_prj_conf"

cd ${BSIM_OUT_PATH}/bin
Expand Down
10 changes: 10 additions & 0 deletions tests/bsim/bluetooth/host/adv/long_ad/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tests:
bluetooth.host.adv.long_ad:
build_only: true
tags:
- bluetooth
platform_allow:
- nrf52_bsim
harness: bsim
harness_config:
bsim_exe_name: tests_bsim_bluetooth_host_adv_long_ad_prj_conf
14 changes: 0 additions & 14 deletions tests/bsim/bluetooth/host/adv/periodic/prj_coded.conf
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
CONFIG_BT=y
CONFIG_BT_DEVICE_NAME="test_per_adv"
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SMP=y
CONFIG_BT_PRIVACY=y

CONFIG_BT_EXT_ADV=y
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_ADV_AUX_SET=2
CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=2
CONFIG_BT_CTLR_PHY_CODED=y
CONFIG_BT_PER_ADV=y
CONFIG_BT_PER_ADV_SYNC=y
15 changes: 1 addition & 14 deletions tests/bsim/bluetooth/host/adv/periodic/prj_long_data.conf
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
CONFIG_BT=y
CONFIG_BT_DEVICE_NAME="test_per_adv"
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SMP=y
CONFIG_BT_PRIVACY=y

CONFIG_BT_EXT_ADV=y
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_ADV_AUX_SET=2
CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=2
CONFIG_BT_CTLR_ADV_AUX_PDU_BACK2BACK=y
CONFIG_BT_CTLR_ADV_SYNC_PDU_BACK2BACK=y
CONFIG_BT_PER_ADV=y
CONFIG_BT_PER_ADV_SYNC=y
CONFIG_BT_PER_ADV_SYNC_BUF_SIZE=1650

CONFIG_BT_PER_ADV_SYNC_BUF_SIZE=1650
CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=1650
CONFIG_BT_CTLR_ADV_DATA_CHAIN=y
CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=1650
23 changes: 23 additions & 0 deletions tests/bsim/bluetooth/host/adv/periodic/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
common:
build_only: true
tags:
- bluetooth
platform_allow:
- nrf52_bsim
- nrf5340bsim/nrf5340/cpunet
harness: bsim

tests:
bluetooth.host.adv.periodic:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_host_adv_periodic_prj_conf
bluetooth.host.adv.periodic.coded:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_host_adv_periodic_prj_coded_conf
extra_args:
EXTRA_CONF_FILE=prj_coded.conf
bluetooth.host.adv.periodic.long_data:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_host_adv_periodic_prj_long_data_conf
extra_args:
EXTRA_CONF_FILE=prj_long_data.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ verbosity_level=2

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=per_adv_advertiser -rs=23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ verbosity_level=2

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=per_adv_advertiser -rs=23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ verbosity_level=2

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_coded_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=per_adv_advertiser_coded_phy -rs=23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ verbosity_level=2

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=per_adv_conn_advertiser -rs=23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ EXECUTE_TIMEOUT=60

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=per_adv_conn_privacy_advertiser -rs=23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ EXECUTE_TIMEOUT=60

cd ${BSIM_OUT_PATH}/bin

if [ "${BOARD_TS}" = "nrf52_bsim" ]; then
BOARD_TS="${BOARD_TS}_native"
fi

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_long_data_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=per_adv_long_data_advertiser -rs=23
Expand Down
27 changes: 0 additions & 27 deletions tests/bsim/bluetooth/host/att/compile.sh

This file was deleted.

Loading

0 comments on commit 08b5104

Please sign in to comment.