diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-06-01 17:50:07 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-06-01 17:50:07 +0000 |
commit | 6c8f17cbd53ae8c0bdc447da59619d6734ebae14 (patch) | |
tree | 1216f52f4180495d3699e39deee969be65685345 /nuttx/examples/ostest | |
parent | 60baf60892705bec8c3180025cd797c5d64a1e1e (diff) | |
download | px4-nuttx-6c8f17cbd53ae8c0bdc447da59619d6734ebae14.tar.gz px4-nuttx-6c8f17cbd53ae8c0bdc447da59619d6734ebae14.tar.bz2 px4-nuttx-6c8f17cbd53ae8c0bdc447da59619d6734ebae14.zip |
examples/ostest can be executed in a loop
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@763 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/ostest')
-rw-r--r-- | nuttx/examples/ostest/barrier.c | 3 | ||||
-rw-r--r-- | nuttx/examples/ostest/main.c | 141 |
2 files changed, 81 insertions, 63 deletions
diff --git a/nuttx/examples/ostest/barrier.c b/nuttx/examples/ostest/barrier.c index 731eaa817..2b6755c9d 100644 --- a/nuttx/examples/ostest/barrier.c +++ b/nuttx/examples/ostest/barrier.c @@ -53,7 +53,7 @@ static void *barrier_func(void *parameter) usleep(500*1000); #endif - /* Take the semaphore */ + /* Wait at the barrier until all threads are synchronized. */ printf("barrier_func: Thread %d calling pthread_barrier_wait()\n", id); status = pthread_barrier_wait(&barrier); @@ -99,6 +99,7 @@ void barrier_test(void) { printf("barrier_test: pthread_barrierattr_init failed, status=%d\n", status); } + /* Create the barrier */ status = pthread_barrierattr_init(&barrierattr); diff --git a/nuttx/examples/ostest/main.c b/nuttx/examples/ostest/main.c index c61e94cff..0f34eea23 100644 --- a/nuttx/examples/ostest/main.c +++ b/nuttx/examples/ostest/main.c @@ -58,12 +58,21 @@ #define NARGS 4 /* The task_create task size can be specified in the defconfig file */ -#ifdef CONFIG_OSTEST_STACKSIZE -# define STACKSIZE CONFIG_OSTEST_STACKSIZE + +#ifdef CONFIG_EXAMPLES_OSTEST_STACKSIZE +# define STACKSIZE CONFIG_EXAMPLES_OSTEST_STACKSIZE #else # define STACKSIZE 8192 #endif +/* The number of times to execute the test can be specified in the defconfig + * file. + */ + +#ifndef CONFIG_EXAMPLES_OSTEST_LOOPS +# define CONFIG_EXAMPLES_OSTEST_LOOPS 1 +#endif + /**************************************************************************** * Private Data ****************************************************************************/ @@ -280,121 +289,129 @@ static int user_main(int argc, char *argv[]) check_test_memory_usage(); #endif + /* Top of test loop */ + +#if CONFIG_EXAMPLES_OSTEST_LOOPS > 1 + for (i = 0; i < CONFIG_EXAMPLES_OSTEST_LOOPS; i++) +#elif CONFIG_EXAMPLES_OSTEST_LOOPS == 0 + for (;;) +#endif + { #if CONFIG_NFILE_DESCRIPTORS > 0 - /* Checkout /dev/null */ + /* Checkout /dev/null */ - printf("\nuser_main: /dev/null test\n"); - dev_null(); - check_test_memory_usage(); + printf("\nuser_main: /dev/null test\n"); + dev_null(); + check_test_memory_usage(); #endif #ifndef CONFIG_DISABLE_PTHREAD - /* Verify pthreads and pthread mutex */ + /* Verify pthreads and pthread mutex */ - printf("\nuser_main: mutex test\n"); - mutex_test(); - check_test_memory_usage(); + printf("\nuser_main: mutex test\n"); + mutex_test(); + check_test_memory_usage(); #endif #ifndef CONFIG_DISABLE_PTHREAD - /* Verify pthread cancellation */ + /* Verify pthread cancellation */ - printf("\nuser_main: cancel test\n"); - cancel_test(); - check_test_memory_usage(); + printf("\nuser_main: cancel test\n"); + cancel_test(); + check_test_memory_usage(); #endif #ifndef CONFIG_DISABLE_PTHREAD - /* Verify pthreads and semaphores */ + /* Verify pthreads and semaphores */ - printf("\nuser_main: semaphore test\n"); - sem_test(); - check_test_memory_usage(); + printf("\nuser_main: semaphore test\n"); + sem_test(); + check_test_memory_usage(); #endif #ifndef CONFIG_DISABLE_PTHREAD - /* Verify pthreads and condition variables */ + /* Verify pthreads and condition variables */ - printf("\nuser_main: condition variable test\n"); - cond_test(); - check_test_memory_usage(); + printf("\nuser_main: condition variable test\n"); + cond_test(); + check_test_memory_usage(); #endif #if !defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_DISABLE_CLOCK) - /* Verify pthreads and condition variable timed waits */ + /* Verify pthreads and condition variable timed waits */ - printf("\nuser_main: timed wait test\n"); - timedwait_test(); - check_test_memory_usage(); + printf("\nuser_main: timed wait test\n"); + timedwait_test(); + check_test_memory_usage(); #endif #if !defined(CONFIG_DISABLE_MQUEUE) && !defined(CONFIG_DISABLE_PTHREAD) - /* Verify pthreads and message queues */ + /* Verify pthreads and message queues */ - printf("\nuser_main: message queue test\n"); - mqueue_test(); - check_test_memory_usage(); + printf("\nuser_main: message queue test\n"); + mqueue_test(); + check_test_memory_usage(); #endif #if !defined(CONFIG_DISABLE_MQUEUE) && !defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_DISABLE_CLOCK) - /* Verify pthreads and message queues */ + /* Verify pthreads and message queues */ - printf("\nuser_main: timed message queue test\n"); - timedmqueue_test(); - check_test_memory_usage(); + printf("\nuser_main: timed message queue test\n"); + timedmqueue_test(); + check_test_memory_usage(); #endif #ifndef CONFIG_DISABLE_SIGNALS - /* Verify signal handlers */ + /* Verify signal handlers */ - printf("\nuser_main: signal handler test\n"); - sighand_test(); - check_test_memory_usage(); + printf("\nuser_main: signal handler test\n"); + sighand_test(); + check_test_memory_usage(); #endif #if !defined(CONFIG_DISABLE_POSIX_TIMERS) && !defined(CONFIG_DISABLE_SIGNALS) - /* Verify posix timers */ + /* Verify posix timers */ - printf("\nuser_main: POSIX timer test\n"); - timer_test(); - check_test_memory_usage(); + printf("\nuser_main: POSIX timer test\n"); + timer_test(); + check_test_memory_usage(); #endif #if !defined(CONFIG_DISABLE_PTHREAD) && CONFIG_RR_INTERVAL > 0 - /* Verify round robin scheduling */ + /* Verify round robin scheduling */ - printf("\nuser_main: round-robin scheduler test\n"); - rr_test(); - check_test_memory_usage(); + printf("\nuser_main: round-robin scheduler test\n"); + rr_test(); + check_test_memory_usage(); #endif #ifndef CONFIG_DISABLE_PTHREAD - /* Verify pthread barriers */ + /* Verify pthread barriers */ - printf("\nuser_main: barrier test\n"); - barrier_test(); - check_test_memory_usage(); + printf("\nuser_main: barrier test\n"); + barrier_test(); + check_test_memory_usage(); #endif - /* Compare memory usage at time user_start started until - * user_main exits. These should not be identical, but should - * be similar enough that we can detect any serious OS memory - * leaks. - */ + /* Compare memory usage at time user_start started until + * user_main exits. These should not be identical, but should + * be similar enough that we can detect any serious OS memory + * leaks. + */ #ifndef CONFIG_DISABLE_SIGNALS - usleep(500*1000); + usleep(500*1000); #ifdef CONFIG_CAN_PASS_STRUCTS - g_mmafter = mallinfo(); + g_mmafter = mallinfo(); #else - (void)mallinfo(&g_mmafter); + (void)mallinfo(&g_mmafter); #endif - printf("\nFinal memory usage:\n"); - show_memory_usage(&g_mmbefore, &g_mmafter); + printf("\nFinal memory usage:\n"); + show_memory_usage(&g_mmbefore, &g_mmafter); #endif - + } printf("user_main: Exitting\n"); return 0; } @@ -446,7 +463,7 @@ int user_start(int argc, char *argv[]) stdio_test(); #ifdef SDCC - /* I am not yet certain why SDCC does not like the initilizer. + /* I am not yet certain why SDCC does not like the following initilizers. * It involves some issues with 2- vs 3-byte pointer types. */ |