Mocking peripherals for unit testing

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Mocking peripherals for unit testing

1,759 次查看
gmb
Contributor I

I have been experimenting with using unity as a unit-testing tool, together with ceedling and cmock, against code developed with SDK2.1. I have only succeeded in getting trivial tests working before running into issues involving drivers. It seems as if cmock fails on static inline functions.

Has anyone managed to properly harness a project built on SDK2.1 or SDK2.2? I am not specifically tied to unity/ceedling/cmock. I would be happy with any tool that manages to penetrate the layers of register definitions and operations.

标签 (1)
标记 (2)
0 项奖励
1 回复

1,199 次查看
laurensmiers
Contributor I

Hi Greg,

I'm trying to do the same thing as you, use ceedling to write some tests for drivers/applications/... that use the KSDK.

Unfortunatelly, I also have issues with 'static inline' functions.

I don't know how you did it, but I just did a workaround by declaring my own mock-headers of the KSDK.

The API of the SDK won't change that quick/much so I guess it's safe to copy the original KSDK header and replace the 'static inline' functions with 'normal' function declarations (without static inline).

That way, CMock recognizes them as a regular function and makes mocks out of it.

And if the API of the SDK changes, I would have to change my code anyway, so I guess this is a 'safe' workaround.

If you found another tool that can better handle this, let me know.

Thanks,

Hope this helps,

KR,

Laurens

0 项奖励