From e8339c2aba22b00979d0e30ef128cfc62f701734 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 1 Jun 2008 17:50:07 +0000 Subject: [PATCH] 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 --- ChangeLog | 1 + Documentation/NuttX.html | 1 + arch/sim/src/Makefile | 1 + configs/ez80f910200kitg/ostest/defconfig | 3 +- configs/sim/ostest/defconfig | 5 + configs/z8encore000zco/ostest/defconfig | 3 +- configs/z8f64200100kit/ostest/defconfig | 3 +- examples/README.txt | 6 +- examples/ostest/barrier.c | 3 +- examples/ostest/main.c | 141 +++++++++++++---------- 10 files changed, 100 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3742881d0..33668b6ed0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -366,3 +366,4 @@ verified). * Host simulator no longer uses Linux system calls directly; Now works with Cygwin. * Fix an error that occurs when a POSIX timer is deleted by the timer signal handler. + * Add logic to allow the examples/ostest to be run repetitively as an endurance test. diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index c6b94fa595..6d8a69ba15 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -1016,6 +1016,7 @@ nuttx-0.3.11 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> verified). * Host simulator no longer uses Linux system calls directly; Now works with Cygwin. * Fix an error that occurs when a POSIX timer is deleted by the timer signal handler. + * Add logic to allow the examples/ostest to be run repetitively as an endurance test. pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index f7f323754e..040a9841d7 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -114,6 +114,7 @@ nuttx$(EXEEXT): nuttx.rel $(HOSTOBJS) @$(NM) $(TOPDIR)/$@ | \ grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ sort > $(TOPDIR)/System.map + @rm -f nuttx.rel .depend: Makefile $(SRCS) @$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/configs/ez80f910200kitg/ostest/defconfig b/configs/ez80f910200kitg/ostest/defconfig index 635ddf5f2f..ea80322721 100644 --- a/configs/ez80f910200kitg/ostest/defconfig +++ b/configs/ez80f910200kitg/ostest/defconfig @@ -311,7 +311,8 @@ CONFIG_NET_RESOLV_ENTRIES=4 # # Settings for examples/ostest -CONFIG_OSTEST_STACKSIZE=256 +CONFIG_EXAMPLES_OSTEST_LOOPS=1 +CONFIG_EXAMPLES_OSTEST_STACKSIZE=256 # # Settings for examples/nsh diff --git a/configs/sim/ostest/defconfig b/configs/sim/ostest/defconfig index a7d93ec760..f5e7bc8f8d 100644 --- a/configs/sim/ostest/defconfig +++ b/configs/sim/ostest/defconfig @@ -281,6 +281,11 @@ CONFIG_EXAMPLE_NETTEST_DRIPADDR=(192<<24|168<<16|0<<8|1) CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0) CONFIG_EXAMPLE_NETTEST_CLIENTIP=(192<<24|168<<16|0<<8|106) +# +# Settings for examples/ostest +CONFIG_EXAMPLES_OSTEST_LOOPS=100 +CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192 + # # Settings for examples/nsh CONFIG_EXAMPLES_NSH_TELNET=n diff --git a/configs/z8encore000zco/ostest/defconfig b/configs/z8encore000zco/ostest/defconfig index 8a8083b30d..9c5e5cd053 100644 --- a/configs/z8encore000zco/ostest/defconfig +++ b/configs/z8encore000zco/ostest/defconfig @@ -312,7 +312,8 @@ CONFIG_NET_RESOLV_ENTRIES=4 # # Settings for examples/ostest -CONFIG_OSTEST_STACKSIZE=256 +CONFIG_EXAMPLES_OSTEST_LOOPS=1 +CONFIG_EXAMPLES_OSTEST_STACKSIZE=256 # # Settings for examples/nsh diff --git a/configs/z8f64200100kit/ostest/defconfig b/configs/z8f64200100kit/ostest/defconfig index c7ed5aa404..1c96071750 100644 --- a/configs/z8f64200100kit/ostest/defconfig +++ b/configs/z8f64200100kit/ostest/defconfig @@ -312,7 +312,8 @@ CONFIG_NET_RESOLV_ENTRIES=4 # # Settings for examples/ostest -CONFIG_OSTEST_STACKSIZE=256 +CONFIG_EXAMPLES_OSTEST_LOOPS=1 +CONFIG_EXAMPLES_OSTEST_STACKSIZE=256 # # Settings for examples/nsh diff --git a/examples/README.txt b/examples/README.txt index b31785a10a..47ec67f6f7 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -20,7 +20,11 @@ examples/ostest The behavior of the ostest can be modified with the following settings in the configs//defconfig file: - * CONFIG_OSTEST_STACKSIZE + * CONFIG_EXAMPLES_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_EXAMPLES_OSTEST_STACKSIZE Used to create the ostest task. Default is 8192. examples/nsh diff --git a/examples/ostest/barrier.c b/examples/ostest/barrier.c index 731eaa8174..2b6755c9d1 100644 --- a/examples/ostest/barrier.c +++ b/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/examples/ostest/main.c b/examples/ostest/main.c index c61e94cff0..0f34eea23e 100644 --- a/examples/ostest/main.c +++ b/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. */