kunit: test: move death test to its own KUnit config

KUnit's death test is not hermetic and can affect behavior of other
tests (http://b/116313114#comment8); that being said, there is not
really any way to make it hermetic without substantially changing how
KUnit works (b/116655541), and the test has proven very useful. Thus,
this commit moves it to its own Kconfig, so we can run other tests
either with it or without it.

Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
Google-Bug-Id: 116313114
Change-Id: I23c6e36834cc56a67ea589c67003fe4f031cb6db
diff --git a/test/Kconfig b/test/Kconfig
index 1b6d4be..971f4aa 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -21,6 +21,13 @@
 	help
 	  Enables KUnit test to test KUnit.
 
+config TEST_DEATH_TEST
+	bool "(Expert) KUnit death test for KUnit"
+	depends on TEST
+	help
+	  Enables KUnit test to test KUnit death test feature. This test is not
+	  hermetic and can cause other tests to misbehave.
+
 config EXAMPLE_TEST
 	bool "Example test for KUnit"
 	depends on TEST
diff --git a/test/Makefile b/test/Makefile
index 07c70a5..d7ca988 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_TEST)		+= test.o mock.o common-mocks.o string-stream.o \
   test-stream.o test-executor.o
 obj-$(CONFIG_TEST_TEST)		+= \
-  test-test.o test-mock.o mock-macro-test.o mock-test.o string-stream-test.o \
+  test-mock.o mock-macro-test.o mock-test.o string-stream-test.o \
   test-stream-test.o
+obj-$(CONFIG_TEST_TEST)		+= test-death-test.o
 obj-$(CONFIG_EXAMPLE_TEST)	+= example-test.o
diff --git a/test/test-death-test.c b/test/test-death-test.c
new file mode 100644
index 0000000..acdd9e6
--- /dev/null
+++ b/test/test-death-test.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * KUnit test for core test infrastructure.
+ *
+ * Copyright (C) 2018, Google LLC.
+ * Author: Brendan Higgins <brendanhiggins@google.com>
+ */
+#include <test/test.h>
+
+static void test_death_test_catches_segfault(struct test *test)
+{
+	void (*invalid_func)(void) = (void (*)(void)) SIZE_MAX;
+
+	ASSERT_SIGSEGV(test, invalid_func());
+}
+
+static struct test_case test_death_test_cases[] = {
+	TEST_CASE(test_death_test_catches_segfault),
+	{},
+};
+
+static struct test_module test_death_test_module = {
+	.name = "test-death-test",
+	.test_cases = test_death_test_cases,
+};
+module_test(test_death_test_module);
diff --git a/test/test-test.c b/test/test-test.c
deleted file mode 100644
index b1d7c7c..0000000
--- a/test/test-test.c
+++ /dev/null
@@ -1,37 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * KUnit test for core test infrastructure.
- *
- * Copyright (C) 2018, Google LLC.
- * Author: Brendan Higgins <brendanhiggins@google.com>
- */
-#include <test/test.h>
-
-static void test_test_catches_segfault(struct test *test)
-{
-	void (*invalid_func)(void) = (void (*)(void)) SIZE_MAX;
-
-	ASSERT_SIGSEGV(test, invalid_func());
-}
-
-static int test_test_init(struct test *test)
-{
-	return 0;
-}
-
-static void test_test_exit(struct test *test)
-{
-}
-
-static struct test_case test_test_cases[] = {
-	TEST_CASE(test_test_catches_segfault),
-	{},
-};
-
-static struct test_module test_test_module = {
-	.name = "test-test",
-	.init = test_test_init,
-	.exit = test_test_exit,
-	.test_cases = test_test_cases,
-};
-module_test(test_test_module);