Skip to content
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
22 changes: 4 additions & 18 deletions tests/bsim/bluetooth/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,8 @@ set -ue
: "${ZEPHYR_BASE:?ZEPHYR_BASE must be set to point to the zephyr root directory}"
: "${INFUSE_BASE:?INFUSE_BASE must be set to point to the Infuse-IoT root directory}"

source ${ZEPHYR_BASE}/tests/bsim/compile.source
#Set a default value to BOARD if it does not have one yet
BOARD="${BOARD:-nrf52_bsim/native}"
OPTS="-iv --no-clean --outdir bsim/bluetooth -p ${BOARD}"

APP_EPACKET=tests/bsim/bluetooth/epacket
APP_GATT=tests/bsim/bluetooth/gatt
APP_TASK_RUNNER=tests/bsim/bluetooth/task_runner

app_root=$INFUSE_BASE app=$APP_EPACKET conf_file=prj_legacy_adv.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_EPACKET conf_file=prj_legacy_adv_named.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_EPACKET conf_file=prj_conn_terminator.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_EPACKET conf_file=prj_device.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_EPACKET conf_file=prj_device_public.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_EPACKET conf_file=prj_device_alt_network.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_EPACKET conf_file=prj_gateway.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_EPACKET conf_file=prj_gateway_grouping.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_EPACKET conf_file=prj_gateway_knows_alt.conf snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_GATT snippet=infuse compile
app_root=$INFUSE_BASE app=$APP_TASK_RUNNER snippet=infuse compile

wait_for_background_jobs
west twister $OPTS -T ${INFUSE_BASE}/tests/bsim/bluetooth/
34 changes: 0 additions & 34 deletions tests/bsim/bluetooth/epacket/CMakeLists.txt

This file was deleted.

16 changes: 16 additions & 0 deletions tests/bsim/bluetooth/epacket/device/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Embeint Holdings Pty Ltd
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(bsim_test_bluetooth_epacket)

target_sources(app PRIVATE
src/main.c
)

zephyr_include_directories(
${BSIM_COMPONENTS_PATH}/libUtilv1/src/
${BSIM_COMPONENTS_PATH}/libPhyComv1/src/
)
15 changes: 15 additions & 0 deletions tests/bsim/bluetooth/epacket/device/nrf_sdc.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/ {
chosen {
zephyr,bt-hci = &bt_hci_sdc;
};
};

&radio {
bt_hci_sdc: bt_hci_sdc {
compatible = "nordic,bt-hci-sdc";
status = "okay";
};
bt_hci_controller {
status = "disabled";
};
};
1 change: 1 addition & 0 deletions tests/bsim/bluetooth/epacket/device/prj_alt_network.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_INFUSE_SECURITY_DEFAULT_NETWORK="../../tests/bsim/bluetooth/epacket/alternate_network.yaml"
5 changes: 5 additions & 0 deletions tests/bsim/bluetooth/epacket/device/prj_public.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Public Bluetooth address
CONFIG_INFUSE_BOARD_HAS_PUBLIC_BT_ADDRESS=y

# No logging support
CONFIG_LOG_BACKEND_EPACKET_BT=n
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/random/random.h>

#include "common.h"

#include "bs_types.h"
#include "bs_tracing.h"
#include "time_machine.h"
Expand All @@ -25,6 +23,21 @@
#include <infuse/tdf/definitions.h>
#include <infuse/work_q.h>

#define FAIL(...) \
do { \
bst_result = Failed; \
bs_trace_error_time_line(__VA_ARGS__); \
} while (0)

#define PASS(...) \
do { \
bst_result = Passed; \
bs_trace_info_time(1, "PASSED: " __VA_ARGS__); \
} while (0)

#define WAIT_SECONDS 30 /* seconds */
#define WAIT_TIME (WAIT_SECONDS * USEC_PER_SEC) /* microseconds*/

extern enum bst_result_t bst_result;
static int connection_notifications;
static int disconnection_notifications;
Expand Down Expand Up @@ -250,6 +263,19 @@ static void main_epacket_bt_periph_send_unconnected(void)
PASS("Send to unconnected passed\n");
}

void test_tick(bs_time_t HW_device_time)
{
if (bst_result != Passed) {
FAIL("test failed (not passed after %i seconds)\n", WAIT_SECONDS);
}
}

void test_init(void)
{
bst_ticker_set_next_tick_absolute(WAIT_TIME);
bst_result = In_progress;
}

static const struct bst_test_instance ext_adv_advertiser[] = {
{
.test_id = "epacket_bt_device",
Expand Down
29 changes: 29 additions & 0 deletions tests/bsim/bluetooth/epacket/device/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
common:
build_only: true
required_snippets:
- infuse
tags:
- bluetooth
platform_allow:
- nrf52_bsim/native
- nrf5340bsim/nrf5340/cpunet
harness: bsim
tests:
bluetooth.epacket.device:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_epacket_device_prj_conf
bluetooth.epacket.device.alt_network:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_epacket_device_prj_alt_network_conf
extra_args:
- EXTRA_CONF_FILE=prj_alt_network.conf
bluetooth.epacket.device.public:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_epacket_device_prj_public_conf
extra_args:
- EXTRA_CONF_FILE=prj_public.conf
bluetooth.epacket.device.sdc:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_epacket_device_sdc_prj_conf
extra_args:
- DTC_OVERLAY_FILE="./app.overlay;./nrf_sdc.overlay"
16 changes: 16 additions & 0 deletions tests/bsim/bluetooth/epacket/gateway/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Embeint Holdings Pty Ltd
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(bsim_test_bluetooth_epacket)

target_sources(app PRIVATE
src/main.c
)

zephyr_include_directories(
${BSIM_COMPONENTS_PATH}/libUtilv1/src/
${BSIM_COMPONENTS_PATH}/libPhyComv1/src/
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Test options

config INFUSE_LEGACY_ADV
bool "Start legacy advertiser"

config CONN_TERMINATOR
bool "Terminate connections after creation"

config INFUSE_REBOOT
default y

Expand Down
12 changes: 12 additions & 0 deletions tests/bsim/bluetooth/epacket/gateway/app.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <mem.h>

/ {
epacket_dummy: epacket_dummy {
compatible = "embeint,epacket-dummy";
};

data_logger_shim: data_logger_shim {
compatible = "embeint,data-logger-shim", "embeint,data-logger";
physical-blocks = <128>;
};
};
15 changes: 15 additions & 0 deletions tests/bsim/bluetooth/epacket/gateway/nrf_sdc.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/ {
chosen {
zephyr,bt-hci = &bt_hci_sdc;
};
};

&radio {
bt_hci_sdc: bt_hci_sdc {
compatible = "nordic,bt-hci-sdc";
status = "okay";
};
bt_hci_controller {
status = "disabled";
};
};
2 changes: 2 additions & 0 deletions tests/bsim/bluetooth/epacket/gateway/prj_grouping.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_EPACKET_RECEIVE_GROUPING=y
CONFIG_EPACKET_RECEIVE_GROUPING_MAX_HOLD_MS=250
2 changes: 2 additions & 0 deletions tests/bsim/bluetooth/epacket/gateway/prj_knows_alt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_INFUSE_SECURITY_SECONDARY_NETWORK_ENABLE=y
CONFIG_INFUSE_SECURITY_SECONDARY_NETWORK="../../tests/bsim/bluetooth/epacket/alternate_network.yaml"
1 change: 1 addition & 0 deletions tests/bsim/bluetooth/epacket/gateway/prj_sdc.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_BT_MAX_CONN=3
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <zephyr/random/random.h>
#include <zephyr/bluetooth/hci_types.h>

#include "common.h"

#include "bs_types.h"
#include "bs_tracing.h"
#include "time_machine.h"
Expand All @@ -28,23 +26,56 @@
#include <infuse/bluetooth/gatt.h>
#include <infuse/fs/kv_store.h>
#include <infuse/fs/kv_types.h>
#include <infuse/reboot.h>
#include <infuse/rpc/types.h>
#include <infuse/rpc/client.h>
#include <infuse/security.h>
#include <infuse/states.h>

#define FAIL(...) \
do { \
bst_result = Failed; \
bs_trace_error_time_line(__VA_ARGS__); \
} while (0)

#define PASS(...) \
do { \
bst_result = Passed; \
bs_trace_info_time(1, "PASSED: " __VA_ARGS__); \
} while (0)

#define WAIT_SECONDS 30 /* seconds */
#define WAIT_TIME (WAIT_SECONDS * USEC_PER_SEC) /* microseconds*/

int epacket_bt_gatt_encrypt(struct net_buf *buf, uint32_t network_key_id);

uint8_t mem_buffer[1024];
extern enum bst_result_t bst_result;
static K_SEM_DEFINE(epacket_adv_received, 0, 1);
static K_SEM_DEFINE(bt_connected, 0, 1);
static K_SEM_DEFINE(bt_disconnected, 0, 1);
static K_SEM_DEFINE(reboot_request, 0, 1);
static bt_addr_le_t adv_device;
static atomic_t received_packets;

LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);

int infuse_reboot_state_query(struct infuse_reboot_state *state)
{
return -ENOENT;
}

void infuse_reboot(enum infuse_reboot_reason reason, uint32_t info1, uint32_t info2)
{
k_sem_give(&reboot_request);
}

void infuse_reboot_delayed(enum infuse_reboot_reason reason, uint32_t info1, uint32_t info2,
k_timeout_t delay)
{
k_sem_give(&reboot_request);
}

static void connected(struct bt_conn *conn, uint8_t err)
{
k_sem_give(&bt_connected);
Expand Down Expand Up @@ -2267,6 +2298,19 @@ static void main_gateway_mcumgr_none_reboot(void)
PASS("MCUMGR NONE rebooter passed\n");
}

void test_tick(bs_time_t HW_device_time)
{
if (bst_result != Passed) {
FAIL("test failed (not passed after %i seconds)\n", WAIT_SECONDS);
}
}

void test_init(void)
{
bst_ticker_set_next_tick_absolute(WAIT_TIME);
bst_result = In_progress;
}

static const struct bst_test_instance epacket_gateway[] = {
{
.test_id = "epacket_bt_gateway",
Expand Down
30 changes: 30 additions & 0 deletions tests/bsim/bluetooth/epacket/gateway/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
common:
build_only: true
required_snippets:
- infuse
tags:
- bluetooth
platform_allow:
- nrf52_bsim/native
- nrf5340bsim/nrf5340/cpunet
harness: bsim
tests:
bluetooth.epacket.gateway:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_epacket_gateway_prj_conf
bluetooth.epacket.gateway.grouping:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_epacket_gateway_prj_grouping_conf
extra_args:
- EXTRA_CONF_FILE=prj_grouping.conf
bluetooth.epacket.gateway.knows_alt:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_epacket_gateway_prj_knows_alt_conf
extra_args:
- EXTRA_CONF_FILE=prj_knows_alt.conf
bluetooth.epacket.gateway.sdc:
harness_config:
bsim_exe_name: tests_bsim_bluetooth_epacket_gateway_sdc_prj_conf
extra_args:
- DTC_OVERLAY_FILE="./app.overlay;./nrf_sdc.overlay"
- EXTRA_CONF_FILE=prj_sdc.conf
16 changes: 16 additions & 0 deletions tests/bsim/bluetooth/epacket/legacy_adv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Embeint Holdings Pty Ltd
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(bsim_test_bluetooth_epacket)

target_sources(app PRIVATE
src/main.c
)

zephyr_include_directories(
${BSIM_COMPONENTS_PATH}/libUtilv1/src/
${BSIM_COMPONENTS_PATH}/libPhyComv1/src/
)
12 changes: 12 additions & 0 deletions tests/bsim/bluetooth/epacket/legacy_adv/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Test options

config INFUSE_REBOOT
default y

config INFUSE_REBOOT_COMPILE
default n

config INFUSE_REBOOT_RETURN
default y

source "Kconfig.zephyr"
Loading