Skip to contentSkip to conversation

Create and populate toplevel tests/ directory

PATCH In review Ananth N Mavinakayanahalli 5 participants 14 messages Jan 10, 2008 – Jan 15, 2008

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Create and populate toplevel tests/ directory

The following series of patches create and populate the toplevel tests/ directory. This will henceforth be the place where all in-kernel tests live.

All patches against 2.6.24-rc6-mm1

Ananth

#1 lore raw

PATCH 1/7 Add tests/ directory

From: Ananth N Mavinakayanahalli <[email protected]>

Create a toplevel tests/ directory to house in-kernel subsystem specific tests.

PS: I am not sure if I've gotten the Makefile change right.

---
 Makefile          |    3 +++
 lib/Kconfig.debug |    2 ++
 tests/Kconfig     |   11 +++++++++++
 tests/Makefile    |    3 +++
 4 files changed, 19 insertions(+)
lib/Kconfig.debug +2 -0
Index: linux-2.6.24-rc6/lib/Kconfig.debug
===================================================================
@@ -596,3 +596,5 @@ config PROVIDE_OHCI1394_DMA_INIT
 	  See Documentation/debugging-via-ohci1394.txt for more information.
 
 source "samples/Kconfig"
+
+source "tests/Kconfig"
tests/Kconfig new file +11 -0
Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================
@@ -0,0 +1,11 @@
+# tests/Kconfig
+
+menuconfig KERNEL_TESTS
+	bool "Kernel subsystem tests"
+	help
+	  You can build kernel subsystem specific tests.
+
+if KERNEL_TESTS
+
+endif # KERNEL_TESTS
+
tests/Makefile new file +3 -0
Index: linux-2.6.24-rc6/tests/Makefile
===================================================================
@@ -0,0 +1,3 @@
+#
+# Makefile for kernel subsystem specific tests
+#
Makefile +3 -0
Index: linux-2.6.24-rc6/Makefile
===================================================================
@@ -598,6 +598,9 @@ export mod_strip_cmd
 
 ifeq ($(KBUILD_EXTMOD),)
 core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/
+ifdef CONFIG_KERNEL_TESTS
+core-y		+= tests/
+endif
 
 vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
Acked-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] Add tests/ directory

Quoted 54 lines · Ananth N Mavinakayanahalli

From: Ananth N Mavinakayanahalli <[email protected]>

Create a toplevel tests/ directory to house in-kernel subsystem specific tests.

PS: I am not sure if I've gotten the Makefile change right.

---
 Makefile          |    3 +++
 lib/Kconfig.debug |    2 ++
 tests/Kconfig     |   11 +++++++++++
 tests/Makefile    |    3 +++
 4 files changed, 19 insertions(+)

Index: linux-2.6.24-rc6/lib/Kconfig.debug
===================================================================

lib/Kconfig.debug +2 -0
@@ -596,3 +596,5 @@ config PROVIDE_OHCI1394_DMA_INIT
 	  See Documentation/debugging-via-ohci1394.txt for more information.
 
 source "samples/Kconfig"
+
+source "tests/Kconfig"

Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================

tests/Kconfig new file +11 -0
@@ -0,0 +1,11 @@
+# tests/Kconfig
+
+menuconfig KERNEL_TESTS
+	bool "Kernel subsystem tests"
+	help
+	  You can build kernel subsystem specific tests.
+
+if KERNEL_TESTS
+
+endif # KERNEL_TESTS
+

Index: linux-2.6.24-rc6/tests/Makefile
===================================================================

tests/Makefile new file +3 -0
@@ -0,0 +1,3 @@
+#
+# Makefile for kernel subsystem specific tests
+#

Index: linux-2.6.24-rc6/Makefile
===================================================================

Makefile export mod_strip_cmd · line 603

Quoted 6 lines
Makefile +3 -0
@@ -598,6 +598,9 @@ export mod_strip_cmd
 
 ifeq ($(KBUILD_EXTMOD),)
 core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/
+ifdef CONFIG_KERNEL_TESTS
+core-y		+= tests/
+endif

CONFIG_KERNEL_TESTS is a bool so this should be written as:
core-$(CONFIG_KERNEL_TESTS) += tests/

With this change:

Sam

author Acked-by Sam Ravnborg
#3 lore raw

Re: [PATCH 1/7] Add tests/ directory

Quoted 65 lines · Sam Ravnborg
Quoted 54 lines · Ananth N Mavinakayanahalli

From: Ananth N Mavinakayanahalli <[email protected]>

Create a toplevel tests/ directory to house in-kernel subsystem specific tests.

PS: I am not sure if I've gotten the Makefile change right.

---
 Makefile          |    3 +++
 lib/Kconfig.debug |    2 ++
 tests/Kconfig     |   11 +++++++++++
 tests/Makefile    |    3 +++
 4 files changed, 19 insertions(+)

Index: linux-2.6.24-rc6/lib/Kconfig.debug
===================================================================

lib/Kconfig.debug +2 -0
@@ -596,3 +596,5 @@ config PROVIDE_OHCI1394_DMA_INIT
 	  See Documentation/debugging-via-ohci1394.txt for more information.
 
 source "samples/Kconfig"
+
+source "tests/Kconfig"

Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================

tests/Kconfig new file +11 -0
@@ -0,0 +1,11 @@
+# tests/Kconfig
+
+menuconfig KERNEL_TESTS
+	bool "Kernel subsystem tests"
+	help
+	  You can build kernel subsystem specific tests.
+
+if KERNEL_TESTS
+
+endif # KERNEL_TESTS
+

Index: linux-2.6.24-rc6/tests/Makefile
===================================================================

tests/Makefile new file +3 -0
@@ -0,0 +1,3 @@
+#
+# Makefile for kernel subsystem specific tests
+#

Index: linux-2.6.24-rc6/Makefile
===================================================================

Makefile export mod_strip_cmd · line 603

Quoted 6 lines
Makefile +3 -0
@@ -598,6 +598,9 @@ export mod_strip_cmd
 
 ifeq ($(KBUILD_EXTMOD),)
 core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/
+ifdef CONFIG_KERNEL_TESTS
+core-y		+= tests/
+endif

CONFIG_KERNEL_TESTS is a bool so this should be written as:
core-$(CONFIG_KERNEL_TESTS) += tests/

Quoted 2 lines

With this change:

Thanks Sam!

Updated patch below...

From: Ananth N Mavinakayanahalli <[email protected]>

Create a toplevel tests/ directory to house in-kernel subsystem specific tests.

PS: I am not sure if I've gotten the Makefile change right.

---
 Makefile          |    1 +
 lib/Kconfig.debug |    2 ++
 tests/Kconfig     |   11 +++++++++++
 tests/Makefile    |    3 +++
 4 files changed, 17 insertions(+)
lib/Kconfig.debug +2 -0
Index: linux-2.6.24-rc6/lib/Kconfig.debug
===================================================================
@@ -596,3 +596,5 @@ config PROVIDE_OHCI1394_DMA_INIT
 	  See Documentation/debugging-via-ohci1394.txt for more information.
 
 source "samples/Kconfig"
+
+source "tests/Kconfig"
tests/Kconfig new file +11 -0
Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================
@@ -0,0 +1,11 @@
+# tests/Kconfig
+
+menuconfig KERNEL_TESTS
+	bool "Kernel subsystem tests"
+	help
+	  You can build kernel subsystem specific tests.
+
+if KERNEL_TESTS
+
+endif # KERNEL_TESTS
+
tests/Makefile new file +3 -0
Index: linux-2.6.24-rc6/tests/Makefile
===================================================================
@@ -0,0 +1,3 @@
+#
+# Makefile for kernel subsystem specific tests
+#
Makefile +1 -0
Index: linux-2.6.24-rc6/Makefile
===================================================================
@@ -598,6 +598,7 @@ export mod_strip_cmd
 
 ifeq ($(KBUILD_EXTMOD),)
 core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/
+core-$(CONFIG_KERNEL_TESTS) += tests/
 
 vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
#4 lore raw

PATCH 2/7 Move locking-selftest to tests/

In reply to Ananth N Mavinakayanahalli

From: Ananth N Mavinakayanahalli <[email protected]>

Move the locking-selftest infrastructure to tests/

---
 lib/locking-selftest-hardirq.h         |    9 
 lib/locking-selftest-mutex.h           |   11 
 lib/locking-selftest-rlock-hardirq.h   |    2 
 lib/locking-selftest-rlock-softirq.h   |    2 
 lib/locking-selftest-rlock.h           |   14 
 lib/locking-selftest-rsem.h            |   14 
 lib/locking-selftest-softirq.h         |    9 
 lib/locking-selftest-spin-hardirq.h    |    2 
 lib/locking-selftest-spin-softirq.h    |    2 
 lib/locking-selftest-spin.h            |   11 
 lib/locking-selftest-wlock-hardirq.h   |    2 
 lib/locking-selftest-wlock-softirq.h   |    2 
 lib/locking-selftest-wlock.h           |   14 
 lib/locking-selftest-wsem.h            |   14 
 lib/locking-selftest.c                 | 1218 ---------------------------------
 lib/Kconfig.debug                      |   11 
 lib/Makefile                           |    1 
 tests/Kconfig                          |   11 
 tests/Makefile                         |    2 
 tests/locking-selftest-hardirq.h       |    9 
 tests/locking-selftest-mutex.h         |   11 
 tests/locking-selftest-rlock-hardirq.h |    2 
 tests/locking-selftest-rlock-softirq.h |    2 
 tests/locking-selftest-rlock.h         |   14 
 tests/locking-selftest-rsem.h          |   14 
 tests/locking-selftest-softirq.h       |    9 
 tests/locking-selftest-spin-hardirq.h  |    2 
 tests/locking-selftest-spin-softirq.h  |    2 
 tests/locking-selftest-spin.h          |   11 
 tests/locking-selftest-wlock-hardirq.h |    2 
 tests/locking-selftest-wlock-softirq.h |    2 
 tests/locking-selftest-wlock.h         |   14 
 tests/locking-selftest-wsem.h          |   14 
 tests/locking-selftest.c               | 1218 +++++++++++++++++++++++++++++++++
 34 files changed, 1339 insertions(+), 1338 deletions(-)
lib/Makefile +0 -1
Index: linux-2.6.24-rc6/lib/Makefile
===================================================================
@@ -25,7 +25,6 @@ lib-$(CONFIG_HOTPLUG) += kobject_uevent.
 obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
 obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
 obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
-obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
 lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
lib/locking-selftest-hardirq.h deleted +0 -9
Index: linux-2.6.24-rc6/lib/locking-selftest-hardirq.h
===================================================================
@@ -1,9 +0,0 @@
-#undef IRQ_DISABLE
-#undef IRQ_ENABLE
-#undef IRQ_ENTER
-#undef IRQ_EXIT
-
-#define IRQ_ENABLE		HARDIRQ_ENABLE
-#define IRQ_DISABLE		HARDIRQ_DISABLE
-#define IRQ_ENTER		HARDIRQ_ENTER
-#define IRQ_EXIT		HARDIRQ_EXIT
lib/locking-selftest-mutex.h deleted +0 -11
Index: linux-2.6.24-rc6/lib/locking-selftest-mutex.h
===================================================================
@@ -1,11 +0,0 @@
-#undef LOCK
-#define LOCK		ML
-
-#undef UNLOCK
-#define UNLOCK		MU
-
-#undef RLOCK
-#undef WLOCK
-
-#undef INIT
-#define INIT		MI
lib/locking-selftest-rlock-hardirq.h deleted +0 -2
Index: linux-2.6.24-rc6/lib/locking-selftest-rlock-hardirq.h
===================================================================
@@ -1,2 +0,0 @@
-#include "locking-selftest-rlock.h"
-#include "locking-selftest-hardirq.h"
lib/locking-selftest-rlock-softirq.h deleted +0 -2
Index: linux-2.6.24-rc6/lib/locking-selftest-rlock-softirq.h
===================================================================
@@ -1,2 +0,0 @@
-#include "locking-selftest-rlock.h"
-#include "locking-selftest-softirq.h"
lib/locking-selftest-rlock.h deleted +0 -14
Index: linux-2.6.24-rc6/lib/locking-selftest-rlock.h
===================================================================
@@ -1,14 +0,0 @@
-#undef LOCK
-#define LOCK		RL
-
-#undef UNLOCK
-#define UNLOCK		RU
-
-#undef RLOCK
-#define RLOCK		RL
-
-#undef WLOCK
-#define WLOCK		WL
-
-#undef INIT
-#define INIT		RWI
lib/locking-selftest-rsem.h deleted +0 -14
Index: linux-2.6.24-rc6/lib/locking-selftest-rsem.h
===================================================================
@@ -1,14 +0,0 @@
-#undef LOCK
-#define LOCK		RSL
-
-#undef UNLOCK
-#define UNLOCK		RSU
-
-#undef RLOCK
-#define RLOCK		RSL
-
-#undef WLOCK
-#define WLOCK		WSL
-
-#undef INIT
-#define INIT		RWSI
lib/locking-selftest-softirq.h deleted +0 -9
Index: linux-2.6.24-rc6/lib/locking-selftest-softirq.h
===================================================================
@@ -1,9 +0,0 @@
-#undef IRQ_DISABLE
-#undef IRQ_ENABLE
-#undef IRQ_ENTER
-#undef IRQ_EXIT
-
-#define IRQ_DISABLE		SOFTIRQ_DISABLE
-#define IRQ_ENABLE		SOFTIRQ_ENABLE
-#define IRQ_ENTER		SOFTIRQ_ENTER
-#define IRQ_EXIT		SOFTIRQ_EXIT
lib/locking-selftest-spin-hardirq.h deleted +0 -2
Index: linux-2.6.24-rc6/lib/locking-selftest-spin-hardirq.h
===================================================================
@@ -1,2 +0,0 @@
-#include "locking-selftest-spin.h"
-#include "locking-selftest-hardirq.h"
lib/locking-selftest-spin-softirq.h deleted +0 -2
Index: linux-2.6.24-rc6/lib/locking-selftest-spin-softirq.h
===================================================================
@@ -1,2 +0,0 @@
-#include "locking-selftest-spin.h"
-#include "locking-selftest-softirq.h"
lib/locking-selftest-spin.h deleted +0 -11
Index: linux-2.6.24-rc6/lib/locking-selftest-spin.h
===================================================================
@@ -1,11 +0,0 @@
-#undef LOCK
-#define LOCK		L
-
-#undef UNLOCK
-#define UNLOCK		U
-
-#undef RLOCK
-#undef WLOCK
-
-#undef INIT
-#define INIT		SI
lib/locking-selftest-wlock-hardirq.h deleted +0 -2
Index: linux-2.6.24-rc6/lib/locking-selftest-wlock-hardirq.h
===================================================================
@@ -1,2 +0,0 @@
-#include "locking-selftest-wlock.h"
-#include "locking-selftest-hardirq.h"
lib/locking-selftest-wlock-softirq.h deleted +0 -2
Index: linux-2.6.24-rc6/lib/locking-selftest-wlock-softirq.h
===================================================================
@@ -1,2 +0,0 @@
-#include "locking-selftest-wlock.h"
-#include "locking-selftest-softirq.h"
lib/locking-selftest-wlock.h deleted +0 -14
Index: linux-2.6.24-rc6/lib/locking-selftest-wlock.h
===================================================================
@@ -1,14 +0,0 @@
-#undef LOCK
-#define LOCK		WL
-
-#undef UNLOCK
-#define UNLOCK		WU
-
-#undef RLOCK
-#define RLOCK		RL
-
-#undef WLOCK
-#define WLOCK		WL
-
-#undef INIT
-#define INIT		RWI
lib/locking-selftest-wsem.h deleted +0 -14
Index: linux-2.6.24-rc6/lib/locking-selftest-wsem.h
===================================================================
@@ -1,14 +0,0 @@
-#undef LOCK
-#define LOCK		WSL
-
-#undef UNLOCK
-#define UNLOCK		WSU
-
-#undef RLOCK
-#define RLOCK		RSL
-
-#undef WLOCK
-#define WLOCK		WSL
-
-#undef INIT
-#define INIT		RWSI
lib/locking-selftest.c deleted +0 -1218

1,218 lines not on this page · raw message

tests/Kconfig +11 -0
Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================
@@ -7,5 +7,16 @@ menuconfig KERNEL_TESTS
 
 if KERNEL_TESTS
 
+config DEBUG_LOCKING_API_SELFTESTS
+	bool "Locking API boot-time self-tests"
+	depends on DEBUG_KERNEL
+	help
+	  Say Y here if you want the kernel to run a short self-test during
+	  bootup. The self-test checks whether common types of locking bugs
+	  are detected by debugging mechanisms or not. (if you disable
+	  lock debugging then those bugs wont be detected of course.)
+	  The following locking APIs are covered: spinlocks, rwlocks,
+	  mutexes and rwsems.
+
 endif # KERNEL_TESTS
 
tests/Makefile +2 -0
Index: linux-2.6.24-rc6/tests/Makefile
===================================================================
@@ -1,3 +1,5 @@
 #
 # Makefile for kernel subsystem specific tests
 #
+
+obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
tests/locking-selftest-hardirq.h new file +9 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-hardirq.h
===================================================================
@@ -0,0 +1,9 @@
+#undef IRQ_DISABLE
+#undef IRQ_ENABLE
+#undef IRQ_ENTER
+#undef IRQ_EXIT
+
+#define IRQ_ENABLE		HARDIRQ_ENABLE
+#define IRQ_DISABLE		HARDIRQ_DISABLE
+#define IRQ_ENTER		HARDIRQ_ENTER
+#define IRQ_EXIT		HARDIRQ_EXIT
tests/locking-selftest-mutex.h new file +11 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-mutex.h
===================================================================
@@ -0,0 +1,11 @@
+#undef LOCK
+#define LOCK		ML
+
+#undef UNLOCK
+#define UNLOCK		MU
+
+#undef RLOCK
+#undef WLOCK
+
+#undef INIT
+#define INIT		MI
tests/locking-selftest-rlock-hardirq.h new file +2 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-rlock-hardirq.h
===================================================================
@@ -0,0 +1,2 @@
+#include "locking-selftest-rlock.h"
+#include "locking-selftest-hardirq.h"
tests/locking-selftest-rlock-softirq.h new file +2 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-rlock-softirq.h
===================================================================
@@ -0,0 +1,2 @@
+#include "locking-selftest-rlock.h"
+#include "locking-selftest-softirq.h"
tests/locking-selftest-rlock.h new file +14 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-rlock.h
===================================================================
@@ -0,0 +1,14 @@
+#undef LOCK
+#define LOCK		RL
+
+#undef UNLOCK
+#define UNLOCK		RU
+
+#undef RLOCK
+#define RLOCK		RL
+
+#undef WLOCK
+#define WLOCK		WL
+
+#undef INIT
+#define INIT		RWI
tests/locking-selftest-rsem.h new file +14 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-rsem.h
===================================================================
@@ -0,0 +1,14 @@
+#undef LOCK
+#define LOCK		RSL
+
+#undef UNLOCK
+#define UNLOCK		RSU
+
+#undef RLOCK
+#define RLOCK		RSL
+
+#undef WLOCK
+#define WLOCK		WSL
+
+#undef INIT
+#define INIT		RWSI
tests/locking-selftest-softirq.h new file +9 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-softirq.h
===================================================================
@@ -0,0 +1,9 @@
+#undef IRQ_DISABLE
+#undef IRQ_ENABLE
+#undef IRQ_ENTER
+#undef IRQ_EXIT
+
+#define IRQ_DISABLE		SOFTIRQ_DISABLE
+#define IRQ_ENABLE		SOFTIRQ_ENABLE
+#define IRQ_ENTER		SOFTIRQ_ENTER
+#define IRQ_EXIT		SOFTIRQ_EXIT
tests/locking-selftest-spin-hardirq.h new file +2 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-spin-hardirq.h
===================================================================
@@ -0,0 +1,2 @@
+#include "locking-selftest-spin.h"
+#include "locking-selftest-hardirq.h"
tests/locking-selftest-spin-softirq.h new file +2 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-spin-softirq.h
===================================================================
@@ -0,0 +1,2 @@
+#include "locking-selftest-spin.h"
+#include "locking-selftest-softirq.h"
tests/locking-selftest-spin.h new file +11 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-spin.h
===================================================================
@@ -0,0 +1,11 @@
+#undef LOCK
+#define LOCK		L
+
+#undef UNLOCK
+#define UNLOCK		U
+
+#undef RLOCK
+#undef WLOCK
+
+#undef INIT
+#define INIT		SI
tests/locking-selftest-wlock-hardirq.h new file +2 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-wlock-hardirq.h
===================================================================
@@ -0,0 +1,2 @@
+#include "locking-selftest-wlock.h"
+#include "locking-selftest-hardirq.h"
tests/locking-selftest-wlock-softirq.h new file +2 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-wlock-softirq.h
===================================================================
@@ -0,0 +1,2 @@
+#include "locking-selftest-wlock.h"
+#include "locking-selftest-softirq.h"
tests/locking-selftest-wlock.h new file +14 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-wlock.h
===================================================================
@@ -0,0 +1,14 @@
+#undef LOCK
+#define LOCK		WL
+
+#undef UNLOCK
+#define UNLOCK		WU
+
+#undef RLOCK
+#define RLOCK		RL
+
+#undef WLOCK
+#define WLOCK		WL
+
+#undef INIT
+#define INIT		RWI
tests/locking-selftest-wsem.h new file +14 -0
Index: linux-2.6.24-rc6/tests/locking-selftest-wsem.h
===================================================================
@@ -0,0 +1,14 @@
+#undef LOCK
+#define LOCK		WSL
+
+#undef UNLOCK
+#define UNLOCK		WSU
+
+#undef RLOCK
+#define RLOCK		RSL
+
+#undef WLOCK
+#define WLOCK		WSL
+
+#undef INIT
+#define INIT		RWSI
tests/locking-selftest.c new file +1218 -0

1,218 lines not on this page · raw message

lib/Kconfig.debug +0 -11
Index: linux-2.6.24-rc6/lib/Kconfig.debug
===================================================================
@@ -350,17 +350,6 @@ config DEBUG_SPINLOCK_SLEEP
 	  If you say Y here, various routines which may sleep will become very
 	  noisy if they are called with a spinlock held.
 
-config DEBUG_LOCKING_API_SELFTESTS
-	bool "Locking API boot-time self-tests"
-	depends on DEBUG_KERNEL
-	help
-	  Say Y here if you want the kernel to run a short self-test during
-	  bootup. The self-test checks whether common types of locking bugs
-	  are detected by debugging mechanisms or not. (if you disable
-	  lock debugging then those bugs wont be detected of course.)
-	  The following locking APIs are covered: spinlocks, rwlocks,
-	  mutexes and rwsems.
-
 config STACKTRACE
 	bool
 	depends on DEBUG_KERNEL
#5 lore raw

PATCH 3/7 Move rcutorture to tests/

In reply to Ananth N Mavinakayanahalli

From: Ananth N Mavinakayanahalli <[email protected]>

Move the rcutorture infrastructure to tests/

---
 kernel/rcutorture.c |  995 ----------------------------------------------------
 kernel/Makefile     |    1 
 lib/Kconfig.debug   |   13 
 tests/Kconfig       |   13 
 tests/Makefile      |    1 
 tests/rcutorture.c  |  995 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 1009 insertions(+), 1009 deletions(-)
kernel/Makefile +0 -1
Index: linux-2.6.24-rc6/kernel/Makefile
===================================================================
@@ -56,7 +56,6 @@ obj-$(CONFIG_DETECT_SOFTLOCKUP) += softl
 obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
 obj-$(CONFIG_SECCOMP) += seccomp.o
 obj-$(CONFIG_DEBUG_SYNCHRO_TEST) += synchro-test.o
-obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
 obj-$(CONFIG_CLASSIC_RCU) += rcuclassic.o
 obj-$(CONFIG_PREEMPT_RCU) += rcupreempt.o
 ifeq ($(CONFIG_PREEMPT_RCU),y)
kernel/rcutorture.c deleted +0 -995

995 lines not on this page · raw message

lib/Kconfig.debug +0 -13
Index: linux-2.6.24-rc6/lib/Kconfig.debug
===================================================================
@@ -487,19 +487,6 @@ config DEBUG_SYNCHRO_TEST
 
 	  See Documentation/synchro-test.txt.
 
-config RCU_TORTURE_TEST
-	tristate "torture tests for RCU"
-	depends on DEBUG_KERNEL
-	depends on m
-	default n
-	help
-	  This option provides a kernel module that runs torture tests
-	  on the RCU infrastructure.  The kernel module may be built
-	  after the fact on the running kernel to be tested, if desired.
-
-	  Say M if you want the RCU torture tests to build as a module.
-	  Say N if you are unsure.
-
 config LKDTM
 	tristate "Linux Kernel Dump Test Tool Module"
 	depends on DEBUG_KERNEL
tests/Kconfig +13 -0
Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================
@@ -18,5 +18,18 @@ config DEBUG_LOCKING_API_SELFTESTS
 	  The following locking APIs are covered: spinlocks, rwlocks,
 	  mutexes and rwsems.
 
+config RCU_TORTURE_TEST
+	tristate "torture tests for RCU"
+	depends on DEBUG_KERNEL
+	depends on m
+	default n
+	help
+	  This option provides a kernel module that runs torture tests
+	  on the RCU infrastructure.  The kernel module may be built
+	  after the fact on the running kernel to be tested, if desired.
+
+	  Say M if you want the RCU torture tests to build as a module.
+	  Say N if you are unsure.
+
 endif # KERNEL_TESTS
 
tests/Makefile +1 -0
Index: linux-2.6.24-rc6/tests/Makefile
===================================================================
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
+obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
tests/rcutorture.c new file +995 -0

995 lines not on this page · raw message

#8 lore raw

PATCH 4/7 Move rtmutex tests under tests/

In reply to Ananth N Mavinakayanahalli

From: Ananth N Mavinakayanahalli <[email protected]>

Move the rtmutex-tester infrastructure to tests/

---
 kernel/rtmutex-tester.c |  442 ------------------------------------------------
 kernel/Makefile         |    1 
 lib/Kconfig.debug       |    6 
 tests/Kconfig           |    6 
 tests/Makefile          |    1 
 tests/rtmutex-tester.c  |  442 ++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 449 insertions(+), 449 deletions(-)
kernel/Makefile +0 -1
Index: linux-2.6.24-rc6/kernel/Makefile
===================================================================
@@ -25,7 +25,6 @@ obj-$(CONFIG_FUTEX) += futex_compat.o
 endif
 obj-$(CONFIG_RT_MUTEXES) += rtmutex.o
 obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o
-obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
 obj-$(CONFIG_SMP) += cpu.o spinlock.o
 obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
kernel/rtmutex-tester.c deleted +0 -442

442 lines not on this page · raw message

lib/Kconfig.debug +0 -6
Index: linux-2.6.24-rc6/lib/Kconfig.debug
===================================================================
@@ -219,12 +219,6 @@ config DEBUG_PI_LIST
 	default y
 	depends on DEBUG_RT_MUTEXES
 
-config RT_MUTEX_TESTER
-	bool "Built-in scriptable tester for rt-mutexes"
-	depends on DEBUG_KERNEL && RT_MUTEXES
-	help
-	  This option enables a rt-mutex tester.
-
 config DEBUG_SPINLOCK
 	bool "Spinlock and rw-lock debugging: basic checks"
 	depends on DEBUG_KERNEL
tests/Kconfig +6 -0
Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================
@@ -31,5 +31,11 @@ config RCU_TORTURE_TEST
 	  Say M if you want the RCU torture tests to build as a module.
 	  Say N if you are unsure.
 
+config RT_MUTEX_TESTER
+	bool "Built-in scriptable tester for rt-mutexes"
+	depends on DEBUG_KERNEL && RT_MUTEXES
+	help
+	  This option enables a rt-mutex tester.
+
 endif # KERNEL_TESTS
 
tests/Makefile +1 -0
Index: linux-2.6.24-rc6/tests/Makefile
===================================================================
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
+obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
tests/rtmutex-tester.c new file +442 -0

442 lines not on this page · raw message

#9 lore raw

PATCH 5/7 Move synchro-test under tests/

In reply to Ananth N Mavinakayanahalli

From: Ananth N Mavinakayanahalli <[email protected]>

Move the synchro-test infrastructure to tests/

---
 kernel/synchro-test.c |  526 --------------------------------------------------
 kernel/Makefile       |    1 
 lib/Kconfig.debug     |   14 -
 tests/Kconfig         |   14 +
 tests/Makefile        |    1 
 tests/synchro-test.c  |  526 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 541 insertions(+), 541 deletions(-)
kernel/Makefile +0 -1
Index: linux-2.6.24-rc6/kernel/Makefile
===================================================================
@@ -54,7 +54,6 @@ obj-$(CONFIG_SYSFS) += ksysfs.o
 obj-$(CONFIG_DETECT_SOFTLOCKUP) += softlockup.o
 obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
 obj-$(CONFIG_SECCOMP) += seccomp.o
-obj-$(CONFIG_DEBUG_SYNCHRO_TEST) += synchro-test.o
 obj-$(CONFIG_CLASSIC_RCU) += rcuclassic.o
 obj-$(CONFIG_PREEMPT_RCU) += rcupreempt.o
 ifeq ($(CONFIG_PREEMPT_RCU),y)
kernel/synchro-test.c deleted +0 -526

526 lines not on this page · raw message

lib/Kconfig.debug +0 -14
Index: linux-2.6.24-rc6/lib/Kconfig.debug
===================================================================
@@ -467,20 +467,6 @@ config BOOT_PRINTK_DELAY
 	  BOOT_PRINTK_DELAY also may cause DETECT_SOFTLOCKUP to detect
 	  what it believes to be lockup conditions.
 
-config DEBUG_SYNCHRO_TEST
-	tristate "Synchronisation primitive testing module"
-	depends on DEBUG_KERNEL
-	default n
-	help
-	  This option provides a kernel module that can thrash the sleepable
-	  synchronisation primitives (mutexes and semaphores).
-
-	  You should say N or M here. Whilst the module can be built in, it's
-	  not recommended as it requires module parameters supplying to get it
-	  to do anything.
-
-	  See Documentation/synchro-test.txt.
-
 config LKDTM
 	tristate "Linux Kernel Dump Test Tool Module"
 	depends on DEBUG_KERNEL
tests/Kconfig +14 -0
Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================
@@ -37,5 +37,19 @@ config RT_MUTEX_TESTER
 	help
 	  This option enables a rt-mutex tester.
 
+config DEBUG_SYNCHRO_TEST
+	tristate "Synchronisation primitive testing module"
+	depends on DEBUG_KERNEL
+	default n
+	help
+	  This option provides a kernel module that can thrash the sleepable
+	  synchronisation primitives (mutexes and semaphores).
+
+	  You should say N or M here. Whilst the module can be built in, it's
+	  not recommended as it requires module parameters supplying to get it
+	  to do anything.
+
+	  See Documentation/synchro-test.txt.
+
 endif # KERNEL_TESTS
 
tests/Makefile +1 -0
Index: linux-2.6.24-rc6/tests/Makefile
===================================================================
@@ -5,3 +5,4 @@
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
 obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
+obj-$(CONFIG_DEBUG_SYNCHRO_TEST) += synchro-test.o
tests/synchro-test.c new file +526 -0

526 lines not on this page · raw message

#10 lore raw

PATCH 6/7 Move lkdtm under tests/

In reply to Ananth N Mavinakayanahalli

From: Ananth N Mavinakayanahalli <[email protected]>

Move the lkdtm infrastructure to tests/

---
 drivers/misc/lkdtm.c  |  345 --------------------------------------------------
 drivers/misc/Makefile |    1 
 lib/Kconfig.debug     |   15 --
 tests/Kconfig         |   15 ++
 tests/Makefile        |    1 
 tests/lkdtm.c         |  345 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 361 insertions(+), 361 deletions(-)
drivers/misc/Makefile +0 -1
Index: linux-2.6.24-rc6/drivers/misc/Makefile
===================================================================
@@ -8,7 +8,6 @@ obj-$(CONFIG_HDPU_FEATURES)	+= hdpuftrs/
 obj-$(CONFIG_MSI_LAPTOP)     += msi-laptop.o
 obj-$(CONFIG_ASUS_LAPTOP)     += asus-laptop.o
 obj-$(CONFIG_ATMEL_SSC)		+= atmel-ssc.o
-obj-$(CONFIG_LKDTM)		+= lkdtm.o
 obj-$(CONFIG_TIFM_CORE)       	+= tifm_core.o
 obj-$(CONFIG_TIFM_7XX1)       	+= tifm_7xx1.o
 obj-$(CONFIG_PHANTOM)		+= phantom.o
drivers/misc/lkdtm.c deleted +0 -345

345 lines not on this page · raw message

lib/Kconfig.debug +0 -15
Index: linux-2.6.24-rc6/lib/Kconfig.debug
===================================================================
@@ -467,21 +467,6 @@ config BOOT_PRINTK_DELAY
 	  BOOT_PRINTK_DELAY also may cause DETECT_SOFTLOCKUP to detect
 	  what it believes to be lockup conditions.
 
-config LKDTM
-	tristate "Linux Kernel Dump Test Tool Module"
-	depends on DEBUG_KERNEL
-	depends on KPROBES
-	default n
-	help
-	This module enables testing of the different dumping mechanisms by
-	inducing system failures at predefined crash points.
-	If you don't need it: say N
-	Choose M here to compile this code as a module. The module will be
-	called lkdtm.
-
-	Documentation on how to use the module can be found in
-	drivers/misc/lkdtm.c
-
 config FAULT_INJECTION
 	bool "Fault-injection framework"
 	depends on DEBUG_KERNEL
tests/Kconfig +15 -0
Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================
@@ -51,5 +51,20 @@ config DEBUG_SYNCHRO_TEST
 
 	  See Documentation/synchro-test.txt.
 
+config LKDTM
+	tristate "Linux Kernel Dump Test Tool Module"
+	depends on DEBUG_KERNEL
+	depends on KPROBES
+	default n
+	help
+	This module enables testing of the different dumping mechanisms by
+	inducing system failures at predefined crash points.
+	If you don't need it: say N
+	Choose M here to compile this code as a module. The module will be
+	called lkdtm.
+
+	Documentation on how to use the module can be found in
+	drivers/misc/lkdtm.c
+
 endif # KERNEL_TESTS
 
tests/Makefile +1 -0
Index: linux-2.6.24-rc6/tests/Makefile
===================================================================
@@ -6,3 +6,4 @@ obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS
 obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
 obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
 obj-$(CONFIG_DEBUG_SYNCHRO_TEST) += synchro-test.o
+obj-$(CONFIG_LKDTM) += lkdtm.o
tests/lkdtm.c new file +345 -0

345 lines not on this page · raw message

#11 lore raw

PATCH 7/7 Add kprobes smoke tests under tests/

In reply to Ananth N Mavinakayanahalli

From: Ananth N Mavinakayanahalli <[email protected]>

Here is a quick and naive smoke test for kprobes. This is intended to just verify if some unrelated change broke the *probes subsystem. It is self contained, architecture agnostic and isn't of any great use by itself.

This needs to be built in the kernel and runs a basic set of tests to verify if kprobes, jprobes and kretprobes run fine on the kernel. In case of an error, it'll print out a message with a "BUG" prefix.

This is a start; we intend to add more tests to this bucket over time.

Thanks to Jim Keniston and Masami Hiramatsu for comments and suggestions.

Tested on x86 (32/64) and powerpc.

PS: This can't be built as a module (yet), as noinline doesn't always work reliably and I am yet to figure out a solution (non-varargs based), so jprobes tests can work seamlessly.

Updated to live under tests/

---
 include/linux/kprobes.h |    9 +
 kernel/kprobes.c        |    2 
 tests/Kconfig           |   12 ++
 tests/Makefile          |    1 
 tests/test_kprobes.c    |  218 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 242 insertions(+)
tests/Kconfig +12 -0
Index: linux-2.6.24-rc6/tests/Kconfig
===================================================================
@@ -66,5 +66,17 @@ config LKDTM
 	Documentation on how to use the module can be found in
 	drivers/misc/lkdtm.c
 
+config KPROBES_SANITY_TEST
+        bool "Kprobes sanity tests"
+        depends on DEBUG_KERNEL
+        depends on KPROBES
+        default n
+        help
+          This option provides for testing basic kprobes functionality on
+          boot. A sample kprobe, jprobe and kretprobe are inserted and
+          verified for functionality.
+
+          Say N if you are unsure.
+
 endif # KERNEL_TESTS
 
tests/Makefile +1 -0
Index: linux-2.6.24-rc6/tests/Makefile
===================================================================
@@ -7,3 +7,4 @@ obj-$(CONFIG_RCU_TORTURE_TEST) += rcutor
 obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
 obj-$(CONFIG_DEBUG_SYNCHRO_TEST) += synchro-test.o
 obj-$(CONFIG_LKDTM) += lkdtm.o
+obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o
tests/test_kprobes.c new file +218 -0

218 lines not on this page · raw message

include/linux/kprobes.h +9 -0
Index: linux-2.6.24-rc6/include/linux/kprobes.h
===================================================================
@@ -182,6 +182,15 @@ static inline void kretprobe_assert(stru
 	}
 }
 
+#ifdef CONFIG_KPROBES_SANITY_TEST
+extern int init_test_probes(void);
+#else
+static inline int init_test_probes(void)
+{
+	return 0;
+}
+#endif /* CONFIG_KPROBES_SANITY_TEST */
+
 extern spinlock_t kretprobe_lock;
 extern struct mutex kprobe_mutex;
 extern int arch_prepare_kprobe(struct kprobe *p);
kernel/kprobes.c +2 -0
Index: linux-2.6.24-rc6/kernel/kprobes.c
===================================================================
@@ -824,6 +824,8 @@ static int __init init_kprobes(void)
 	if (!err)
 		err = register_die_notifier(&kprobe_exceptions_nb);
 
+	if (!err)
+		init_test_probes();
 	return err;
 }
 
#12 lore raw
In reply to Ananth N Mavinakayanahalli

Hi Ananth.

Quoted 3 lines · Ananth N Mavinakayanahalli

The following series of patches create and populate the toplevel tests/ directory. This will henceforth be the place where all in-kernel tests live.

Thanks for creating these patches.
Look good - one small comment in a follow-up mail.

Sam

#13 lore raw
In reply to Ananth N Mavinakayanahalli
Quoted 5 lines · Ananth N Mavinakayanahalli

The following series of patches create and populate the toplevel tests/ directory. This will henceforth be the place where all in-kernel tests live.

All patches against 2.6.24-rc6-mm1

There's a small test I stuck at the end of lib/sort.c, if you're in the mood. And there's another large set of tests in the cryptoapi.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.