This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new f85a6b6fb Added poweroff in fs and mm tests.
f85a6b6fb is described below

commit f85a6b6fb95e5f42c7a737cc9c7d9e69b8754335
Author: Fotis Panagiotopoulos <f.pa...@amco.gr>
AuthorDate: Mon Nov 7 18:07:13 2022 +0200

    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 <sys/ioctl.h>
 #include <sys/statfs.h>
 
+#ifdef CONFIG_TESTING_FSTEST_POWEROFF
+#include <sys/boardctl.h>
+#endif
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -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 <nuttx/config.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <malloc.h>
 #include <string.h>
 #include <assert.h>
 
+#ifdef CONFIG_TESTING_MM_POWEROFF
+#include <sys/boardctl.h>
+#endif
+
 #include <nuttx/queue.h>
 
 /* 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;
 }

Reply via email to