ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects

Home Page:http://throwtheswitch.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple definition of, intending to stub a sub-module

jnz86 opened this issue · comments

commented

Ceedling, GCC, FFF. I want to test complex_logic.c. It brings in portable_abstraction.h.

What I'm intending to do is stub portable_abstraction functions, mock them, using FFF to create fakes and see how the complex_logic functions interact with mocked portable_abstraction functions.

In the test, I bring in the real complex_logic.h and mock_port_abstraction.h. Because the test does the linking, I figured it would be OK that complex_logic.c brings in the real port_abstraction.h, but it is not. Multiple definitions of portable_abstraction functions.

Is there a way to stub this that I'm not thinking of? Is there functionality that I'm missing?

EDIT: I found something that may have added complexity. I have one portable_abstraction.h file. But I have two file options for portable_abstraction.c, let's call it portable_freertos.c and portable_bare.c. In order to tell Ceedling which file to use, I have this line after my includes:

TEST_FILE("portable_bare.c") Intention is to use these versions of the portable functions, not the FreeRTOS versions as neither of these need testing, but the complex_logic functions do. Now I suspect adding this specific file in this macro may be an issue.

commented

I'm dumb.

There was at one point a reason to bring in portable_bare.c, but not anymore. It wasn't a good reason, but I didn't process that when I was confident in the file, it shouldn't pull in that .c anymore. That was the issue. Ceedling seems to be doing everything correct and it's not a problem that complex_logic.c brings in the real portable_abstraction.h. I assume the "magic" happens at linking.

But... Using that macro to bring a specific .c file in, doesn't seem to work with the same stubbing process.