xiaoxiang781216 commented on code in PR #2205:
URL: https://github.com/apache/nuttx-apps/pull/2205#discussion_r1419242042


##########
testing/ostest/ostest_main.c:
##########
@@ -96,6 +96,32 @@ static const char g_bad_value2[]   = "BadValue2";
 static const char g_putenv_value[] = "Variable1=BadValue3";
 #endif
 
+#define POSIX_FUNC(func) \
+{ \
+  .name  = #func, \
+  .entry = func \
+}
+
+static struct posix_spawn_table_s
+{
+  const char *name;
+  CODE int (*entry)(int argc, char *argv[]);
+}
+g_posix_spawn_table[] =
+{
+#if defined(CONFIG_SCHED_WAITPID)
+POSIX_FUNC(waitpid_main),
+POSIX_FUNC(pthread_exit_main),
+#endif
+#if defined(CONFIG_SIG_SIGSTOP_ACTION) && defined(CONFIG_SIG_SIGKILL_ACTION)
+POSIX_FUNC(victim_main),
+#endif
+POSIX_FUNC(user_main)
+};
+
+static const int g_posix_spawn_table_count =
+    sizeof(g_posix_spawn_table) / sizeof(struct posix_spawn_table_s);

Review Comment:
   nitems



##########
testing/ostest/waitpid.c:
##########
@@ -70,10 +70,23 @@ static void waitpid_start_children(void)
 {
   int ret;
   int i;
+  struct sched_param param;
+  posix_spawnattr_t attr;
+  pid_t waiterpid;
+  FAR char *argv[3];

Review Comment:
   ```
     struct sched_param param;
     posix_spawnattr_t attr;
     pid_t waiterpid;
     FAR char *argv[3];
     int ret;
     int i;
   ```



##########
testing/ostest/ostest_main.c:
##########
@@ -96,6 +96,32 @@ static const char g_bad_value2[]   = "BadValue2";
 static const char g_putenv_value[] = "Variable1=BadValue3";
 #endif
 
+#define POSIX_FUNC(func) \

Review Comment:
   move to predefine section and change to POSIX_SPAWN_ENTRY



##########
testing/ostest/suspend.c:
##########
@@ -58,8 +58,14 @@ static int victim_main(int argc, char *argv[])
 void suspend_test(void)
 {
   struct sched_param param;
+  posix_spawnattr_t attr;
   pid_t victim;
   int ret;
+  FAR char *argv[3];

Review Comment:
   move after line 61



##########
testing/ostest/ostest_main.c:
##########
@@ -211,7 +237,7 @@ static void show_environment(bool var1_valid, bool 
var2_valid,
  * Name: user_main
  ****************************************************************************/
 
-static int user_main(int argc, char *argv[])
+int user_main(int argc, char *argv[])

Review Comment:
   keep as the static function



##########
testing/ostest/pthread_exit.c:
##########
@@ -97,20 +97,38 @@ static int pthread_exit_main(int argc, char **argv)
 void pthread_exit_test(void)
 {
   int statloc;
+  posix_spawnattr_t attr;
+  struct sched_param param;
   int ret;
-
-  ret = task_create("pthread_exit", PRIORITY, STACKSIZE, pthread_exit_main,
-                    NULL);
+  pid_t pid;
+  FAR char *argv[3];

Review Comment:
   ```
     struct sched_param param;
     posix_spawnattr_t attr;
     FAR char *argv[3];
     pid_t pid;
     int statloc;
     int ret;
   ```



##########
testing/ostest/ostest_main.c:
##########
@@ -347,13 +375,16 @@ static int user_main(int argc, char *argv[])
       check_test_memory_usage();
 #endif
 
+#ifndef CONFIG_BUILD_KERNEL
       /* Checkout task_restart() */
 
       printf("\nuser_main: task_restart test\n");
       restart_test();
       check_test_memory_usage();
+#endif
 
-#ifdef CONFIG_SCHED_WAITPID
+#if defined(CONFIG_SCHED_WAITPID) && \
+    (!defined(CONFIG_BUILD_KERNEL) || defined(CONFIG_SCHED_CHILD_STATUS))

Review Comment:
   why check CONFIG_BUILD_KERNEL



##########
testing/ostest/ostest_main.c:
##########
@@ -641,6 +680,28 @@ int main(int argc, FAR char **argv)
 #else
   int ostest_result = OK;
 #endif
+  int i;
+  pid_t pid;
+  struct sched_param param;
+  posix_spawnattr_t attr;
+  FAR const char * const arg[7] =
+  {
+    argv[0], "user_main", arg1, arg2, arg3, arg4, NULL
+  };
+
+  /* posix_spawn API to spawn the new task for tests, need re-visit
+   * the main entry, Use the second arg string to identify the real
+   * entry of test tasks
+   */
+
+  for (i = 0; i < g_posix_spawn_table_count; i++)

Review Comment:
   nitems(g_posix_spawn_table)



##########
testing/ostest/sighand.c:
##########
@@ -128,7 +128,7 @@ static void wakeup_action(int signo, siginfo_t *info, void 
*ucontext)
     }
 }
 
-static int waiter_main(int argc, char *argv[])
+static void *waiter_main(FAR void *parm)

Review Comment:
   why not use posix_spawn



##########
testing/ostest/waitpid.c:
##########
@@ -55,7 +55,7 @@ static int g_waitpids[NCHILDREN];
  * Private Functions
  ****************************************************************************/
 
-static int waitpid_main(int argc, char *argv[])
+int waitpid_main(int argc, char *argv[])

Review Comment:
   move to public section, ALL pointer to FAR



##########
testing/ostest/ostest_main.c:
##########
@@ -96,6 +96,32 @@ static const char g_bad_value2[]   = "BadValue2";
 static const char g_putenv_value[] = "Variable1=BadValue3";
 #endif
 
+#define POSIX_FUNC(func) \
+{ \
+  .name  = #func, \
+  .entry = func \
+}
+
+static struct posix_spawn_table_s
+{
+  const char *name;
+  CODE int (*entry)(int argc, char *argv[]);
+}
+g_posix_spawn_table[] =
+{
+#if defined(CONFIG_SCHED_WAITPID)
+POSIX_FUNC(waitpid_main),

Review Comment:
   intent



##########
testing/ostest/ostest_main.c:
##########
@@ -295,7 +321,9 @@ static int user_main(int argc, char *argv[])
   show_environment(false, true, true);
   check_test_memory_usage();
 
+#ifndef CONFIG_BUILD_KERNEL

Review Comment:
   why skip



##########
testing/ostest/pthread_exit.c:
##########
@@ -56,7 +56,7 @@ static void *pthread_exit_thread(FAR void *parameter)
   return NULL;
 }
 
-static int pthread_exit_main(int argc, char **argv)
+int pthread_exit_main(int argc, char *argv[])

Review Comment:
   move public section



##########
testing/ostest/ostest_main.c:
##########
@@ -96,6 +96,32 @@ static const char g_bad_value2[]   = "BadValue2";
 static const char g_putenv_value[] = "Variable1=BadValue3";
 #endif
 
+#define POSIX_FUNC(func) \
+{ \
+  .name  = #func, \
+  .entry = func \
+}
+
+static struct posix_spawn_table_s
+{
+  const char *name;
+  CODE int (*entry)(int argc, char *argv[]);
+}
+g_posix_spawn_table[] =
+{
+#if defined(CONFIG_SCHED_WAITPID)
+POSIX_FUNC(waitpid_main),
+POSIX_FUNC(pthread_exit_main),
+#endif
+#if defined(CONFIG_SIG_SIGSTOP_ACTION) && defined(CONFIG_SIG_SIGKILL_ACTION)
+POSIX_FUNC(victim_main),
+#endif
+POSIX_FUNC(user_main)
+};
+
+static const int g_posix_spawn_table_count =

Review Comment:
   int->size_t



##########
testing/ostest/ostest_main.c:
##########
@@ -641,6 +680,28 @@ int main(int argc, FAR char **argv)
 #else
   int ostest_result = OK;
 #endif
+  int i;
+  pid_t pid;
+  struct sched_param param;
+  posix_spawnattr_t attr;
+  FAR const char * const arg[7] =
+  {
+    argv[0], "user_main", arg1, arg2, arg3, arg4, NULL

Review Comment:
   where argx define



##########
testing/ostest/ostest.h:
##########
@@ -87,6 +87,8 @@
  * Public Function Prototypes
  ****************************************************************************/
 
+int user_main(int argc, char *argv[]);

Review Comment:
   add FAR for ALL pointers



##########
testing/ostest/ostest_main.c:
##########
@@ -641,6 +680,28 @@ int main(int argc, FAR char **argv)
 #else
   int ostest_result = OK;
 #endif
+  int i;

Review Comment:
   ```
     struct sched_param param;
     posix_spawnattr_t attr;
     FAR const char * const arg[7] =
     {
       argv[0], "user_main", arg1, arg2, arg3, arg4, NULL
     };
   #ifdef CONFIG_TESTING_OSTEST_WAITRESULT
     int ostest_result = ERROR;
   #else
     int ostest_result = OK;
   #endif
     int result;
     pid_t pid;
     size_t i;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to