Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion testing/ostest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ if(CONFIG_TESTING_OSTEST)
endif()

set(OSTEST_SRCS ostest_main.c ${SRCS})
nuttx_add_application(NAME ostest SRCS ${OSTEST_SRCS})
nuttx_add_application(
MODULE
${CONFIG_TESTING_OSTEST}
NAME
ostest
SRCS
${OSTEST_SRCS}
STACKSIZE
${CONFIG_TESTING_OSTEST_STACKSIZE}
PRIORITY
${CONFIG_TESTING_OSTEST_PRIORITY})

endif()
4 changes: 4 additions & 0 deletions testing/ostest/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ config TESTING_OSTEST_LOOPS
Used to control the number of executions of the test. If undefined, the test
executes one time. If defined to be zero, the test runs forever.

config TESTING_OSTEST_PRIORITY
int "OS test task priority"
default 150

config TESTING_OSTEST_STACKSIZE
int "OS test stack size"
default 8192
Expand Down
2 changes: 1 addition & 1 deletion testing/ostest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include $(APPDIR)/Make.defs
# ostest built-in application info

PROGNAME = ostest
PRIORITY = SCHED_PRIORITY_DEFAULT
PRIORITY = $(CONFIG_TESTING_OSTEST_PRIORITY)
STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
MODULE = $(CONFIG_TESTING_OSTEST)

Expand Down
17 changes: 15 additions & 2 deletions testing/ostest/cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ static FAR void *asynch_waiter(FAR void *parameter)
ASSERT(false);
}

/* Then wait a bit. We should be canceled aynchronously while waiting, but
* the cancellation should pend because we are non-cancellable.
/* Then wait a bit. We should be canceled asynchronously while waiting,
* but the cancellation should pend because we are non-cancelable.
*/

usleep(250 * 1000);
Expand Down Expand Up @@ -321,6 +321,7 @@ static FAR void *asynch_waiter(FAR void *parameter)
static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter,
int cancelable)
{
struct sched_param param;
pthread_attr_t attr;
int status;

Expand Down Expand Up @@ -356,6 +357,18 @@ static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter,
ASSERT(false);
}

param.sched_priority = PRIORITY;
printf("start_thread: Parent thread priority=%d\n",
param.sched_priority);

status = pthread_attr_setschedparam(&attr, &param);
if (status != 0)
{
printf("start_thread: ERROR pthread_attr_setschedparam failed,"
"status=%d\n", status);
ASSERT(false);
}

status = pthread_attr_setstacksize(&attr, STACKSIZE);
if (status != 0)
{
Expand Down
15 changes: 7 additions & 8 deletions testing/ostest/cond.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ static void *thread_signaler(void *parameter)

#if defined(CONFIG_SMP) && (CONFIG_SMP_NCPUS > 1)
/* Workaround for SMP:
* In multi-core environment, thread_signaler would be excecuted prior
* In multi-core environment, thread_signaler would be executed prior
* to the thread_waiter, even though priority of thread_signaler is
* lower than the thread_waiter. In this case, thread_signaler will
* aquire mutex before the thread_waiter aquires it and will show
* acquire mutex before the thread_waiter acquire it and will show
* the error message such as "thread_signaler: ERROR waiter state...".
* To avoid this situaltion, we add the following usleep()
*/
Expand Down Expand Up @@ -253,7 +253,6 @@ void cond_test(void)
struct sched_param sparam;
int prio_min;
int prio_max;
int prio_mid;
int status;

sem_init(&sem_thread_started, 0, 0);
Expand Down Expand Up @@ -289,11 +288,9 @@ void cond_test(void)
printf("cond_test: pthread_attr_init failed, status=%d\n", status);
}

prio_min = sched_get_priority_min(SCHED_FIFO);
prio_max = sched_get_priority_max(SCHED_FIFO);
prio_mid = (prio_min + prio_max) / 2;

sparam.sched_priority = prio_mid;
sparam.sched_priority = PRIORITY + 10 <= prio_max ?
PRIORITY + 10 : prio_max;
status = pthread_attr_setschedparam(&attr, &sparam);
if (status != OK)
{
Expand Down Expand Up @@ -321,7 +318,9 @@ void cond_test(void)
printf("cond_test: pthread_attr_init failed, status=%d\n", status);
}

sparam.sched_priority = (prio_min + prio_mid) / 2;
prio_min = sched_get_priority_min(SCHED_FIFO);
sparam.sched_priority = PRIORITY - 10 >= prio_min ?
PRIORITY - 10 : prio_min;
status = pthread_attr_setschedparam(&attr, &sparam);
if (status != OK)
{
Expand Down
2 changes: 1 addition & 1 deletion testing/ostest/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#endif

#ifndef CONFIG_TESTING_OSTEST_FPUPRIORITY
# define CONFIG_TESTING_OSTEST_FPUPRIORITY SCHED_PRIORITY_DEFAULT
# define CONFIG_TESTING_OSTEST_FPUPRIORITY PRIORITY
#endif

#ifndef CONFIG_TESTING_OSTEST_FPUSTACKSIZE
Expand Down
11 changes: 5 additions & 6 deletions testing/ostest/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ void mqueue_test(void)
FAR void *expected;
int prio_min;
int prio_max;
int prio_mid;
int status;

/* Reset globals for the beginning of the test */
Expand Down Expand Up @@ -301,11 +300,9 @@ void mqueue_test(void)
ASSERT(false);
}

prio_min = sched_get_priority_min(SCHED_FIFO);
prio_max = sched_get_priority_max(SCHED_FIFO);
prio_mid = (prio_min + prio_max) / 2;

sparam.sched_priority = prio_mid;
sparam.sched_priority = PRIORITY + 10 <= prio_max ?
PRIORITY + 10 : prio_max;
status = pthread_attr_setschedparam(&attr, &sparam);
if (status != OK)
{
Expand Down Expand Up @@ -348,7 +345,9 @@ void mqueue_test(void)
ASSERT(false);
}

sparam.sched_priority = (prio_min + prio_mid) / 2;
prio_min = sched_get_priority_min(SCHED_FIFO);
sparam.sched_priority = PRIORITY - 10 >= prio_min ?
PRIORITY - 10 : prio_min;
status = pthread_attr_setschedparam(&attr, &sparam);
if (status != OK)
{
Expand Down
10 changes: 3 additions & 7 deletions testing/ostest/nsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ void nsem_test(void)
FAR sem_t *sem1;
FAR sem_t *sem2;
struct sched_param sparam;
int prio_min;
int prio_max;
int prio_mid;
pthread_attr_t attr;
int prio_max;
int status;

/* Open semaphore 2. We will create that one */
Expand All @@ -137,11 +135,9 @@ void nsem_test(void)
printf("nsem_test: pthread_attr_init failed, status=%d\n", status);
}

prio_min = sched_get_priority_min(SCHED_FIFO);
prio_max = sched_get_priority_max(SCHED_FIFO);
prio_mid = (prio_min + prio_max) / 2;

sparam.sched_priority = (prio_mid + prio_max) / 2;
sparam.sched_priority = PRIORITY + 10 <= prio_max ?
PRIORITY + 10 : prio_max;
status = pthread_attr_setschedparam(&attr, &sparam);
if (status != OK)
{
Expand Down
4 changes: 2 additions & 2 deletions testing/ostest/nxevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void nxevent_test(void)

/* Lower priority */

sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY;
sparam.sched_priority = PRIORITY;
pthread_attr_setschedparam(&attr, &sparam);

/* Create thread */
Expand All @@ -304,7 +304,7 @@ void nxevent_test(void)

/* Lower priority */

sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY;
sparam.sched_priority = PRIORITY;
pthread_attr_setschedparam(&attr, &sparam);

/* Create thread */
Expand Down
20 changes: 15 additions & 5 deletions testing/ostest/ostest.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,24 @@
* Pre-processor Definitions
****************************************************************************/

/* The task_create task size can be specified in the defconfig file */
#define OSTEST_NARGS 4
#define RESTART_NARGS 3

#ifdef CONFIG_TESTING_OSTEST_STACKSIZE
# define STACKSIZE CONFIG_TESTING_OSTEST_STACKSIZE
#else
# define STACKSIZE 8192
#define HALF_SECOND_USEC 500000L
#define RETURN_STATUS 14

#ifdef CONFIG_SCHED_WAITPID
# define NCHILDREN 3
#endif

/* The task_create priority can be specified in the defconfig file */

#define PRIORITY CONFIG_TESTING_OSTEST_PRIORITY

/* The task_create task size can be specified in the defconfig file */

#define STACKSIZE CONFIG_TESTING_OSTEST_STACKSIZE

/* The number of times to execute the test can be specified in the defconfig
* file.
*/
Expand Down
20 changes: 6 additions & 14 deletions testing/ostest/ostest_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@

#include "ostest.h"

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#define PRIORITY 100
#define NARGS 4
#define HALF_SECOND_USEC 500000L

/****************************************************************************
* Private Data
****************************************************************************/
Expand All @@ -72,9 +64,9 @@ static const char write_data2[] = "stdio_test: write fd=2\n";
* pointer types.
*/

static const char *g_argv[NARGS + 1];
static const char *g_argv[OSTEST_NARGS + 1];
#else
static const char *g_argv[NARGS + 1] =
static const char *g_argv[OSTEST_NARGS + 1] =
{
arg1, arg2, arg3, arg4, NULL
};
Expand Down Expand Up @@ -229,19 +221,19 @@ static int user_main(int argc, char *argv[])

/* Verify passed arguments */

if (argc != NARGS + 1)
if (argc != OSTEST_NARGS + 1)
{
printf("user_main: ERROR expected argc=%d got argc=%d\n",
NARGS + 1, argc);
OSTEST_NARGS + 1, argc);
ASSERT(false);
}

for (i = 0; i <= NARGS; i++)
for (i = 0; i <= OSTEST_NARGS; i++)
{
printf("user_main: argv[%d]=\"%s\"\n", i, argv[i]);
}

for (i = 1; i <= NARGS; i++)
for (i = 1; i <= OSTEST_NARGS; i++)
{
if (strcmp(argv[i], g_argv[i - 1]) != 0)
{
Expand Down
8 changes: 4 additions & 4 deletions testing/ostest/prioinherit.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static FAR void *lowpri_thread(FAR void *parameter)
while (g_middlestate == NOTSTARTED &&
nhighpri_waiting() < NHIGHPRI_THREADS)
{
printf("lowpri_thread-%d: Waiting for the midle pri task to run\n",
printf("lowpri_thread-%d: Waiting for the mid pri task to run\n",
threadno);
printf(" g_middlestate: %d\n", (int)g_middlestate);
for (i = 0; i < NHIGHPRI_THREADS; i++)
Expand Down Expand Up @@ -403,7 +403,7 @@ static FAR void *lowpri_thread(FAR void *parameter)
*/

printf("lowpri_thread-%d: %s the middle priority task has already"
" exitted!\n",
" exited!\n",
threadno, count >= 0 ? "SUCCESS" : "ERROR");
ASSERT(count >= 0);
printf(" g_middlestate: %d sem count=%d\n",
Expand Down Expand Up @@ -516,7 +516,7 @@ void priority_inheritance(void)
{
printf("priority_inheritance: ERROR sched_getparam failed\n");
ASSERT(false);
sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY;
sparam.sched_priority = PRIORITY;
}

my_pri = sparam.sched_priority;
Expand Down Expand Up @@ -657,7 +657,7 @@ void priority_inheritance(void)
if (status != 0)
{
printf("priority_inheritance: "
"ERRROR pthread_create failed, status=%d\n", status);
"ERROR pthread_create failed, status=%d\n", status);
ASSERT(false);
}
}
Expand Down
6 changes: 0 additions & 6 deletions testing/ostest/pthread_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@

#ifdef CONFIG_SCHED_WAITPID

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#define PRIORITY 100

/****************************************************************************
* Private Functions
****************************************************************************/
Expand Down
15 changes: 4 additions & 11 deletions testing/ostest/restart.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,11 @@

#ifndef CONFIG_BUILD_KERNEL

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#define PRIORITY 100
#define NARGS 3

/****************************************************************************
* Private Data
****************************************************************************/

static char * const g_argv[NARGS + 1] =
static char * const g_argv[RESTART_NARGS + 1] =
{
"This is argument 1",
"Argument 2 here",
Expand Down Expand Up @@ -83,14 +76,14 @@ static int restart_main(int argc, char *argv[])

/* Verify passed arguments */

if (argc != NARGS + 1)
if (argc != RESTART_NARGS + 1)
{
printf("restart_main: ERROR: Expected argc=%d got argc=%d\n",
NARGS + 1, argc);
RESTART_NARGS + 1, argc);
ASSERT(false);
}

for (i = 0; i <= NARGS; i++)
for (i = 0; i <= RESTART_NARGS; i++)
{
printf("restart_main: argv[%d]=\"%s\"\n", i, argv[i]);
if (i > 0 && strcmp(argv[i], g_argv[i - 1]) != 0)
Expand Down
2 changes: 1 addition & 1 deletion testing/ostest/schedlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void sched_lock_test(void)
{
printf("sched_lock: ERROR sched_getparam failed\n");
ASSERT(false);
sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY;
sparam.sched_priority = PRIORITY;
}

highprio = sparam.sched_priority - 2;
Expand Down
Loading
Loading