-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bluetooth: tests: Add tests for UUID APIs
This adds initial test for UUID APIs. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
- Loading branch information
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 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_gatt) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE ${app_sources}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CONFIG_TEST=y | ||
CONFIG_ZTEST=y | ||
|
||
CONFIG_BT=y | ||
CONFIG_BT_CTLR=n | ||
CONFIG_BT_NO_DRIVER=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* 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 <bluetooth/uuid.h> | ||
|
||
static struct bt_uuid_16 uuid_16 = BT_UUID_INIT_16(0xffff); | ||
|
||
static struct bt_uuid_128 uuid_128 = BT_UUID_INIT_128( | ||
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, | ||
0x00, 0x10, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00); | ||
|
||
static void test_uuid_cmp(void) | ||
{ | ||
/* Compare UUID 16 bits */ | ||
zassert_false(bt_uuid_cmp(&uuid_16.uuid, BT_UUID_DECLARE_16(0xffff)), | ||
"Test UUIDs don't match"); | ||
|
||
/* Compare UUID 128 bits */ | ||
zassert_false(bt_uuid_cmp(&uuid_128.uuid, BT_UUID_DECLARE_16(0xffff)), | ||
"Test UUIDs don't match"); | ||
|
||
/* Compare UUID 16 bits with UUID 128 bits */ | ||
zassert_false(bt_uuid_cmp(&uuid_16.uuid, &uuid_128.uuid), | ||
"Test UUIDs don't match"); | ||
|
||
/* Compare different UUID 16 bits */ | ||
zassert_true(bt_uuid_cmp(&uuid_16.uuid, BT_UUID_DECLARE_16(0x0000)), | ||
"Test UUIDs match"); | ||
|
||
/* Compare different UUID 128 bits */ | ||
zassert_true(bt_uuid_cmp(&uuid_128.uuid, BT_UUID_DECLARE_16(0x000)), | ||
"Test UUIDs match"); | ||
} | ||
|
||
/*test case main entry*/ | ||
void test_main(void) | ||
{ | ||
ztest_test_suite(test_uuid, | ||
ztest_unit_test(test_uuid_cmp)); | ||
ztest_run_test_suite(test_uuid); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
tests: | ||
bluetooth.gatt: | ||
platform_whitelist: native_posix qemu_x86 qemu_cortex_m3 | ||
tags: bluetooth uuid |