ostest: remove printf & sem_wait in sigaction

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2022-12-20 15:38:20 +08:00 committed by Masayuki Ishikawa
parent d1e46c2d3e
commit 7f11c91054

View File

@ -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");