From f85a6b6fb95e5f42c7a737cc9c7d9e69b8754335 Mon Sep 17 00:00:00 2001 From: Fotis Panagiotopoulos Date: Mon, 7 Nov 2022 18:07:13 +0200 Subject: [PATCH] Added poweroff in fs and mm tests. --- testing/fstest/Kconfig | 5 +++++ testing/fstest/fstest_main.c | 13 +++++++++++++ testing/mm/Kconfig | 5 +++++ testing/mm/mm_main.c | 15 +++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/testing/fstest/Kconfig b/testing/fstest/Kconfig index d468f9d3d..0e83e979e 100644 --- a/testing/fstest/Kconfig +++ b/testing/fstest/Kconfig @@ -71,4 +71,9 @@ config TESTING_FSTEST_VERBOSE bool "Verbose output" default n +config TESTING_FSTEST_POWEROFF + bool "Terminate on test completion" + default n + depends on BOARDCTL_POWEROFF + endif diff --git a/testing/fstest/fstest_main.c b/testing/fstest/fstest_main.c index 8474ee5d1..1d44675a3 100644 --- a/testing/fstest/fstest_main.c +++ b/testing/fstest/fstest_main.c @@ -28,6 +28,10 @@ #include #include +#ifdef CONFIG_TESTING_FSTEST_POWEROFF +#include +#endif + #include #include #include @@ -1175,5 +1179,14 @@ int main(int argc, FAR char *argv[]) fstest_endmemusage(ctx); fflush(stdout); free(ctx); + +#ifdef CONFIG_TESTING_FSTEST_POWEROFF + /* Power down. This is useful when used with the simulator and gcov, + * as the graceful shutdown allows for the generation of the .gcda files. + */ + + boardctl(BOARDIOC_POWEROFF, 0); +#endif + return 0; } diff --git a/testing/mm/Kconfig b/testing/mm/Kconfig index 9b30b0544..a3fc91ded 100644 --- a/testing/mm/Kconfig +++ b/testing/mm/Kconfig @@ -26,4 +26,9 @@ config TESTING_MM_STACKSIZE int "Stack size" default DEFAULT_TASK_STACKSIZE +config TESTING_MM_POWEROFF + bool "Terminate on test completion" + default n + depends on BOARDCTL_POWEROFF + endif diff --git a/testing/mm/mm_main.c b/testing/mm/mm_main.c index 155aadc65..bb5ec02f1 100644 --- a/testing/mm/mm_main.c +++ b/testing/mm/mm_main.c @@ -22,12 +22,18 @@ * Included Files ****************************************************************************/ +#include + #include #include #include #include #include +#ifdef CONFIG_TESTING_MM_POWEROFF +#include +#endif + #include /* Include nuttx/mm/mm_heap/mm.h */ @@ -354,5 +360,14 @@ int main(int argc, FAR char *argv[]) do_frees(g_allocs, g_alloc_small_sizes, g_random1, NTEST_ALLOCS); printf("TEST COMPLETE\n"); + +#ifdef CONFIG_TESTING_MM_POWEROFF + /* Power down. This is useful when used with the simulator and gcov, + * as the graceful shutdown allows for the generation of the .gcda files. + */ + + boardctl(BOARDIOC_POWEROFF, 0); +#endif + return 0; }