meekrosoft / fff

A testing micro framework for creating function test doubles
Other
749 stars 163 forks source link

#pragma pack(1) breaks Function Return Value Sequences #107

Open alexsconway opened 2 years ago

alexsconway commented 2 years ago

Describe the bug I'm using Ceedling with Unity and FFF to unit test some embedded code. To make some things work I need to specify #pragma pack(1) for some structures. I was trying to mock a sequence of return values for a function and the results were not as expected. Some hours later I have trimmed it down to a minimal reproduction case:

To Reproduce make sure you have Ceedling and FFF set up etc... This was on Windows 10 with MinGW Unzip the TestFFFseq.zip, start a command prompt in the TestFFFseq folder and run ceedling test:all

the result will be

FAILED TEST SUMMARY

[test_FFFseq.c] Test: test_One At line (28): "Expected 1 Was 0"

OVERALL TEST SUMMARY

TESTED: 1 PASSED: 0 FAILED: 1 IGNORED: 0

Expected behavior

OVERALL TEST SUMMARY

TESTED: 1 PASSED: 1 FAILED: 0 IGNORED: 0

Compiler, toolset, platform (please complete the following information):

If one comments out the #pragma pack(1) on line 3 of test_FFFseq.c then the test passes.

I tried but couldn't reproduce without Ceedling generating the fake.

This can be avoided by using #pragma pack(push, 1) and #pragma pack(pop) where one needs it in one's code

TestFFFseq.zip

samthode commented 2 years ago

Thanks for posting this. Just spent 5 hours debugging a non sense issue. Turns out it was b/c pragma pack