Mocking peripherals for unit testing

cancel
Showing results for 
Search instead for 
Did you mean: 

Mocking peripherals for unit testing

896 Views
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.

Labels (1)
Tags (2)
0 Kudos
1 Reply

336 Views
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 Kudos