summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-06-04 10:46:58 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-06-09 12:20:05 +0200
commit7457c3d1d457922772e8bb7e07e3e9fe7dd0e09d (patch)
treea18ab27a128c0e99c153c16b64e19ded98557ca5 /common
parentff10a9966637f65efe2c82f65ad2b76e34f3774c (diff)
downloadbarebox-7457c3d1d457922772e8bb7e07e3e9fe7dd0e09d.tar.gz
barebox-7457c3d1d457922772e8bb7e07e3e9fe7dd0e09d.tar.xz
test: add basic barebox self-test infrastructure
Self tests is code written to run within barebox to exercise functionality. They offer flexibility to test specific units of barebox instead of the program as a whole. Add a very simple infrastructure for registering and executing self-tests. This is based on the Linux kselftest modules. We don't utilize modules for this, however, because we only have module support on ARM, but we need a generic solution. Selftests can be enabled individually and even tested without shell support to allow tests to happen for size-restricted barebox images as well. Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/startup.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/startup.c b/common/startup.c
index 080feebf05..d170cb8a7c 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -37,6 +37,7 @@
#include <linux/ctype.h>
#include <watchdog.h>
#include <glob.h>
+#include <bselftest.h>
extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[],
__barebox_initcalls_end[];
@@ -417,6 +418,9 @@ void __noreturn start_barebox(void)
pr_debug("initcalls done\n");
+ if (IS_ENABLED(CONFIG_SELFTEST_AUTORUN))
+ selftests_run();
+
if (barebox_main)
barebox_main();