diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Kconfig | 8 | ||||
-rw-r--r-- | test/Makefile | 1 | ||||
-rw-r--r-- | test/self/Kconfig | 33 | ||||
-rw-r--r-- | test/self/Makefile | 3 | ||||
-rw-r--r-- | test/self/core.c | 22 |
5 files changed, 67 insertions, 0 deletions
diff --git a/test/Kconfig b/test/Kconfig new file mode 100644 index 0000000000..eece702e68 --- /dev/null +++ b/test/Kconfig @@ -0,0 +1,8 @@ +menuconfig TEST + bool "Testing" + +if TEST + +source "test/self/Kconfig" + +endif diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000000..1b9eb2171a --- /dev/null +++ b/test/Makefile @@ -0,0 +1 @@ +obj-y += self/ diff --git a/test/self/Kconfig b/test/self/Kconfig new file mode 100644 index 0000000000..720abeffc5 --- /dev/null +++ b/test/self/Kconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0 + +config SELFTEST + bool "Self-tests" + help + Configures support for in-barebox testing + +if SELFTEST + +config CMD_SELFTEST + bool "selftest command" + depends on COMMAND_SUPPORT + help + Command to run enabled barebox self-tests. + If run without arguments, all tests are run + + Usage: selftest [-l] [tests...] + + Options: + -l list available tests + +config SELFTEST_AUTORUN + bool "Run self-tests on startup" + help + Self tests are run automatically after initcalls are done, + but before barebox_main (shell or board-specific startup). + +config SELFTEST_ENABLE_ALL + bool "Enable all self-tests" + help + Selects all self-tests compatible with current configuration + +endif diff --git a/test/self/Makefile b/test/self/Makefile new file mode 100644 index 0000000000..78f738c8e2 --- /dev/null +++ b/test/self/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_SELFTEST) += core.o diff --git a/test/self/core.c b/test/self/core.c new file mode 100644 index 0000000000..caa4c27f6d --- /dev/null +++ b/test/self/core.c @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#define pr_fmt(fmt) "bselftest: " fmt + +#include <common.h> +#include <bselftest.h> + +LIST_HEAD(selftests); + +void selftests_run(void) +{ + struct selftest *test; + int err = 0; + + pr_notice("Configured tests will run now\n"); + + list_for_each_entry(test, &selftests, list) + err |= test->func(); + + if (err) + pr_err("Some selftests failed\n"); +} |