Bluetooth: Add support for self testing framework
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 30 Dec 2014 04:48:35 +0000 (20:48 -0800)
committerJohan Hedberg <johan.hedberg@intel.com>
Tue, 30 Dec 2014 06:53:55 +0000 (08:53 +0200)
This add support for the Bluetooth self testing framework that allows
running certain test cases of sample data to ensure correctness of its
basic functionality.

With this patch only the basic framework will be added. It contains
the build magic that allows running this at module loading time or
at late_initcall stage when built into the kernel image.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
net/bluetooth/Kconfig
net/bluetooth/Makefile
net/bluetooth/af_bluetooth.c
net/bluetooth/selftest.c [new file with mode: 0644]
net/bluetooth/selftest.h [new file with mode: 0644]

index 29bcafc..3296841 100644 (file)
@@ -64,4 +64,17 @@ config BT_6LOWPAN
        help
          IPv6 compression over Bluetooth Low Energy.
 
+config BT_SELFTEST
+       bool "Bluetooth self testing support"
+       depends on BT && DEBUG_KERNEL
+       help
+         Run self tests when initializing the Bluetooth subsystem.  This
+         is a developer option and can cause significant delay when booting
+         the system.
+
+         When the Bluetooth subsystem is built as module, then the test
+         cases are run first thing at module load time.  When the Bluetooth
+         subsystem is compiled into the kernel image, then the test cases
+         are run late in the initcall hierarchy.
+
 source "drivers/bluetooth/Kconfig"
index 364cff1..8e96e30 100644 (file)
@@ -15,4 +15,6 @@ bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \
        hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \
        a2mp.o amp.o ecc.o hci_request.o hci_debugfs.o
 
+bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o
+
 subdir-ccflags-y += -D__CHECK_ENDIAN__
index 012e3b0..ce22e0c 100644 (file)
@@ -31,6 +31,8 @@
 #include <net/bluetooth/bluetooth.h>
 #include <linux/proc_fs.h>
 
+#include "selftest.h"
+
 #define VERSION "2.20"
 
 /* Bluetooth sockets */
@@ -716,6 +718,10 @@ static int __init bt_init(void)
 
        BT_INFO("Core ver %s", VERSION);
 
+       err = bt_selftest();
+       if (err < 0)
+               return err;
+
        bt_debugfs = debugfs_create_dir("bluetooth", NULL);
 
        err = bt_sysfs_init();
Simple merge
Simple merge