Skip to content

Commit

Permalink
🔥 update testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
hungry-foolish committed May 4, 2024
1 parent 8a6134c commit 433d81d
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 24 deletions.
15 changes: 9 additions & 6 deletions Include/Kernel/rmp_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,11 @@ do \
while(0)
#endif

/* Coverage switch detection */
#ifndef RMP_COVERAGE_MARKER
/* Coverage marker enabling */
#ifdef RMP_COVERAGE_LINE_NUM
#define RMP_COVERAGE_WORD_NUM (RMP_ROUND_UP(RMP_COVERAGE_LINE_NUM,RMP_WORD_ORDER)>>RMP_WORD_ORDER)
#define RMP_COVERAGE_MARKER() (RMP_Coverage[__LINE__>>RMP_WORD_ORDER]|=RMP_POW2(__LINE__&RMP_WORD_MASK))
#else
#define RMP_COVERAGE_MARKER()
#endif
/*****************************************************************************/
Expand Down Expand Up @@ -339,9 +342,9 @@ struct RMP_Mem
/* If the header is not used in the public mode */
#ifndef __HDR_PUBLIC__
/*****************************************************************************/
#ifdef RMP_COVERAGE
#ifdef RMP_COVERAGE_LINE_NUM
/* For coverage use only */
static volatile rmp_ptr_t RMP_Coverage[RMP_COVERAGE_LINES];
static volatile rmp_ptr_t RMP_Coverage[RMP_COVERAGE_WORD_NUM];
#endif
/* The scheduler bitmap */
static volatile rmp_ptr_t RMP_Bitmap[RMP_PRIO_WORD_NUM];
Expand Down Expand Up @@ -691,8 +694,8 @@ EXTERN void RMP_Init_Hook(void);
EXTERN void RMP_Init_Idle(void);

/* Coverage test */
#ifdef RMP_COVERAGE
__EXTERN__ void RMP_Print_Coverage(void);
#ifdef RMP_COVERAGE_LINE_NUM
__EXTERN__ void RMP_Coverage_Print(void);
#endif
/*****************************************************************************/
/* Undefine "__EXTERN__" to avoid redefinition */
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>1</Optim>
<Optim>4</Optim>
<oTime>1</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>
Expand All @@ -333,7 +333,7 @@
<v6LangP>5</v6LangP>
<vShortEn>0</vShortEn>
<vShortWch>0</vShortWch>
<v6Lto>0</v6Lto>
<v6Lto>1</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
Expand Down Expand Up @@ -475,9 +475,9 @@
<GroupName>Test</GroupName>
<Files>
<File>
<FileName>rmp_benchmark.c</FileName>
<FileName>rmp_coverage.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\Source\Test\rmp_benchmark.c</FilePath>
<FilePath>..\..\Source\Test\rmp_coverage.c</FilePath>
</File>
</Files>
</Group>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description : The configuration file for ARMv7-M HAL.
******************************************************************************/

/* Config Includes ***********************************************************/
#include "Platform/A7M/Chip/STM32F103RB/rmp_platform_stm32f103rb.h"
#include "rmp_platform_stm32f103rb.h"
/* End Config Includes *******************************************************/

/* End Of File ***************************************************************/
Expand Down
120 changes: 120 additions & 0 deletions Project/RVMDK-STM32F103RBT6-COV/rmp_platform_stm32f103rb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/******************************************************************************
Filename : rmp_platform_stm32f103rb.h
Author : pry
Date : 24/06/2017
Licence : The Unlicense; see LICENSE for details.
Description: The configuration file for STM32F103RB.
******************************************************************************/

/* Define ********************************************************************/
/* The HAL library */
#include "stm32f1xx_hal.h"
#include "stm32f1xx_hal_conf.h"
#include "core_cm3.h"

/* Debugging */
#define RMP_ASSERT_CORRECT (0U)
/* Coverage */
#define RMP_COVERAGE_LINE_NUM (6144U)

/* The maximum number of preemption priority levels in the system.
* This parameter must be divisible by the word length - 32 is usually sufficient */
#define RMP_PREEMPT_PRIO_NUM (64U)
/* The maximum number of slices allowed */
#define RMP_SLICE_MAX (100000U)
/* The maximum number of semaphore counts allowed */
#define RMP_SEM_CNT_MAX (1000U)
/* Are we using custom hooks? */
#define RMP_HOOK_EXTRA (0U)
/* The stzck size of the init thread */
#define RMP_INIT_STACK_SIZE (256U)
/* The mask/unmask interrupt operations - can be adjusted to fit your own levels */
#define RMP_INT_MASK() RMP_Int_Mask(0xFFU)
#define RMP_INT_UNMASK() RMP_Int_Mask(0x00U)

/* What is the NVIC priority grouping? */
#define RMP_A7M_NVIC_GROUPING RMP_A7M_NVIC_GROUPING_P2S6
/* What is the Systick value? */
#define RMP_A7M_SYSTICK_VAL (7200U)

/* Other low-level initialization stuff - clock and serial
* STM32F10x APB1<36MHz, APB2<72MHz.
* This is the default initialization sequence. If you wish to supply
* your own, just redirect this macro to a custom function, or do your
* initialization stuff in the initialization hook (RMP_Start_Hook). */
#define RMP_A7M_LOWLVL_INIT() \
do \
{ \
RCC_OscInitTypeDef Osc_Init; \
RCC_ClkInitTypeDef Clk_Init; \
UART_HandleTypeDef USART1_Handle; \
GPIO_InitTypeDef GPIOA_Init; \
HAL_Init(); \
RMP_Clear(&Osc_Init, sizeof(RCC_OscInitTypeDef)); \
RMP_Clear(&Clk_Init, sizeof(RCC_ClkInitTypeDef)); \
RMP_Clear(&USART1_Handle, sizeof(UART_HandleTypeDef)); \
RMP_Clear(&GPIOA_Init, sizeof(GPIO_InitTypeDef)); \
\
/* Enable HSE Oscillator and activate PLL with HSE as source */ \
Osc_Init.OscillatorType=RCC_OSCILLATORTYPE_HSE; \
Osc_Init.HSEState=RCC_HSE_ON; \
Osc_Init.HSEPredivValue=RCC_HSE_PREDIV_DIV1; \
Osc_Init.PLL.PLLState=RCC_PLL_ON; \
Osc_Init.PLL.PLLSource=RCC_PLLSOURCE_HSE; \
Osc_Init.PLL.PLLMUL=RCC_PLL_MUL9; \
RMP_ASSERT(HAL_RCC_OscConfig(&Osc_Init)==HAL_OK); \
\
/* Secect PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ \
Clk_Init.ClockType=(RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2); \
Clk_Init.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK; \
Clk_Init.AHBCLKDivider=RCC_SYSCLK_DIV1; \
Clk_Init.APB2CLKDivider=RCC_HCLK_DIV1; \
Clk_Init.APB1CLKDivider=RCC_HCLK_DIV2; \
RMP_ASSERT(HAL_RCC_ClockConfig(&Clk_Init, FLASH_LATENCY_2)==HAL_OK); \
__HAL_FLASH_PREFETCH_BUFFER_ENABLE(); \
\
__HAL_RCC_GPIOA_CLK_ENABLE(); \
__HAL_RCC_USART1_CLK_ENABLE(); \
GPIOA_Init.Mode=GPIO_MODE_AF_PP; \
GPIOA_Init.Pin=GPIO_PIN_9; \
GPIOA_Init.Speed=GPIO_SPEED_FREQ_HIGH; \
HAL_GPIO_Init(GPIOA, &GPIOA_Init); \
\
USART1_Handle.Instance=USART1; \
USART1_Handle.Init.BaudRate=115200; \
USART1_Handle.Init.WordLength=UART_WORDLENGTH_8B; \
USART1_Handle.Init.StopBits=UART_STOPBITS_1; \
USART1_Handle.Init.Parity=UART_PARITY_NONE; \
USART1_Handle.Init.HwFlowCtl=UART_HWCONTROL_NONE; \
USART1_Handle.Init.Mode=UART_MODE_TX; \
HAL_UART_Init(&USART1_Handle); \
RMP_A7M_PUTCHAR('\r'); \
RMP_A7M_PUTCHAR('\n'); \
/* Enable all fault handlers */ \
SCB->SHCSR|=RMP_A7M_SHCSR_USGFAULTENA|RMP_A7M_SHCSR_BUSFAULTENA|RMP_A7M_SHCSR_MEMFAULTENA; \
\
/* Set the priority of timer, svc and faults to the lowest */ \
NVIC_SetPriorityGrouping(RMP_A7M_NVIC_GROUPING); \
NVIC_SetPriority(SVCall_IRQn,0xFFU); \
NVIC_SetPriority(PendSV_IRQn,0xFFU); \
NVIC_SetPriority(SysTick_IRQn,0xFFU); \
NVIC_SetPriority(BusFault_IRQn,0xFFU); \
NVIC_SetPriority(UsageFault_IRQn,0xFFU); \
NVIC_SetPriority(DebugMonitor_IRQn,0xFFU); \
SysTick_Config(RMP_A7M_SYSTICK_VAL); \
} \
while(0)

/* This is for debugging output */
#define RMP_A7M_PUTCHAR(CHAR) \
do \
{ \
USART1->DR=CHAR; \
while((USART1->SR&0x40U)==0U); \
} \
while(0)
/* End Define ****************************************************************/

/* End Of File ***************************************************************/

/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/
File renamed without changes.
37 changes: 25 additions & 12 deletions Source/Kernel/rmp_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,28 +452,41 @@ rmp_ptr_t RMP_RBT_Generic(rmp_ptr_t Value)
}
/* End Function:RMP_RBT_Generic **********************************************/

/* Function:RMP_Print_Coverage ************************************************
/* Function:RMP_Coverage_Print ************************************************
Description : The coverage data printer. Should always be disabled for all cases
except where a kernel coverage test is needed. This should never
be called ny any user application; for EDI coverage testing only.
be called any any user application; for coverage testing only.
Input : None.
Output : None.
Return : None.
******************************************************************************/
#ifdef RMP_COVERAGE
void RMP_Print_Coverage(void)
#ifdef RMP_COVERAGE_LINE_NUM
void RMP_Coverage_Print(void)
{
rmp_ptr_t Count;
rmp_ptr_t Next;

for(Count=1U;Count<RMP_COVERAGE_LINES;Count++)
Next=0U;
for(Count=0U;Count<RMP_COVERAGE_LINE_NUM;Count++)
{
if(RMP_Coverage[Count]!=0U)
if((RMP_Coverage[Count>>RMP_WORD_ORDER]&RMP_POW2(Count&RMP_WORD_MASK))!=0U)
{
RMP_COVERAGE_MARKER();
RMP_DBG_I(Count);
RMP_DBG_S(":");
RMP_DBG_I(RMP_Coverage[Count]);
RMP_DBG_S("\r\n");
RMP_DBG_S(",");
/* We put 12 markers on a single line */
Next++;
if(Next>11U)
{
RMP_COVERAGE_MARKER();
Next=0U;
RMP_DBG_S("\r\n");
}
else
{
RMP_COVERAGE_MARKER();
/* No action needed */
}
}
else
{
Expand All @@ -483,7 +496,7 @@ void RMP_Print_Coverage(void)
}
}
#endif
/* End Function:RMP_Print_Coverage *******************************************/
/* End Function:RMP_Coverage_Print *******************************************/

/* Function:RMP_Clear *********************************************************
Description : Memset a memory area to zero.
Expand Down Expand Up @@ -3110,9 +3123,9 @@ int main(void)
{
rmp_ptr_t Count;

#ifdef RMP_COVERAGE
#ifdef RMP_COVERAGE_LINE_NUM
/* Initialize coverage markers if coverage enabled */
for(Count=0U;Count<RMP_COVERAGE_LINES;Count++)
for(Count=0U;Count<RMP_COVERAGE_WORD_NUM;Count++)
{
RMP_Coverage[Count]=0U;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Test/rmp_coverage.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
Filename : rmp_test.c
Filename : rmp_coverage.c
Author : pry
Date : 22/07/2017
Licence : The Unlicense; see LICENSE for details.
Expand Down

0 comments on commit 433d81d

Please sign in to comment.