diff --git a/examples/ostest/Kconfig b/examples/ostest/Kconfig index dad1725f3..af9d7b445 100644 --- a/examples/ostest/Kconfig +++ b/examples/ostest/Kconfig @@ -108,11 +108,14 @@ config EXAMPLES_OSTEST_FPUSTACKSIZE endif # !EXAMPLES_OSTEST_FPUTESTDISABLE endif # ARCH_FPU && SCHED_WAITPID && !DISABLE_SIGNALS -if BOARDCTL_POWEROFF +config EXAMPLES_OSTEST_WAITRESULT + bool "Wait and return test result + default y + depends on SCHED_WAITPID config EXAMPLES_OSTEST_POWEROFF - bool "Terminate on return" - default n + bool "Terminate on test completion" + default n + depends on BOARDCTL_POWEROFF && EXAMPLES_OSTEST_WAITRESULT -endif # BOARDCTL_POWEROFF endif # EXAMPLES_OSTEST diff --git a/examples/ostest/ostest_main.c b/examples/ostest/ostest_main.c index a9d29f787..6d0ec4eeb 100644 --- a/examples/ostest/ostest_main.c +++ b/examples/ostest/ostest_main.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/examples/ostest/ostest_main.c * - * Copyright (C) 2007-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2012, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -555,7 +555,12 @@ int main(int argc, FAR char **argv) int ostest_main(int argc, FAR char *argv[]) { int result; +#ifdef CONFIG_EXAMPLES_OSTEST_WAITRESULT int ostest_result = ERROR; +#else + int ostest_result = OK; +#endif + /* Verify that stdio works first */ stdio_test(); @@ -604,16 +609,28 @@ int ostest_main(int argc, FAR char *argv[]) else { printf("ostest_main: Started user_main at PID=%d\n", result); - if(waitpid(result, &ostest_result,0) != result) + +#ifdef CONFIG_EXAMPLES_OSTEST_WAITRESULT + /* Wait for the test to complete to get the test result */ + + if (waitpid(result, &ostest_result, 0) != result) { printf("ostest_main: ERROR Failed to wait for user_main to terminate\n"); ostest_result = ERROR; } +#endif } - printf("ostest_main: Exiting with status %d\n",ostest_result); + printf("ostest_main: Exiting with status %d\n", ostest_result); + #ifdef CONFIG_EXAMPLES_OSTEST_POWEROFF - boardctl(BOARDIOC_POWEROFF,ostest_result); + /* Power down, providing the test result. This is really only an + *interesting case when used with the NuttX simulator. In that case, + * test management logic can received the result of the test. + */ + + boardctl(BOARDIOC_POWEROFF, ostest_result); #endif + return ostest_result; }