Skip to content
Permalink
Browse files

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...
Vudentz authored and jhedberg committed Jun 18, 2019
1 parent 5846a36 commit 72b05f3e176cde9f08b79da7917b8b0510c05768
@@ -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})
@@ -0,0 +1,6 @@
CONFIG_TEST=y
CONFIG_ZTEST=y

CONFIG_BT=y
CONFIG_BT_CTLR=n
CONFIG_BT_NO_DRIVER=y
@@ -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);
}
@@ -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.
You can’t perform that action at this time.