diff options
Diffstat (limited to 'FreeRTOS-Plus/Test/CMock/test/system/test_compilation')
6 files changed, 445 insertions, 0 deletions
diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/callingconv.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/callingconv.h new file mode 100644 index 000000000..beae0619f --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/callingconv.h @@ -0,0 +1,11 @@ +/* ========================================== + CMock Project - Automatic Mock Generation for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef __stdcall +#define __stdcall +#endif + +int __stdcall this_uses_calling_conventions(int b); diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/config.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/config.yml new file mode 100644 index 000000000..787e2e1f6 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/config.yml @@ -0,0 +1,10 @@ +--- +:cmock: + :plugins: [] + :includes: [] + :mock_path: ./system/generated/ + :mock_prefix: mock_ + :treat_inlines: :include + :treat_as_void: + - OSEK_TASK + - VOID_TYPE_CRAZINESS diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/const.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/const.h new file mode 100644 index 000000000..71426bc3b --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/const.h @@ -0,0 +1,37 @@ +/* ========================================== + CMock Project - Automatic Mock Generation for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#if defined(__GNUC__) && !defined(__ICC) +#if !defined(__clang__) +#pragma GCC diagnostic ignored "-Wpragmas" +#endif +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier" +#endif + +struct _DUMMY_T { unsigned int a; float b; }; + +void const_variants1( const char* a, int const, unsigned short const * c ); + +void const_variants2( + struct _DUMMY_T const * const param1, + const unsigned long int const * const param2, + const struct _DUMMY_T const * param3 ); + +const int * const_retval1(void); /* nicety version for pointer to constant int */ +int const * const_retval2(void); /* formal version for pointer to constant int */ +//int * const const_retval3(void); /* formal version for constant pointer to int */ +//int const * const const_retval4(void); /* formal version for constant pointer to constant int */ + +const int* const_retval5(void); /* sticky-left nicety version for pointer to constant int */ +int const* const_retval6(void); /* sticky-left formal version for pointer to constant int */ +//int* const const_retval7(void); /* sticky-left formal version for constant pointer to int */ +//int const* const const_retval8(void); /* sticky-left formal version for constant pointer to constant int */ + +const int *const_retval9(void); /* sticky-right nicety version for pointer to constant int */ +int const *const_retvalA(void); /* sticky-right formal version for pointer to constant int */ +//int *const const_retvalB(void); /* sticky-right formal version for constant pointer to int */ +//int const *const const_retvalC(void); /* sticky-right formal version for constant pointer to constant int */ diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/inline.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/inline.h new file mode 100644 index 000000000..06e33c184 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/inline.h @@ -0,0 +1,23 @@ + +static inline int dummy_func_0(void) { + return 5; +} + +inline static int dummy_func_1(int a) { + int a = dummy_func_0(); + int b = 10; + + return a + b; +} + +int inline static dummy_func_2(int a, char b, float c) { + c += 3.14; + b -= 32; + return a + (int)(b) + (int)c; +} + +void dummy_normal_func(int a); + +inline void dummy_func_3(void) { + //NOP +} diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/osek.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/osek.h new file mode 100644 index 000000000..f3abe7b57 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/osek.h @@ -0,0 +1,275 @@ +/* ========================================== + CMock Project - Automatic Mock Generation for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +typedef unsigned char OSServiceIdType; +typedef void (*OSEKOS_VOIDFUNCPTR)(void); + +typedef unsigned char StatusType; +typedef unsigned char OSEK_U8; +typedef unsigned short OSEK_U16; +typedef unsigned long OSEK_U32; + +void OSEKOSDisableAll(void); +void OSEKOSEnableAll(void); + +typedef unsigned long * OSEKOSSaveType; +typedef void OSEK_TASK; +typedef OSEK_U8 OSEKOSPrioType; + +enum { +Task_DbgCAN +, +Task_ALS +, +CalibrateMagTask +, +Task_IAQ +, +SmartBeam +, +Task_QbertTestImage +, +Task_TestQbertMem +, +Task_Cyclic1000 +, +ProcessMagForCompass +, +ReadMag +, +Task_Cyclic10 +, +Task_Wdm +, +BackgroundTask +, +Task_Cyclic20 +, +Task_Cyclic2 +}; + +OSEK_TASK OSEKOS_T_Task_DbgCAN(void); +OSEK_TASK OSEKOS_T_Task_ALS(void); +OSEK_TASK OSEKOS_T_CalibrateMagTask(void); +OSEK_TASK OSEKOS_T_Task_IAQ(void); +OSEK_TASK OSEKOS_T_SmartBeam(void); +OSEK_TASK OSEKOS_T_Task_QbertTestImage(void); +OSEK_TASK OSEKOS_T_Task_TestQbertMem(void); +OSEK_TASK OSEKOS_T_Task_Cyclic1000(void); +OSEK_TASK OSEKOS_T_ProcessMagForCompass(void); +OSEK_TASK OSEKOS_T_ReadMag(void); +OSEK_TASK OSEKOS_T_Task_Cyclic10(void); +OSEK_TASK OSEKOS_T_Task_Wdm(void); +OSEK_TASK OSEKOS_T_BackgroundTask(void); +OSEK_TASK OSEKOS_T_Task_Cyclic20(void); +OSEK_TASK OSEKOS_T_Task_Cyclic2(void); +OSEK_TASK OSEKOS_Twrap_Task_DbgCAN(void); +OSEK_TASK OSEKOS_Twrap_Task_ALS(void); +OSEK_TASK OSEKOS_Twrap_CalibrateMagTask(void); +OSEK_TASK OSEKOS_Twrap_Task_IAQ(void); +OSEK_TASK OSEKOS_Twrap_SmartBeam(void); +OSEK_TASK OSEKOS_Twrap_Task_QbertTestImage(void); +OSEK_TASK OSEKOS_Twrap_Task_TestQbertMem(void); +OSEK_TASK OSEKOS_Twrap_Task_Cyclic1000(void); +OSEK_TASK OSEKOS_Twrap_ProcessMagForCompass(void); +OSEK_TASK OSEKOS_Twrap_ReadMag(void); +OSEK_TASK OSEKOS_Twrap_Task_Cyclic10(void); +OSEK_TASK OSEKOS_Twrap_Task_Wdm(void); +OSEK_TASK OSEKOS_Twrap_BackgroundTask(void); +OSEK_TASK OSEKOS_Twrap_Task_Cyclic20(void); +OSEK_TASK OSEKOS_Twrap_Task_Cyclic2(void); + +typedef OSEK_U8 TaskType; +typedef OSEK_U8 TaskStateType; +typedef OSEK_U16 EventMaskType; +typedef OSEK_U8 ResourceType; + +void OSEKOSEnableSystemTimers(void); + +typedef OSEK_U8 CounterType; +typedef OSEK_U32 TickType; +typedef OSEK_U8 AlarmType; + +void OSEKOS_ISR_CanTxInterrupt(void); +void OSEKOS_ISR_CanRxInterrupt(void); +void OSEKOS_ISR_CanErrInterrupt(void); +void OSEKOS_ISR_SCIRxInterrupt(void); +void OSEKOS_ISR_SCITxInterrupt(void); +void OSEKOS_ISR_UP_DMA_Interrupt_0(void); +void OSEKOS_ISR_UP_DMA_Interrupt_1(void); +void OSEKOS_ISR_UP_DMA_Interrupt_2(void); +void OSEKOS_ISR_UP_DMA_Interrupt_3(void); +void OSEKOS_ISR_CompFreqHandler(void); +void OSEKOS_ISR_AmbientReturnInt(void); +void OSEKOS_ISR_GlareReturnInt(void); +void OSEKOS_ISR_ALSTimeoutInt(void); +void OSEKOS_ISR_LINTimerInt(void); +void OSEKOS_ISR_LINDelayInt(void); +void OSEKOS_ISR_TimerMExpire(void); +void OSEKOS_ISR_LINRxTx_SCI1(void); +void OSEKOS_ISR_CanRxInterrupt_1(void); +void OSEKOS_ISR_LINError_SCI1(void); +void OSEKOS_ISR_SysCounter(void); + + +// defined multiple times (slightly different forms) These should be ignored because they are externed +extern void OSEKOS_ISR_CanTxInterrupt( void ); +extern void OSEKOS_ISR_CanRxInterrupt( void ); + + +unsigned long OSEKOSrtcGetSeconds ( void ); +void OSEKOSrtcIncrement ( unsigned long nsec ); + +enum +{ + E_OS_ACCESS = 1, + E_OS_CALLEVEL = 2, + E_OS_ID = 3, + E_OS_LIMIT = 4, + E_OS_NOFUNC = 5, + E_OS_RESOURCE = 6, + E_OS_STATE = 7, + E_OS_VALUE = 8, + E_OS_SYS_StackOverflow = 20, + E_OS_SYS_StackUnderflow = 21, + E_OS_SYS_INIT = 22, + E_OS_SYS_CONFIG = 23, + E_OS_SYS_CODE = 24, + E_OS_SYS_TOOL = 25, + E_OS_SYS_TimerRange = 26 +}; + +enum +{ + SUSPENDED = 0x00, + READY = 0x01, + RUNNING = 0x02, + WAITING = 0x03, + INTSTART = 0x08, + SETSTART = 0x10, + NPRTASK = 0x20, + USEFP = 0x40 +}; + +typedef struct +{ + TickType maxallowedvalue; + TickType ticksperbase; +} AlarmBaseType; + +typedef TaskType *TaskRefType; +typedef TaskStateType *TaskStateRefType; +typedef EventMaskType *EventMaskRefType; +typedef TickType *TickRefType; +typedef AlarmBaseType *AlarmBaseRefType; +typedef OSEK_U8 AppModeType; +typedef OSEK_U8 OSEKOSTaskActCntType; + +TaskType OSEKOStidact; +OSEKOSPrioType OSEKOSrunprio; + +StatusType OSEKOSError ( register StatusType ); +void ErrorHook ( StatusType ); +void StartupHook ( void ); +void ShutdownHook ( StatusType ); + +int getUsedTaskStack ( TaskType ); +int getUnusedTaskStack ( TaskType ); +int getUsedIsrStack ( void ); +int getUnusedIsrStack ( void ); +void OSEKOStaskStackCheckInit ( void ); +signed char OSEKOStaskStackCheck ( OSEK_U8 * ); +signed char OSEKOSisrStackCheck ( OSEK_U8 * ); +void OSEKOStaskStackCheckFatal ( OSEK_U8 * ); +void OSEKOSisrStackCheckFatal ( OSEK_U8 * ); +OSEK_U8 * OSEKOSgetStackPointer ( void ); +void OSEKOSTaskSwitch ( void ); +StatusType OSEKOSReturn ( StatusType ); +StatusType OSEKOSActivateTask ( register TaskType ); +void OSEKOSTerminateTask ( TaskType, TaskType ); + + extern void OSEKOSGetResource ( ResourceType ); + extern void OSEKOSReleaseResource ( ResourceType ); + +int OSEKOSSetEvent ( TaskType, EventMaskType ); +int OSEKOSWaitEvent ( EventMaskType ); +TickType OSEKOSGetAlarm(register AlarmType); +void OSEKOSSetAlarm ( AlarmType, TickType, TickType ); +StatusType OSEKOSSetAbsAlarm ( AlarmType a, TickType b, TickType c ); + +StatusType OSEKOSCancelAlarm ( register AlarmType ); +void OSEKOSAdvCntr ( void ); +AppModeType GetActiveApplicationMode ( void ); + +void StartOS ( AppModeType ); + +void OSEKOSShutdownOS ( StatusType ); + +StatusType ActivateTask ( TaskType A ); +StatusType TerminateTask ( void ); +StatusType ChainTask ( TaskType A ); +StatusType GetTaskState ( TaskType A, TaskStateRefType B ); +StatusType GetTaskID ( TaskRefType A ); +StatusType Schedule ( void ); +StatusType GetResource ( ResourceType A ); +StatusType ReleaseResource ( ResourceType A ); +StatusType SetEvent ( TaskType A, EventMaskType B ); +StatusType ClearEvent ( EventMaskType A ); +StatusType WaitEvent ( EventMaskType A ); +StatusType GetEvent ( TaskType A, EventMaskRefType B ); +StatusType GetAlarm ( AlarmType A, TickRefType B ); +StatusType GetAlarmBase ( AlarmType A, AlarmBaseRefType B ); +StatusType SetRelAlarm ( AlarmType A, TickType B, TickType C ); +StatusType SetAbsAlarm ( AlarmType A, TickType B, TickType C ); +StatusType CancelAlarm ( AlarmType A ); +StatusType AdvCntr ( CounterType A ); +StatusType IAdvCntr ( CounterType A ); +void SuspendOSInterrupts ( void ); +void ResumeOSInterrupts ( void ); +void SuspendAllInterrupts ( void ); +void ResumeAllInterrupts ( void ); +void DisableAllInterrupts ( void ); +void EnableAllInterrupts ( void ); + +void OSEKOSDisable(void); +void OSEKOSEnable(void); +void OSEKOSAsmIDispatch(unsigned long *); +void OSEKOSAsmDispatch(OSEKOSPrioType p); +void OSEKOSStartupEnable(void); +void OSEKOSNop(void); +unsigned int OSEKOSV850CheckIsrSwitch(void); +void OSEKOSV850InitInterrupts(void); +void OSEKOSV850SetupInterrupts(); +void OSEKOSV850SyncContextLoad(OSEKOSSaveType); +void OSEKOSV850SyncContextLoadFromIRQ(OSEKOSSaveType); +void OSEKOSV850ASyncContextLoad(OSEKOSSaveType); +void OSEKOSV850ASyncContextLoadFromIRQ(OSEKOSSaveType); + +// arrays of function pointers - they look like function prototypes +void ( ( * const OSEKOStaskStartAddress [10] ) ( void ) ); +StatusType (* OSEKOStaskStatuses [10][5]) ( void ); + +void OSEKOSV850StartContext +( + OSEK_TASK (( * const ) ( void )), + OSEK_U8 * const +); +void OSEKOSV850StartContextFromIRQ +( + OSEK_TASK (( * const ) ( void )), + OSEK_U8 * const +); + +void OSEKOSSuspendOSInterrupts(void); +void OSEKOSResumeOSInterrupts(void); +void OSEKOSSuspendAllInterrupts(void); +void OSEKOSResumeAllInterrupts(void); +void OSEKOScheckSuspendResumeNesting(void); + + +void OSEKOSgetSR(void); +void OSEKOSEnableInterrupt_intern(int nr); +void OSEKOSDisableInterrupt_intern(int nr); diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/parsing.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/parsing.h new file mode 100644 index 000000000..d4734f448 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/parsing.h @@ -0,0 +1,89 @@ +/* ========================================== + CMock Project - Automatic Mock Generation for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +typedef unsigned short U16; +typedef signed int int32_t; + +/* CMock should handle UTF-8 characters in comments. The world is an awesomely diverse place! */ +/* my µC Rocks! Open Source, not ©! My language has no Ümlauts! ǺƜǝƧǾɱɛ! */ /**! Illegal: åäö */ + +typedef struct _POINT_T +{ + int x; + int y; +} POINT_T; + +// typedef edge case; +// not ANSI C but it has been done and will break cmock if not handled +typedef void VOID_TYPE_CRAZINESS; + +/* fun parsing & mock generation cases */ + +void var_args1(int a, ...); +void var_args2(int a, int b, ...); + +VOID_TYPE_CRAZINESS void_type_craziness1(int, float, double, char, short, long, long int, long long, void*); +int void_type_craziness2( VOID_TYPE_CRAZINESS ); + + void crazy_whitespace ( int lint, double shot , short stack ) ; + +char + crazy_multiline +( + int a, + unsigned int b); + +U16 *ptr_return1(int a); +U16* ptr_return2(int a); +U16 * ptr_return3(int a); + +unsigned int** ptr_ptr_return1(unsigned int** a); +unsigned int* *ptr_ptr_return2(unsigned int* *a); +unsigned int **ptr_ptr_return3(unsigned int **a); +unsigned int ** ptr_ptr_return4(unsigned int ** a); + +extern unsigned long int incredible_descriptors(register const unsigned short a); + +int32_t example_c99_type(int32_t param1); + +void I2CIntRegister(uint32_t ui32Base, void (*pfnHandler)(void)); + +/* these are function pointers, not function declarations USING a function pointer, and so should NOT get mocked */ +int (* func_pointer)(void); +extern int (*another_func_pointer)(unsigned int argument); +struct struct_to_be_ignored { + union { + int i32; + void *p; + } variant; + void (*a_function_pointer_in_a_struct)(void *); +}; + +typedef struct +{ + uint32_t a; + struct + { + uint32_t bb; + float bc; + float bd; + } b; + int (*another_function_pointer_in_a_struct) (void); +} another_thing_that_should_get_ignored; + +inline int stuff(int num) +{ + int reg = 0x12; + if (num > 0) + { + reg |= (0x0Eu); + } + else + { + reg |= (0x07u); + } + return reg; +} |