You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2022/12/21 04:38:22 UTC
[nuttx-apps] branch master updated: ostest: remove printf & sem_wait in sigaction
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 7f11c9105 ostest: remove printf & sem_wait in sigaction
7f11c9105 is described below
commit 7f11c910540a42f63ee1110db126230e1e4ea894
Author: ligd <li...@xiaomi.com>
AuthorDate: Tue Dec 20 15:38:20 2022 +0800
ostest: remove printf & sem_wait in sigaction
Signed-off-by: ligd <li...@xiaomi.com>
---
testing/ostest/sighand.c | 79 +-----------------------------------------------
1 file changed, 1 insertion(+), 78 deletions(-)
diff --git a/testing/ostest/sighand.c b/testing/ostest/sighand.c
index 2f209d532..a63744a7b 100644
--- a/testing/ostest/sighand.c
+++ b/testing/ostest/sighand.c
@@ -47,7 +47,6 @@ static sem_t sem1;
static sem_t sem2;
static bool sigreceived = false;
static bool thread1exited = false;
-static bool thread2exited = false;
/****************************************************************************
* Private Functions
@@ -86,15 +85,12 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext)
/* Use of printf in a signal handler is NOT safe! It can cause deadlocks! */
- printf("wakeup_action: Received signal %d\n" , signo);
-
sigreceived = true;
/* Check signo */
if (signo != WAKEUP_SIGNAL)
{
- printf("wakeup_action: ERROR expected signo=%d\n" , WAKEUP_SIGNAL);
ASSERT(false);
}
@@ -102,59 +98,27 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext)
if (info->si_value.sival_int != SIGVALUE_INT)
{
- printf("wakeup_action: ERROR sival_int=%d expected %d\n",
- info->si_value.sival_int, SIGVALUE_INT);
ASSERT(false);
}
- else
- {
- printf("wakeup_action: sival_int=%d\n" , info->si_value.sival_int);
- }
if (info->si_signo != WAKEUP_SIGNAL)
{
- printf("wakeup_action: ERROR expected si_signo=%d, got=%d\n",
- WAKEUP_SIGNAL, info->si_signo);
ASSERT(false);
}
- printf("wakeup_action: si_code=%d\n" , info->si_code);
-
- /* Check ucontext_t */
-
- printf("wakeup_action: ucontext=%p\n" , ucontext);
-
/* Check sigprocmask */
sigfillset(&allsigs);
status = sigprocmask(SIG_SETMASK, NULL, &oldset);
if (status != OK)
{
- printf("wakeup_action: ERROR sigprocmask failed, status=%d\n",
- status);
ASSERT(false);
}
if (oldset != allsigs)
{
- printf("wakeup_action: ERROR sigprocmask=%jx expected=%jx\n",
- (uintmax_t)oldset, (uintmax_t)allsigs);
ASSERT(false);
}
-
- /* Checkout sem_wait */
-
- status = sem_wait(&sem2);
- if (status != 0)
- {
- int error = errno;
- printf("wakeup_action: ERROR sem_wait failed, errno=%d\n" , error);
- ASSERT(false);
- }
- else
- {
- printf("wakeup_action: sem_wait() successfully!\n");
- }
}
static int waiter_main(int argc, char *argv[])
@@ -235,27 +199,6 @@ static int waiter_main(int argc, char *argv[])
return 0;
}
-static int poster_main(int argc, char *argv[])
-{
- int status;
-
- printf("poster_main: Poster started\n");
-
- status = sem_post(&sem2);
- if (status != 0)
- {
- int error = errno;
- printf("poster_main: sem_post failed error=%d\n", error);
- ASSERT(false);
- }
-
- printf("poster_main: done\n");
- FFLUSH();
-
- thread2exited = true;
- return 0;
-}
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -269,7 +212,7 @@ void sighand_test(void)
#endif
struct sched_param param;
union sigval sigvalue;
- pid_t waiterpid, posterpid;
+ pid_t waiterpid;
int status;
printf("sighand_test: Initializing semaphore to 0\n");
@@ -346,20 +289,6 @@ void sighand_test(void)
task_delete(waiterpid);
}
- /* Start poster thread */
-
- posterpid = task_create("poster", param.sched_priority,
- STACKSIZE, poster_main, NULL);
- if (posterpid == ERROR)
- {
- printf("sighand_test: ERROR failed to start poster_main\n");
- ASSERT(false);
- }
- else
- {
- printf("sighand_test: Started poster_main pid=%d\n", posterpid);
- }
-
/* Wait a bit */
FFLUSH();
@@ -377,12 +306,6 @@ void sighand_test(void)
ASSERT(false);
}
- if (!thread2exited)
- {
- printf("sighand_test: ERROR poster task did not exit\n");
- ASSERT(false);
- }
-
if (!sigreceived)
{
printf("sighand_test: ERROR signal handler did not run\n");