Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-12-27 Thread via GitHub


xiaoxiang781216 merged PR #2205:
URL: https://github.com/apache/nuttx-apps/pull/2205


-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-12-27 Thread via GitHub


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


##
testing/ostest/ostest_main.c:
##
@@ -680,9 +715,19 @@ int main(int argc, FAR char **argv)
 
   /* Verify that we can spawn a new task */
 
+#ifdef CONFIG_BUILD_KERNEL
+  posix_spawnattr_init();
+  param.sched_priority = PRIORITY;
+  posix_spawnattr_setschedparam(, );
+  posix_spawnattr_setstacksize(, STACKSIZE);
+  status = posix_spawn(, arg[0], NULL, ,
+   (char * const *)arg, NULL);
+  if (status != 0)
+#else
   result = task_create("ostest", PRIORITY, STACKSIZE, user_main,

Review Comment:
   Subtask in  user_main need check the argc and argv parameter list, but there 
is no copy argv list and argc in pthread_create API. If need, should rework for 
user_main, but do not change anything if posix_spawn is used in kernel mode.
   static int user_main(int argc, char *argv[])



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-12-26 Thread via GitHub


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


##
testing/ostest/ostest_main.c:
##
@@ -680,9 +715,19 @@ int main(int argc, FAR char **argv)
 
   /* Verify that we can spawn a new task */
 
+#ifdef CONFIG_BUILD_KERNEL
+  posix_spawnattr_init();
+  param.sched_priority = PRIORITY;
+  posix_spawnattr_setschedparam(, );
+  posix_spawnattr_setstacksize(, STACKSIZE);
+  status = posix_spawn(, arg[0], NULL, ,
+   (char * const *)arg, NULL);
+  if (status != 0)
+#else
   result = task_create("ostest", PRIORITY, STACKSIZE, user_main,

Review Comment:
   Subtask user_main need check the argc and argv list, but no copy argv list 
in pthread_create for parameter. If need, should rework for user_main, but do 
not change anything if posix_spawn in kernel mode.
   static int user_main(int argc, char *argv[])



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-12-21 Thread via GitHub


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


##
testing/ostest/signest.c:
##
@@ -180,10 +180,10 @@ static int waiter_main(int argc, char *argv[])
   /* Just exit, the system should clean up the signal handlers */
 
   g_waiter_running = false;
-  return EXIT_SUCCESS;
+  return NULL;
 }
 
-static int interfere_main(int argc, char *argv[])
+static void *interfere_main(void *arg)

Review Comment:
   ```suggestion
   static FAR void *interfere_main(FAR void *arg)
   ```



##
testing/ostest/ostest_main.c:
##
@@ -680,9 +715,19 @@ int main(int argc, FAR char **argv)
 
   /* Verify that we can spawn a new task */
 
+#ifdef CONFIG_BUILD_KERNEL
+  posix_spawnattr_init();
+  param.sched_priority = PRIORITY;
+  posix_spawnattr_setschedparam(, );
+  posix_spawnattr_setstacksize(, STACKSIZE);
+  status = posix_spawn(, arg[0], NULL, ,
+   (char * const *)arg, NULL);
+  if (status != 0)
+#else
   result = task_create("ostest", PRIORITY, STACKSIZE, user_main,

Review Comment:
   why not always use pthread_create



##
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)
+static void *pthread_exit_main(FAR void *arg)

Review Comment:
   ```suggestion
   static FAR void *pthread_exit_main(FAR void *arg)
   ```



##
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 *arg)

Review Comment:
   ```suggestion
   static FAR void *waiter_main(FAR void *arg)
   ```



##
testing/ostest/signest.c:
##
@@ -118,7 +118,7 @@ static void waiter_action(int signo)
   sem_post(_sem_signal_finish);
 }
 
-static int waiter_main(int argc, char *argv[])
+static void *waiter_main(void *arg)

Review Comment:
   ```suggestion
   static FAR void *waiter_main(FAR void *arg)
   ```



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-12-18 Thread via GitHub


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


##
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:
   global variable argx



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-12-09 Thread via GitHub


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


##
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:
   clearenv() will clear PATH, result in failure to find elf binary for 
sub-task spawn



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-12-09 Thread via GitHub


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


##
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:
   global variable to check status, but invalid in kernel mode
   https://github.com/apache/nuttx-apps/blob/master/testing/ostest/sighand.c#L55



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-12-09 Thread via GitHub


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


##
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:
   waitpid function is not completed, and child exit status is wrong. Should 
enable SCHED_CHILD_STATUS in kernel mode.



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-12-07 Thread via GitHub


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 

Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-11-27 Thread via GitHub


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


##
testing/ostest/signest.c:
##
@@ -295,11 +298,12 @@ void signest_test(void)
 
   /* Start interfering thread  */
 
-  prio++;
-  printf("signest_test: Starting interfering task at priority %d\n", prio);
-  interferepid = task_create("interfere", prio, STACKSIZE,

Review Comment:
   OK. That requires quite a bit of extra work to change with posix_spawn for 
kernel mode. 
   1. some case use many global variables to sync between tasks, but global 
variable is not the same copy between process for kernel mode
   https://github.com/apache/nuttx-apps/blob/master/testing/ostest/signest.c#L56
   2. waitpid to check WEXISTATUS is wrong in kernel mode.
   @xiaoxiang781216 



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-11-27 Thread via GitHub


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


##
testing/ostest/signest.c:
##
@@ -295,11 +298,12 @@ void signest_test(void)
 
   /* Start interfering thread  */
 
-  prio++;
-  printf("signest_test: Starting interfering task at priority %d\n", prio);
-  interferepid = task_create("interfere", prio, STACKSIZE,

Review Comment:
   OK. That requires quite a bit of extra work to change with posix_spawn for 
kernel mode. 
   1. some case use many global variables to sync between tasks, but global 
variable is not the same copy between process for kernel mode
   https://github.com/apache/nuttx-apps/blob/master/testing/ostest/signest.c#L56
   2. waitpid to check WEXISTATUS is wrong in kernel mode.



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-11-21 Thread via GitHub


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


##
testing/ostest/ostest_main.c:
##
@@ -706,6 +719,9 @@ int main(int argc, FAR char **argv)
 }
 
   printf("ostest_main: Exiting with status %d\n", ostest_result);
+#else
+  user_main(1, NULL);

Review Comment:
   test task_create function in flat mode, we can skip in kernel mode
   
https://github.com/apache/nuttx-apps/blob/master/testing/ostest/ostest_main.c#L681



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-11-21 Thread via GitHub


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


##
testing/ostest/ostest_main.c:
##
@@ -581,8 +585,16 @@ static int user_main(int argc, char *argv[])
 #endif
 
 #if defined(CONFIG_ARCH_HAVE_FORK) && defined(CONFIG_SCHED_WAITPID)
+#ifndef CONFIG_BUILD_KERNEL
   printf("\nuser_main: vfork() test\n");
   vfork_test();

Review Comment:
   Ok.



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-11-21 Thread via GitHub


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


##
testing/ostest/ostest_main.c:
##
@@ -581,8 +585,16 @@ static int user_main(int argc, char *argv[])
 #endif
 
 #if defined(CONFIG_ARCH_HAVE_FORK) && defined(CONFIG_SCHED_WAITPID)
+#ifndef CONFIG_BUILD_KERNEL
   printf("\nuser_main: vfork() test\n");
   vfork_test();

Review Comment:
   vfork->arm_fork do not support in CONFIG_BUILD_KERNEL, and will hang for 
some reason, there will be much effect to support it.



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] ostest: Add initial support for CONFIG_BUILD_KERNEL [nuttx-apps]

2023-11-21 Thread via GitHub


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


##
testing/ostest/ostest_main.c:
##
@@ -347,13 +349,15 @@ 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)
   /* Check waitpid() and friends */

Review Comment:
   waittpid support in kernel mode, why skip



##
testing/ostest/ostest_main.c:
##
@@ -225,6 +225,7 @@ static int user_main(int argc, char *argv[])
   printf("\nuser_main: Begin argument test\n");
   printf("user_main: Started with argc=%d\n", argc);
 
+#ifndef CONFIG_BUILD_KERNEL

Review Comment:
   why skip



##
testing/ostest/ostest_main.c:
##
@@ -706,6 +719,9 @@ int main(int argc, FAR char **argv)
 }
 
   printf("ostest_main: Exiting with status %d\n", ostest_result);
+#else
+  user_main(1, NULL);

Review Comment:
   why need #else



##
testing/ostest/signest.c:
##
@@ -295,11 +298,12 @@ void signest_test(void)
 
   /* Start interfering thread  */
 
-  prio++;
-  printf("signest_test: Starting interfering task at priority %d\n", prio);
-  interferepid = task_create("interfere", prio, STACKSIZE,

Review Comment:
   let's change task_create to posix_spawn



##
testing/ostest/ostest_main.c:
##
@@ -581,8 +585,16 @@ static int user_main(int argc, char *argv[])
 #endif
 
 #if defined(CONFIG_ARCH_HAVE_FORK) && defined(CONFIG_SCHED_WAITPID)
+#ifndef CONFIG_BUILD_KERNEL
   printf("\nuser_main: vfork() test\n");
   vfork_test();

Review Comment:
   vfork should support too?



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org