From 234d88f6d04db0f10aaa8dffaaf8f5d7e015711d Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 10 Apr 2015 14:41:35 +0000 Subject: [PATCH] Improved testing procedures for RT. Improved simulator port for RT. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7879 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/various/RT-Win32-Simulator/.cproject | 5 +- os/rt/ports/SIMIA32/chcore.c | 19 ++++++ os/rt/ports/SIMIA32/chcore.h | 37 +++++++---- os/rt/src/chstats.c | 4 +- test/rt/testbuild/Makefile | 2 +- test/rt/testbuild/chconf.h | 2 +- test/rt/testbuild/go.sh | 75 ++++++++++++---------- test/rt/testbuild/readme.txt | 2 +- 8 files changed, 91 insertions(+), 55 deletions(-) diff --git a/demos/various/RT-Win32-Simulator/.cproject b/demos/various/RT-Win32-Simulator/.cproject index 9c293802f..39a4a35b2 100644 --- a/demos/various/RT-Win32-Simulator/.cproject +++ b/demos/various/RT-Win32-Simulator/.cproject @@ -1,7 +1,5 @@ - - - + @@ -48,4 +46,5 @@ + diff --git a/os/rt/ports/SIMIA32/chcore.c b/os/rt/ports/SIMIA32/chcore.c index a2dbbbe71..92d0fed7f 100644 --- a/os/rt/ports/SIMIA32/chcore.c +++ b/os/rt/ports/SIMIA32/chcore.c @@ -25,6 +25,8 @@ * @{ */ +#include + #include "ch.h" /*===========================================================================*/ @@ -35,6 +37,9 @@ /* Module exported variables. */ /*===========================================================================*/ +bool port_isr_context_flag; +syssts_t port_irq_sts; + /*===========================================================================*/ /* Module local types. */ /*===========================================================================*/ @@ -98,4 +103,18 @@ void _port_thread_start(msg_t (*pf)(void *), void *p) { while(1); } + +/** + * @brief Returns the current value of the realtime counter. + * + * @return The realtime counter value. + */ +rtcnt_t port_rt_get_counter_value(void) { + LARGE_INTEGER n; + + QueryPerformanceCounter(&n); + + return (rtcnt_t)(n.QuadPart / 1000LL); +} + /** @} */ diff --git a/os/rt/ports/SIMIA32/chcore.h b/os/rt/ports/SIMIA32/chcore.h index b313cb9f9..0caa1ecfd 100644 --- a/os/rt/ports/SIMIA32/chcore.h +++ b/os/rt/ports/SIMIA32/chcore.h @@ -60,7 +60,7 @@ /** * @brief This port supports a realtime counter. */ -#define PORT_SUPPORTS_RT FALSE +#define PORT_SUPPORTS_RT TRUE /*===========================================================================*/ /* Module pre-compile time settings. */ @@ -204,14 +204,19 @@ struct context { * @details This macro must be inserted at the start of all IRQ handlers * enabled to invoke system APIs. */ -#define PORT_IRQ_PROLOGUE() +#define PORT_IRQ_PROLOGUE() { \ + port_isr_context_flag = true; \ +} /** * @brief IRQ epilogue code. * @details This macro must be inserted at the end of all IRQ handlers * enabled to invoke system APIs. */ -#define PORT_IRQ_EPILOGUE() +#define PORT_IRQ_EPILOGUE() { \ + port_isr_context_flag = false; \ +} + /** * @brief IRQ handler function declaration. @@ -231,6 +236,9 @@ struct context { /* External declarations. */ /*===========================================================================*/ +extern bool port_isr_context_flag; +extern syssts_t port_irq_sts; + #ifdef __cplusplus extern "C" { #endif @@ -239,6 +247,7 @@ extern "C" { __attribute__((cdecl, noreturn)) void _port_thread_start(msg_t (*pf)(void *p), void *p); /*lint -restore*/ + rtcnt_t port_rt_get_counter_value(void); void _sim_check_for_interrupts(void); #ifdef __cplusplus } @@ -253,6 +262,8 @@ extern "C" { */ static inline void port_init(void) { + port_irq_sts = (syssts_t)0; + port_isr_context_flag = false; } /** @@ -262,7 +273,7 @@ static inline void port_init(void) { */ static inline syssts_t port_get_irq_status(void) { - return (syssts_t)0; + return port_irq_sts; } /** @@ -276,7 +287,7 @@ static inline syssts_t port_get_irq_status(void) { */ static inline bool port_irq_enabled(syssts_t sts) { - return (sts & (syssts_t)1) == (syssts_t)0; + return sts == (syssts_t)0; } /** @@ -288,7 +299,7 @@ static inline bool port_irq_enabled(syssts_t sts) { */ static inline bool port_is_isr_context(void) { - return false; + return port_isr_context_flag; } /** @@ -297,7 +308,7 @@ static inline bool port_is_isr_context(void) { */ static inline void port_lock(void) { - __asm volatile ("nop"); + port_irq_sts = (syssts_t)1; } /** @@ -306,7 +317,7 @@ static inline void port_lock(void) { */ static inline void port_unlock(void) { - __asm volatile ("nop"); + port_irq_sts = (syssts_t)0; } /** @@ -316,7 +327,7 @@ static inline void port_unlock(void) { */ static inline void port_lock_from_isr(void) { - __asm volatile ("nop"); + port_irq_sts = (syssts_t)1; } /** @@ -326,7 +337,7 @@ static inline void port_lock_from_isr(void) { */ static inline void port_unlock_from_isr(void) { - __asm volatile ("nop"); + port_irq_sts = (syssts_t)0; } /** @@ -334,7 +345,7 @@ static inline void port_unlock_from_isr(void) { */ static inline void port_disable(void) { - __asm volatile ("nop"); + port_irq_sts = (syssts_t)1; } /** @@ -342,7 +353,7 @@ static inline void port_disable(void) { */ static inline void port_suspend(void) { - __asm volatile ("nop"); + port_irq_sts = (syssts_t)1; } /** @@ -350,7 +361,7 @@ static inline void port_suspend(void) { */ static inline void port_enable(void) { - __asm volatile ("nop"); + port_irq_sts = (syssts_t)0; } /** diff --git a/os/rt/src/chstats.c b/os/rt/src/chstats.c index fbd28f44a..40169642e 100644 --- a/os/rt/src/chstats.c +++ b/os/rt/src/chstats.c @@ -61,8 +61,8 @@ */ void _stats_init(void) { - ch.kernel_stats.n_irq = 0; - ch.kernel_stats.n_ctxswc = 0; + ch.kernel_stats.n_irq = (ucnt_t)0; + ch.kernel_stats.n_ctxswc = (ucnt_t)0; chTMObjectInit(&ch.kernel_stats.m_crit_thd); chTMObjectInit(&ch.kernel_stats.m_crit_isr); } diff --git a/test/rt/testbuild/Makefile b/test/rt/testbuild/Makefile index 7d10e9667..143ccbe01 100644 --- a/test/rt/testbuild/Makefile +++ b/test/rt/testbuild/Makefile @@ -136,7 +136,7 @@ clean: -rm -fR .dep misra: - @lint-nt -v -w3 $(DEFS) pclint/co-gcc.lnt pclint/au-misra3.lnt pclint/waivers.lnt $(INCDIR) $(KERNSRC) &> misra.txt + @lint-nt -v -w3 $(DEFS) pclint/co-gcc.lnt pclint/au-misra3.lnt pclint/waivers.lnt $(INCDIR) $(KERNSRC) # # Include the dependency files, should be the last of the makefile diff --git a/test/rt/testbuild/chconf.h b/test/rt/testbuild/chconf.h index b6b58e6bf..5b21d70b8 100644 --- a/test/rt/testbuild/chconf.h +++ b/test/rt/testbuild/chconf.h @@ -153,7 +153,7 @@ * @note The default is @p TRUE. */ #if !defined(CH_CFG_USE_TM) || defined(__DOXIGEN__) -#define CH_CFG_USE_TM FALSE +#define CH_CFG_USE_TM TRUE #endif /** diff --git a/test/rt/testbuild/go.sh b/test/rt/testbuild/go.sh index b09fcd4c3..ac73b7883 100644 --- a/test/rt/testbuild/go.sh +++ b/test/rt/testbuild/go.sh @@ -18,6 +18,7 @@ function compile() { clean exit fi + mv -f buildlog.txt ./reports/${1}_build.txt echo "OK" } @@ -29,28 +30,29 @@ function execute_test() { clean exit fi + mv -f testlog.txt ./reports/${1}_test.txt echo "OK" } function coverage() { echo -n " * Coverage..." - mkdir coverage 2> /dev/null - mkdir coverage/$1 2> /dev/null - echo "Configuration $2" > coverage/$1.txt - echo "----------------------------------------------------------------" >> coverage/$1.txt - if ! make gcov >> coverage/$1.txt 2> /dev/null + mkdir reports/${1}_gcov 2> /dev/null + echo "Configuration $2" > gcovlog.txt + echo "----------------------------------------------------------------" >> reports/gcovlog.txt + if ! make gcov >> gcovlog.txt 2> /dev/null then echo "failed" clean exit fi - mv -f *.gcov ./coverage/$1 + mv -f gcovlog.txt ./reports/${1}_gcov.txt + mv -f *.gcov ./reports/${1}_gcov echo "OK" } function misra() { echo -n " * Analysing..." - if ! make misra > misralog.txt + if ! make misra > misralog.txt 2> misraerrlog.txt then echo "failed" clean @@ -69,8 +71,8 @@ function test() { XDEFS=$2 fi echo $msg - compile - execute_test + compile $1 + execute_test $1 coverage $1 "$msg" misra clean @@ -83,34 +85,39 @@ function partial() { clean } +mkdir reports 2> /dev/null + test cfg1 "" test cfg2 "-DCH_CFG_OPTIMIZE_SPEED=FALSE" test cfg3 "-DCH_CFG_TIME_QUANTUM=0" test cfg4 "-DCH_CFG_USE_REGISTRY=FALSE" -test cfg5 "-DCH_CFG_USE_SEMAPHORES=FALSE -DCH_CFG_USE_MAILBOXES=FALSE" -test cfg6 "-DCH_CFG_USE_SEMAPHORES_PRIORITY=TRUE" -test cfg7 "-DCH_CFG_USE_MUTEXES=FALSE -DCH_CFG_USE_CONDVARS=FALSE" -test cfg8 "-DCH_CFG_USE_MUTEXES_RECURSIVE=TRUE" -test cfg9 "-DCH_CFG_USE_CONDVARS=FALSE" -test cfg10 "-DCH_CFG_USE_CONDVARS_TIMEOUT=FALSE" -test cfg11 "-DCH_CFG_USE_EVENTS=FALSE" -test cfg12 "-DCH_CFG_USE_EVENTS_TIMEOUT=FALSE" -test cfg13 "-DCH_CFG_USE_MESSAGES=FALSE" -test cfg14 "-DCH_CFG_USE_MESSAGES_PRIORITY=TRUE" -test cfg15 "-DCH_CFG_USE_MAILBOXES=FALSE" -test cfg16 "-DCH_CFG_USE_MEMCORE=FALSE -DCH_CFG_USE_MEMPOOLS=FALSE -DCH_CFG_USE_HEAP=FALSE -DCH_CFG_USE_DYNAMIC=FALSE" -test cfg17 "-DCH_CFG_USE_MEMPOOLS=FALSE -DCH_CFG_USE_HEAP=FALSE -DCH_CFG_USE_DYNAMIC=FALSE" -test cfg18 "-DCH_CFG_USE_MEMPOOLS=FALSE" -test cfg19 "-DCH_CFG_USE_HEAP=FALSE" -test cfg20 "-DCH_CFG_USE_DYNAMIC=FALSE" -#test cfg21 "-DCH_DBG_STATISTICS=TRUE" -test cfg22 "-DCH_DBG_SYSTEM_STATE_CHECK=TRUE" -test cfg23 "-DCH_DBG_ENABLE_CHECKS=TRUE" -test cfg24 "-DCH_DBG_ENABLE_ASSERTS=TRUE" -test cfg25 "-DCH_DBG_ENABLE_TRACE=TRUE" -#test cfg26 "-DCH_DBG_ENABLE_STACK_CHECK=TRUE" -test cfg27 "-DCH_DBG_FILL_THREADS=TRUE" -test cfg28 "-DCH_DBG_THREADS_PROFILING=FALSE" -test cfg29 "-DCH_DBG_SYSTEM_STATE_CHECK=TRUE -DCH_DBG_ENABLE_CHECKS=TRUE -DCH_DBG_ENABLE_ASSERTS=TRUE -DCH_DBG_ENABLE_TRACE=TRUE -DCH_DBG_FILL_THREADS=TRUE" +test cfg5 "-DCH_CFG_USE_TM=FALSE" +test cfg6 "-DCH_CFG_USE_SEMAPHORES=FALSE -DCH_CFG_USE_MAILBOXES=FALSE" +test cfg7 "-DCH_CFG_USE_SEMAPHORES_PRIORITY=TRUE" +test cfg8 "-DCH_CFG_USE_MUTEXES=FALSE -DCH_CFG_USE_CONDVARS=FALSE" +test cfg9 "-DCH_CFG_USE_MUTEXES_RECURSIVE=TRUE" +test cfg10 "-DCH_CFG_USE_CONDVARS=FALSE" +test cfg11 "-DCH_CFG_USE_CONDVARS_TIMEOUT=FALSE" +test cfg12 "-DCH_CFG_USE_EVENTS=FALSE" +test cfg13 "-DCH_CFG_USE_EVENTS_TIMEOUT=FALSE" +test cfg14 "-DCH_CFG_USE_MESSAGES=FALSE" +test cfg15 "-DCH_CFG_USE_MESSAGES_PRIORITY=TRUE" +test cfg16 "-DCH_CFG_USE_MAILBOXES=FALSE" +test cfg17 "-DCH_CFG_USE_MEMCORE=FALSE -DCH_CFG_USE_MEMPOOLS=FALSE -DCH_CFG_USE_HEAP=FALSE -DCH_CFG_USE_DYNAMIC=FALSE" +test cfg18 "-DCH_CFG_USE_MEMPOOLS=FALSE -DCH_CFG_USE_HEAP=FALSE -DCH_CFG_USE_DYNAMIC=FALSE" +test cfg19 "-DCH_CFG_USE_MEMPOOLS=FALSE" +test cfg20 "-DCH_CFG_USE_HEAP=FALSE" +test cfg21 "-DCH_CFG_USE_DYNAMIC=FALSE" +test cfg22 "-DCH_DBG_STATISTICS=TRUE" +test cfg23 "-DCH_DBG_SYSTEM_STATE_CHECK=TRUE" +test cfg24 "-DCH_DBG_ENABLE_CHECKS=TRUE" +test cfg25 "-DCH_DBG_ENABLE_ASSERTS=TRUE" +test cfg26 "-DCH_DBG_ENABLE_TRACE=TRUE" +#test cfg27 "-DCH_DBG_ENABLE_STACK_CHECK=TRUE" +test cfg28 "-DCH_DBG_FILL_THREADS=TRUE" +test cfg29 "-DCH_DBG_THREADS_PROFILING=FALSE" +test cfg30 "-DCH_DBG_SYSTEM_STATE_CHECK=TRUE -DCH_DBG_ENABLE_CHECKS=TRUE -DCH_DBG_ENABLE_ASSERTS=TRUE -DCH_DBG_ENABLE_TRACE=TRUE -DCH_DBG_FILL_THREADS=TRUE" rm *log.txt 2> /dev/null +echo +echo "Done" diff --git a/test/rt/testbuild/readme.txt b/test/rt/testbuild/readme.txt index aff565702..5e8b8543e 100644 --- a/test/rt/testbuild/readme.txt +++ b/test/rt/testbuild/readme.txt @@ -15,7 +15,7 @@ Coverage data is collected during the execution for use by step 3. Step 3: Coverage The utility gcov is ran on the generate data and the coverage information is -stored in reports under ./coverage. +stored in reports under ./reports. Step 4: Analysis