2015-10-03 01:33:30 +02:00
|
|
|
/****************************************************************************
|
2018-12-12 23:37:38 +01:00
|
|
|
* apps/testing/ostest/signest.c
|
2015-05-12 20:39:21 +02:00
|
|
|
*
|
2021-06-10 07:51:27 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2015-05-12 20:39:21 +02:00
|
|
|
*
|
2021-06-10 07:51:27 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-05-12 20:39:21 +02:00
|
|
|
*
|
2021-06-10 07:51:27 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2015-05-12 20:39:21 +02:00
|
|
|
*
|
2015-10-03 01:33:30 +02:00
|
|
|
****************************************************************************/
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-03-06 22:17:52 +01:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2023-03-16 03:35:15 +01:00
|
|
|
#include <assert.h>
|
2023-03-06 22:17:52 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <sched.h>
|
|
|
|
#include <semaphore.h>
|
|
|
|
#include <signal.h>
|
2015-05-12 20:39:21 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
2023-03-06 22:17:52 +01:00
|
|
|
#include <sys/types.h>
|
2015-05-12 20:39:21 +02:00
|
|
|
#include <unistd.h>
|
2023-03-06 22:17:52 +01:00
|
|
|
|
2015-05-12 20:39:21 +02:00
|
|
|
#include "ostest.h"
|
|
|
|
|
2015-10-03 01:33:30 +02:00
|
|
|
/****************************************************************************
|
2015-05-12 20:39:21 +02:00
|
|
|
* Pre-processor Definitions
|
2015-10-03 01:33:30 +02:00
|
|
|
****************************************************************************/
|
2015-05-12 20:39:21 +02:00
|
|
|
|
|
|
|
#define WAKEUP_SIGNAL 17
|
|
|
|
#define SIGVALUE_INT 42
|
|
|
|
|
2015-10-03 01:33:30 +02:00
|
|
|
/****************************************************************************
|
2015-05-12 20:39:21 +02:00
|
|
|
* Private Data
|
2015-10-03 01:33:30 +02:00
|
|
|
****************************************************************************/
|
2015-05-12 20:39:21 +02:00
|
|
|
|
|
|
|
static sem_t g_waiter_sem;
|
|
|
|
static sem_t g_interferer_sem;
|
2015-05-13 04:58:22 +02:00
|
|
|
static volatile bool g_waiter_running;
|
|
|
|
static volatile bool g_interferer_running;
|
|
|
|
static volatile bool g_done;
|
|
|
|
static volatile int g_nestlevel;
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2015-05-13 04:58:22 +02:00
|
|
|
static volatile int g_even_handled;
|
|
|
|
static volatile int g_odd_handled;
|
|
|
|
static volatile int g_even_nested;
|
|
|
|
static volatile int g_odd_nested;
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2015-05-13 04:58:22 +02:00
|
|
|
static volatile int g_nest_level;
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2015-10-03 01:33:30 +02:00
|
|
|
/****************************************************************************
|
2015-05-12 20:39:21 +02:00
|
|
|
* Private Functions
|
2015-10-03 01:33:30 +02:00
|
|
|
****************************************************************************/
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2018-08-30 21:37:37 +02:00
|
|
|
static bool signest_catchable(int signo)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
2020-11-05 12:48:55 +01:00
|
|
|
if (signo == SIGSTOP || signo == SIGCONT)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-08-30 21:37:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SIG_SIGKILL_ACTION
|
2020-11-05 12:48:55 +01:00
|
|
|
if (signo == SIGKILL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-08-30 21:37:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-05-12 20:39:21 +02:00
|
|
|
static void waiter_action(int signo)
|
|
|
|
{
|
|
|
|
int nest_level;
|
|
|
|
|
|
|
|
sched_lock();
|
|
|
|
nest_level = g_nest_level++;
|
|
|
|
sched_unlock();
|
|
|
|
|
|
|
|
if ((signo & 1) != 0)
|
|
|
|
{
|
|
|
|
g_odd_handled++;
|
|
|
|
if (nest_level > 0)
|
|
|
|
{
|
|
|
|
g_odd_nested++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_even_handled++;
|
|
|
|
if (nest_level > 0)
|
|
|
|
{
|
|
|
|
g_even_nested++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_nest_level = nest_level;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int waiter_main(int argc, char *argv[])
|
|
|
|
{
|
2015-07-31 21:31:44 +02:00
|
|
|
sigset_t set;
|
2015-05-12 20:39:21 +02:00
|
|
|
struct sigaction act;
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
printf("waiter_main: Waiter started\n");
|
|
|
|
printf("waiter_main: Setting signal mask\n");
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2020-01-02 13:09:50 +01:00
|
|
|
sigemptyset(&set);
|
2015-07-31 21:31:44 +02:00
|
|
|
ret = sigprocmask(SIG_SETMASK, &set, NULL);
|
2015-05-12 20:39:21 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
printf("waiter_main: ERROR sigprocmask failed: %d\n", errno);
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
printf("waiter_main: Registering signal handler\n");
|
2015-05-12 20:39:21 +02:00
|
|
|
|
|
|
|
act.sa_handler = waiter_action;
|
|
|
|
act.sa_flags = 0;
|
|
|
|
|
2020-01-02 13:09:50 +01:00
|
|
|
sigemptyset(&act.sa_mask);
|
2015-05-12 20:39:21 +02:00
|
|
|
for (i = 1; i < MAX_SIGNO; i += 2)
|
|
|
|
{
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(i))
|
|
|
|
{
|
2020-01-02 13:09:50 +01:00
|
|
|
sigaddset(&act.sa_mask, i);
|
2018-08-30 21:37:37 +02:00
|
|
|
}
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < MAX_SIGNO; i++)
|
|
|
|
{
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(i))
|
2015-05-12 20:39:21 +02:00
|
|
|
{
|
2018-08-30 21:37:37 +02:00
|
|
|
ret = sigaction(i, &act, NULL);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2020-11-05 12:49:45 +01:00
|
|
|
printf("waiter_main: WARNING sigaction failed with %d\n",
|
|
|
|
errno);
|
2018-08-30 21:37:37 +02:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now just loop until the test completes */
|
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
printf("waiter_main: Waiting on semaphore\n");
|
2015-05-12 20:39:21 +02:00
|
|
|
FFLUSH();
|
|
|
|
|
|
|
|
g_waiter_running = true;
|
|
|
|
while (!g_done)
|
|
|
|
{
|
|
|
|
ret = sem_wait(&g_waiter_sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Just exit, the system should clean up the signal handlers */
|
|
|
|
|
|
|
|
g_waiter_running = false;
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int interfere_main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
/* Now just loop staying in the way as much as possible */
|
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
printf("interfere_main: Waiting on semaphore\n");
|
2015-05-12 20:39:21 +02:00
|
|
|
FFLUSH();
|
|
|
|
|
|
|
|
g_interferer_running = true;
|
|
|
|
while (!g_done)
|
|
|
|
{
|
2020-01-02 13:09:50 +01:00
|
|
|
sem_wait(&g_interferer_sem);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Just exit, the system should clean up the signal handlers */
|
|
|
|
|
|
|
|
g_interferer_running = false;
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
2020-11-05 12:48:55 +01:00
|
|
|
|
2015-10-03 01:33:30 +02:00
|
|
|
/****************************************************************************
|
2015-05-12 20:39:21 +02:00
|
|
|
* Public Functions
|
2015-10-03 01:33:30 +02:00
|
|
|
****************************************************************************/
|
2015-05-12 20:39:21 +02:00
|
|
|
|
|
|
|
void signest_test(void)
|
|
|
|
{
|
|
|
|
struct sched_param param;
|
|
|
|
pid_t waiterpid;
|
|
|
|
pid_t interferepid;
|
|
|
|
int total_signals;
|
|
|
|
int total_handled;
|
|
|
|
int total_nested;
|
2015-05-13 04:58:22 +02:00
|
|
|
int even_signals;
|
|
|
|
int odd_signals;
|
2015-05-12 20:39:21 +02:00
|
|
|
int prio;
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
sem_init(&g_waiter_sem, 0, 0);
|
|
|
|
sem_init(&g_interferer_sem, 0, 0);
|
|
|
|
g_waiter_running = false;
|
|
|
|
g_interferer_running = false;
|
|
|
|
g_done = false;
|
|
|
|
g_nestlevel = 0;
|
|
|
|
|
2015-05-13 04:58:22 +02:00
|
|
|
even_signals = 0;
|
|
|
|
odd_signals = 0;
|
|
|
|
|
2015-05-12 20:39:21 +02:00
|
|
|
g_even_handled = 0;
|
|
|
|
g_odd_handled = 0;
|
|
|
|
g_even_nested = 0;
|
|
|
|
g_odd_nested = 0;
|
|
|
|
|
|
|
|
g_nest_level = 0;
|
|
|
|
|
|
|
|
ret = sched_getparam (0, ¶m);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2020-11-05 12:48:55 +01:00
|
|
|
printf("signest_test: ERROR sched_getparam() failed\n");
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
param.sched_priority = PTHREAD_DEFAULT_PRIORITY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start waiter thread */
|
|
|
|
|
|
|
|
prio = param.sched_priority + 1;
|
|
|
|
printf("signest_test: Starting signal waiter task at priority %d\n", prio);
|
|
|
|
waiterpid = task_create("waiter", param.sched_priority,
|
2018-06-07 17:52:02 +02:00
|
|
|
STACKSIZE, waiter_main, NULL);
|
2015-05-12 20:39:21 +02:00
|
|
|
if (waiterpid == ERROR)
|
|
|
|
{
|
|
|
|
printf("signest_test: ERROR failed to start waiter_main\n");
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("signest_test: Started waiter_main pid=%d\n", waiterpid);
|
|
|
|
|
|
|
|
/* Start interfering thread */
|
|
|
|
|
|
|
|
prio++;
|
|
|
|
printf("signest_test: Starting interfering task at priority %d\n", prio);
|
|
|
|
interferepid = task_create("interfere", param.sched_priority,
|
2018-06-07 17:52:02 +02:00
|
|
|
STACKSIZE, interfere_main, NULL);
|
2015-05-12 20:39:21 +02:00
|
|
|
if (interferepid == ERROR)
|
|
|
|
{
|
|
|
|
printf("signest_test: ERROR failed to start interfere_main\n");
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
goto errout_with_waiter;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("signest_test: Started interfere_main pid=%d\n", interferepid);
|
|
|
|
|
|
|
|
/* Wait a bit */
|
|
|
|
|
|
|
|
FFLUSH();
|
2020-11-05 12:48:55 +01:00
|
|
|
usleep(500 * 1000L);
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
/* Then signal the waiter thread with back-to-back signals, one masked
|
|
|
|
* and the other unmasked.
|
|
|
|
*/
|
2015-05-12 20:39:21 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
for (j = 1; j < MAX_SIGNO; j += 2)
|
|
|
|
{
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(j))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j);
|
|
|
|
odd_signals++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signest_catchable(j + 1))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j + 1);
|
|
|
|
even_signals++;
|
|
|
|
}
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
usleep(10 * 1000L);
|
2015-05-12 20:39:21 +02:00
|
|
|
|
|
|
|
/* Even then odd */
|
|
|
|
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(j + 1))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j + 1);
|
|
|
|
even_signals++;
|
|
|
|
}
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(j))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j);
|
|
|
|
odd_signals++;
|
|
|
|
}
|
2015-05-12 20:39:21 +02:00
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
usleep(10 * 1000L);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the test results so far */
|
|
|
|
|
2015-05-13 04:58:22 +02:00
|
|
|
total_signals = odd_signals + even_signals;
|
2015-05-12 20:39:21 +02:00
|
|
|
total_handled = g_odd_handled + g_even_handled;
|
|
|
|
total_nested = g_odd_nested + g_even_nested;
|
|
|
|
|
|
|
|
printf("signest_test: Simple case:\n");
|
|
|
|
printf(" Total signalled %-3d Odd=%-3d Even=%-3d\n",
|
2015-05-13 04:58:22 +02:00
|
|
|
total_signals, odd_signals, even_signals);
|
2015-05-12 20:39:21 +02:00
|
|
|
printf(" Total handled %-3d Odd=%-3d Even=%-3d\n",
|
|
|
|
total_handled, g_odd_handled, g_even_handled);
|
|
|
|
printf(" Total nested %-3d Odd=%-3d Even=%-3d\n",
|
|
|
|
total_nested, g_odd_nested, g_even_nested);
|
|
|
|
|
|
|
|
/* Then signal the waiter thread with two signals pending. The
|
|
|
|
* sched_lock() assures that the first signal was not processed
|
|
|
|
* before the second was delivered.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
for (j = 1; j < MAX_SIGNO; j += 2)
|
|
|
|
{
|
|
|
|
/* Odd then even */
|
|
|
|
|
|
|
|
sched_lock();
|
|
|
|
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(j))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j);
|
|
|
|
odd_signals++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signest_catchable(j + 1))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j + 1);
|
|
|
|
even_signals++;
|
|
|
|
}
|
|
|
|
|
2015-05-12 20:39:21 +02:00
|
|
|
sched_unlock();
|
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
usleep(10 * 1000L);
|
2015-05-12 20:39:21 +02:00
|
|
|
|
|
|
|
/* Even then odd */
|
|
|
|
|
|
|
|
sched_lock();
|
|
|
|
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(j + 1))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j + 1);
|
|
|
|
even_signals++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signest_catchable(j))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j);
|
|
|
|
odd_signals++;
|
|
|
|
}
|
|
|
|
|
2015-05-12 20:39:21 +02:00
|
|
|
sched_unlock();
|
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
usleep(10 * 1000L);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the test results so far */
|
|
|
|
|
2015-05-13 04:58:22 +02:00
|
|
|
total_signals = odd_signals + even_signals;
|
2015-05-12 20:39:21 +02:00
|
|
|
total_handled = g_odd_handled + g_even_handled;
|
|
|
|
total_nested = g_odd_nested + g_even_nested;
|
|
|
|
|
|
|
|
printf("signest_test: With task locking\n");
|
|
|
|
printf(" Total signalled %-3d Odd=%-3d Even=%-3d\n",
|
2015-05-13 04:58:22 +02:00
|
|
|
total_signals, odd_signals, even_signals);
|
2015-05-12 20:39:21 +02:00
|
|
|
printf(" Total handled %-3d Odd=%-3d Even=%-3d\n",
|
|
|
|
total_handled, g_odd_handled, g_even_handled);
|
|
|
|
printf(" Total nested %-3d Odd=%-3d Even=%-3d\n",
|
|
|
|
total_nested, g_odd_nested, g_even_nested);
|
|
|
|
|
|
|
|
/* Then do it all over again with the interfering thread. */
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
for (j = 1; j < MAX_SIGNO; j += 2)
|
|
|
|
{
|
|
|
|
/* Odd then even */
|
|
|
|
|
|
|
|
sched_lock();
|
2018-08-30 21:37:37 +02:00
|
|
|
|
|
|
|
if (signest_catchable(j))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j);
|
|
|
|
odd_signals++;
|
|
|
|
}
|
|
|
|
|
2015-05-12 20:39:21 +02:00
|
|
|
sem_post(&g_interferer_sem);
|
|
|
|
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(j + 1))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j + 1);
|
|
|
|
even_signals++;
|
|
|
|
}
|
|
|
|
|
2015-05-12 20:39:21 +02:00
|
|
|
sched_unlock();
|
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
usleep(10 * 1000L);
|
2015-05-12 20:39:21 +02:00
|
|
|
|
|
|
|
/* Even then odd */
|
|
|
|
|
|
|
|
sched_lock();
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(j + 1))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j + 1);
|
|
|
|
even_signals++;
|
|
|
|
}
|
|
|
|
|
2015-05-12 20:39:21 +02:00
|
|
|
sem_post(&g_interferer_sem);
|
|
|
|
|
2018-08-30 21:37:37 +02:00
|
|
|
if (signest_catchable(j))
|
|
|
|
{
|
|
|
|
kill(waiterpid, j);
|
|
|
|
odd_signals++;
|
|
|
|
}
|
|
|
|
|
2015-05-12 20:39:21 +02:00
|
|
|
sched_unlock();
|
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
usleep(10 * 1000L);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stop the threads */
|
|
|
|
|
|
|
|
errout_with_waiter:
|
|
|
|
g_done = true;
|
|
|
|
sem_post(&g_waiter_sem);
|
|
|
|
sem_post(&g_interferer_sem);
|
2020-11-05 12:48:55 +01:00
|
|
|
usleep(500 * 1000L);
|
2015-05-12 20:39:21 +02:00
|
|
|
|
|
|
|
/* Check the final test results */
|
|
|
|
|
2015-05-13 04:58:22 +02:00
|
|
|
total_signals = odd_signals + even_signals;
|
2015-05-12 20:39:21 +02:00
|
|
|
total_handled = g_odd_handled + g_even_handled;
|
|
|
|
total_nested = g_odd_nested + g_even_nested;
|
|
|
|
|
|
|
|
printf("signest_test: With intefering thread\n");
|
|
|
|
printf(" Total signalled %-3d Odd=%-3d Even=%-3d\n",
|
2015-05-13 04:58:22 +02:00
|
|
|
total_signals, odd_signals, even_signals);
|
2015-05-12 20:39:21 +02:00
|
|
|
printf(" Total handled %-3d Odd=%-3d Even=%-3d\n",
|
|
|
|
total_handled, g_odd_handled, g_even_handled);
|
|
|
|
printf(" Total nested %-3d Odd=%-3d Even=%-3d\n",
|
|
|
|
total_nested, g_odd_nested, g_even_nested);
|
|
|
|
|
|
|
|
/* Check for error */
|
|
|
|
|
|
|
|
if (g_waiter_running)
|
|
|
|
{
|
|
|
|
printf("signest_test: ERROR waiter is still running\n");
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (g_interferer_running)
|
|
|
|
{
|
|
|
|
printf("signest_test: ERROR interferer is still running\n");
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (total_signals != total_handled)
|
|
|
|
{
|
|
|
|
printf("signest_test: ERROR only %d of %d signals were handled\n",
|
|
|
|
total_handled, total_signals);
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
|
2015-05-13 04:58:22 +02:00
|
|
|
if (odd_signals != g_odd_handled)
|
2015-05-12 20:39:21 +02:00
|
|
|
{
|
|
|
|
printf("signest_test: ERROR only %d of %d ODD signals were handled\n",
|
2015-05-13 04:58:22 +02:00
|
|
|
g_odd_handled, odd_signals);
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
|
2015-05-13 04:58:22 +02:00
|
|
|
if (even_signals != g_even_handled)
|
2015-05-12 20:39:21 +02:00
|
|
|
{
|
|
|
|
printf("signest_test: ERROR only %d of %d EVEN signals were handled\n",
|
2015-05-13 04:58:22 +02:00
|
|
|
g_even_handled, even_signals);
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (g_odd_nested > 0)
|
|
|
|
{
|
|
|
|
printf("signest_test: ERROR %d ODD signals were nested\n",
|
|
|
|
g_odd_nested);
|
2022-10-15 16:36:29 +02:00
|
|
|
ASSERT(false);
|
2015-05-12 20:39:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sem_destroy(&g_waiter_sem);
|
|
|
|
sem_destroy(&g_interferer_sem);
|
|
|
|
|
2020-11-05 12:48:55 +01:00
|
|
|
printf("signest_test: done\n");
|
2015-05-12 20:39:21 +02:00
|
|
|
FFLUSH();
|
|
|
|
}
|