mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-17 09:14:32 +08:00
tools: Add skeleton for HCI controller testing
This commit is contained in:
parent
9d34d000b8
commit
7ba4515fb6
1
.gitignore
vendored
1
.gitignore
vendored
@ -65,6 +65,7 @@ tools/mpris-player
|
||||
tools/bluetooth-player
|
||||
tools/l2cap-tester
|
||||
tools/sco-tester
|
||||
tools/hci-tester
|
||||
tools/btproxy
|
||||
tools/btinfo
|
||||
tools/3dsp
|
||||
|
@ -39,7 +39,7 @@ if EXPERIMENTAL
|
||||
noinst_PROGRAMS += emulator/btvirt emulator/b1ee tools/3dsp \
|
||||
tools/mgmt-tester tools/gap-tester \
|
||||
tools/l2cap-tester tools/sco-tester \
|
||||
tools/smp-tester
|
||||
tools/smp-tester tools/hci-tester
|
||||
|
||||
emulator_btvirt_SOURCES = emulator/main.c monitor/bt.h \
|
||||
monitor/mainloop.h monitor/mainloop.c \
|
||||
@ -111,6 +111,14 @@ tools_sco_tester_SOURCES = tools/sco-tester.c monitor/bt.h \
|
||||
src/shared/hciemu.h src/shared/hciemu.c \
|
||||
src/shared/tester.h src/shared/tester.c
|
||||
tools_sco_tester_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
|
||||
|
||||
tools_hci_tester_SOURCES = tools/hci-tester.c monitor/bt.h \
|
||||
src/shared/io.h src/shared/io-glib.c \
|
||||
src/shared/hci.h src/shared/hci.c \
|
||||
src/shared/util.h src/shared/util.c \
|
||||
src/shared/queue.h src/shared/queue.c \
|
||||
src/shared/tester.h src/shared/tester.c
|
||||
tools_hci_tester_LDADD = @GLIB_LIBS@
|
||||
endif
|
||||
|
||||
if TOOLS
|
||||
|
@ -35,8 +35,9 @@ l2cap-tester 15 Kernel L2CAP implementation testing
|
||||
smp-tester 4 Kernel SMP implementation testing
|
||||
sco-tester 8 Kernel SCO implementation testing
|
||||
gap-tester 1 Daemon D-Bus API testing
|
||||
hci-tester 1 Controller hardware testing
|
||||
-----
|
||||
190
|
||||
191
|
||||
|
||||
|
||||
Android end-to-end testing
|
||||
|
115
tools/hci-tester.c
Normal file
115
tools/hci-tester.c
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation. All rights reserved.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "monitor/bt.h"
|
||||
#include "src/shared/hci.h"
|
||||
#include "src/shared/tester.h"
|
||||
|
||||
struct test_data {
|
||||
const void *test_data;
|
||||
uint16_t index;
|
||||
struct bt_hci *hci;
|
||||
};
|
||||
|
||||
static void test_pre_setup_reset_complete(const void *data, uint8_t size,
|
||||
void *user_data)
|
||||
{
|
||||
uint8_t status = *((uint8_t *) data);
|
||||
|
||||
if (status) {
|
||||
tester_warn("HCI Reset command failed (0x%02x)", status);
|
||||
tester_pre_setup_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
tester_pre_setup_complete();
|
||||
}
|
||||
|
||||
static void test_pre_setup(const void *test_data)
|
||||
{
|
||||
struct test_data *data = tester_get_data();
|
||||
|
||||
data->hci = bt_hci_new_user_channel(data->index);
|
||||
if (!data->hci) {
|
||||
tester_warn("Failed to setup HCI user channel");
|
||||
tester_pre_setup_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bt_hci_send(data->hci, BT_HCI_CMD_RESET, NULL, 0,
|
||||
test_pre_setup_reset_complete, NULL, NULL)) {
|
||||
tester_warn("Failed to send HCI Reset command");
|
||||
tester_pre_setup_failed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_post_teardown(const void *test_data)
|
||||
{
|
||||
struct test_data *data = tester_get_data();
|
||||
|
||||
bt_hci_unref(data->hci);
|
||||
data->hci = NULL;
|
||||
|
||||
tester_post_teardown_complete();
|
||||
}
|
||||
|
||||
static void test_data_free(void *test_data)
|
||||
{
|
||||
struct test_data *data = test_data;
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
#define test_hci(name, data, setup, func) \
|
||||
do { \
|
||||
struct test_data *user; \
|
||||
user = calloc(1, sizeof(struct test_data)); \
|
||||
if (!user) \
|
||||
break; \
|
||||
user->test_data = data; \
|
||||
user->index = 0; \
|
||||
tester_add_full(name, data, \
|
||||
test_pre_setup, setup, func, NULL, \
|
||||
test_post_teardown, 2, user, test_data_free); \
|
||||
} while (0)
|
||||
|
||||
static void dummy_test(const void *test_data)
|
||||
{
|
||||
tester_test_passed();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
tester_init(&argc, &argv);
|
||||
|
||||
test_hci("User channel setup", NULL, NULL, dummy_test);
|
||||
|
||||
return tester_run();
|
||||
}
|
Loading…
Reference in New Issue
Block a user