Skip to contentSkip to conversation

Bluetooth: Add support for self testing framework

RFC In review Marcel Holtmann 2 participants 2 messages Dec 30, 2014

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

RFC 1/2 Bluetooth: Add support for self testing framework

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.

---
 net/bluetooth/Kconfig        | 13 ++++++++++
 net/bluetooth/Makefile       |  2 ++
 net/bluetooth/af_bluetooth.c |  6 +++++
 net/bluetooth/selftest.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++
 net/bluetooth/selftest.h     | 45 ++++++++++++++++++++++++++++++++
 5 files changed, 128 insertions(+)
 create mode 100644 net/bluetooth/selftest.c
 create mode 100644 net/bluetooth/selftest.h
net/bluetooth/Kconfig +13 -0
index 29bcafc41adf..3296841531c9 100644
@@ -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"
net/bluetooth/Makefile +2 -0
index 364cff1ad4b1..8e96e3072266 100644
@@ -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__
net/bluetooth/af_bluetooth.c +6 -0
index 012e3b03589d..ce22e0cfa923 100644
@@ -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();
net/bluetooth/selftest.c new file +62 -0

62 lines not on this page · raw message

net/bluetooth/selftest.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.1.0
#1 lore raw

Hi Marcel,

Quoted 9 lines · Marcel Holtmann

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.

Quoted 9 lines
---
 net/bluetooth/Kconfig        | 13 ++++++++++
 net/bluetooth/Makefile       |  2 ++
 net/bluetooth/af_bluetooth.c |  6 +++++
 net/bluetooth/selftest.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++
 net/bluetooth/selftest.h     | 45 ++++++++++++++++++++++++++++++++
 5 files changed, 128 insertions(+)
 create mode 100644 net/bluetooth/selftest.c
 create mode 100644 net/bluetooth/selftest.h

Both of these patches have been applied to bluetooth-next. Thanks.

Johan