Skip to content

Commit

Permalink
Bluetooth: tests: Add tests for UUID APIs
Browse files Browse the repository at this point in the history
This adds initial test for UUID APIs.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
Vudentz authored and jhedberg committed Jun 24, 2019
1 parent 5846a36 commit 72b05f3
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/bluetooth/uuid/CMakeLists.txt
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})
6 changes: 6 additions & 0 deletions tests/bluetooth/uuid/prj.conf
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
50 changes: 50 additions & 0 deletions tests/bluetooth/uuid/src/main.c
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);
}
4 changes: 4 additions & 0 deletions tests/bluetooth/uuid/testcase.yaml
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

0 comments on commit 72b05f3

Please sign in to comment.