From e7dc07c29109922e75ce9ab7e0c76de479e55f11 Mon Sep 17 00:00:00 2001 From: Brennan Ashton Date: Mon, 6 Jul 2015 11:51:15 -0700 Subject: [PATCH] [OSTEST] Add option to poweroff with test status --- examples/ostest/Kconfig | 8 ++++++++ examples/ostest/ostest_main.c | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/examples/ostest/Kconfig b/examples/ostest/Kconfig index 2a061efa4..dad1725f3 100644 --- a/examples/ostest/Kconfig +++ b/examples/ostest/Kconfig @@ -107,4 +107,12 @@ config EXAMPLES_OSTEST_FPUSTACKSIZE endif # !EXAMPLES_OSTEST_FPUTESTDISABLE endif # ARCH_FPU && SCHED_WAITPID && !DISABLE_SIGNALS + +if BOARDCTL_POWEROFF + +config EXAMPLES_OSTEST_POWEROFF + bool "Terminate on return" + default n + +endif # BOARDCTL_POWEROFF endif # EXAMPLES_OSTEST diff --git a/examples/ostest/ostest_main.c b/examples/ostest/ostest_main.c index 31136cd99..a9d29f787 100644 --- a/examples/ostest/ostest_main.c +++ b/examples/ostest/ostest_main.c @@ -48,6 +48,10 @@ #include #include +#ifdef CONFIG_EXAMPLES_OSTEST_POWEROFF +#include +#endif + #include #include "ostest.h" @@ -551,7 +555,7 @@ int main(int argc, FAR char **argv) int ostest_main(int argc, FAR char *argv[]) { int result; - + int ostest_result = ERROR; /* Verify that stdio works first */ stdio_test(); @@ -595,12 +599,21 @@ int ostest_main(int argc, FAR char *argv[]) if (result == ERROR) { printf("ostest_main: ERROR Failed to start user_main\n"); + ostest_result = ERROR; } else { printf("ostest_main: Started user_main at PID=%d\n", result); + if(waitpid(result, &ostest_result,0) != result) + { + printf("ostest_main: ERROR Failed to wait for user_main to terminate\n"); + ostest_result = ERROR; + } } - printf("ostest_main: Exiting\n"); - return 0; + printf("ostest_main: Exiting with status %d\n",ostest_result); +#ifdef CONFIG_EXAMPLES_OSTEST_POWEROFF + boardctl(BOARDIOC_POWEROFF,ostest_result); +#endif + return ostest_result; }