Skip to content
Permalink
Browse files

tests: Bluetooth: Add test case for settings in the controller.

Test case to set and change Company Id and Subversion Number.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
  • Loading branch information...
wopu-ot authored and carlescufi committed Jul 18, 2019
1 parent c5c3a46 commit f62fe1551a2e2053828491064ddc8c478a2c522a
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(bluetooth_ll_settings)

zephyr_library_include_directories($ENV{ZEPHYR_BASE}/subsys/bluetooth/controller/include)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
@@ -0,0 +1,15 @@
CONFIG_TEST=y
CONFIG_ZTEST=y

CONFIG_BT=y
CONFIG_BT_CTLR=y

CONFIG_SETTINGS=y
CONFIG_SETTINGS_RUNTIME=y

CONFIG_BT_SETTINGS=y
CONFIG_BT_CTLR_SETTINGS=y

CONFIG_BT_CTLR_VERSION_SETTINGS=y
CONFIG_BT_CTLR_COMPANY_ID=0x5F1
CONFIG_BT_CTLR_SUBVERSION_NUMBER=0xFFFF
@@ -0,0 +1,57 @@
/* main.c - Application main entry point */

/*
* Copyright (c) 2019 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr.h>
#include <stddef.h>
#include <ztest.h>

#include <settings/settings.h>

#include "ll_settings.h"

void test_company_id(void)
{
u16_t cid;
int err;

cid = 0x1234;
err = settings_runtime_set("bt/ctlr/company", &cid, sizeof(cid));
zassert_equal(err, 0, "Setting Company Id failed");
zassert_equal(ll_settings_company_id(), cid,
"Company Id does not match");

cid = 0x5678;
err = settings_runtime_set("bt/ctlr/company", &cid, sizeof(cid));
zassert_equal(err, 0, "Changing Company Id failed");
zassert_equal(ll_settings_company_id(), cid,
"Company ID does not match");
}

void test_subversion_number(void)
{
u16_t svn;

svn = 0x1234;
settings_runtime_set("bt/ctlr/subver", &svn, sizeof(svn));
zassert_equal(ll_settings_subversion_number(), svn,
"Subversion number does not match");

svn = 0x5678;
settings_runtime_set("bt/ctlr/subver", &svn, sizeof(svn));
zassert_equal(ll_settings_subversion_number(), svn,
"Subversion number does not match");
}

/*test case main entry*/
void test_main(void)
{
ztest_test_suite(test_ll_settings,
ztest_unit_test(test_company_id),
ztest_unit_test(test_subversion_number));
ztest_run_test_suite(test_ll_settings);
}
@@ -0,0 +1,4 @@
tests:
bluetooth.ll_settings:
platform_whitelist: nrf52_bsim
tags: bluetooth

0 comments on commit f62fe15

Please sign in to comment.
You can’t perform that action at this time.