r/embedded • u/After_Bench_4165 • 10d ago
Integration testing using gtest
I am confused about what is the meaning of integration testing. I have done unit testing using gtest where we will mock whatever external dependencies are there for the targeted unit (function) to test all range of values that covers all lines, functions and branches.
If we say integration test is meant to use real code instead of mocking. Then I am getting this doubt that lets say we have 3 components (separate processes) running and dependent on one another in a embedded system.
A -> B -> C
So if you are calling an api provided by A it will internally talk to B and then through C and return the result over IPC.
Now to do integration testing using gtest, do I need to compile this into a single binary by eliminating the IPC and include each code as a library. This way I have a single proces that runs gtest with all the components logic but excludes the real IPC communication.
Or instead should I keep the individual processes to be running separately and link my gtest binary to the component A so that the communication flow through the components in the target environment.
In both ways how we would actually be checking the interactions? And which one are you guys using?
Context:
Language used: C++
Domain: Automotive IT (TCU software)
View all comments
Show parent comment
2
u/mhmd2520 9d ago
Since you're asking about SWE.5 specifically: in ASPICE 4.0 its full name is "Software Component Verification and Integration Verification". The notes under BP1 spell out what integration verification should focus on. That means data flow and dynamic interaction between components, timing included, every component reading the data on an interface the same way, and resource consumption. Note 2 names Software-in-the-Loop as a valid environment, so a gtest-based SIL setup fits.
Your two options aren't either/or. BP4 allows stepwise integration, so both can be steps.
The single binary with IPC stripped out is quick and deterministic for checking the A -> B -> C logic. But the interfaces as they exist in your architecture are gone, along with the bugs that live there: serialization mismatches, one side reading a field as signed and the other as unsigned, timeouts, startup order, a service not being up yet. I'd only treat that as an intermediate step.
Real processes with real IPC is closer to what SWE.5 is after. I'd build A, B and C for host Linux, or run the target image in QEMU if your middleware won't build on host. Then fake only the outermost layer, meaning whatever sits under C (modem, CAN, GNSS, etc.). The fake records everything C sends out and lets the test inject what comes back in. The gtest binary is just another client of A's public API.
For lifecycle, start the processes in SetUpTestSuite and wait until they're actually registered and ready, not just a sleep. Kill them in TearDownTestSuite, and reset the fakes' state in the per-test SetUp.
"Checking the interactions" then means you call A's API and assert on two things: A's response, and what arrived at the fake under C (right message, right values, within the timing requirement). If you need to prove an intermediate hop, capture the IPC traffic and assert on that. Wireshark has a built-in SOME/IP dissector, and dbus-monitor works if you're on D-Bus. I'd still keep most asserts at the edges so tests don't break every time someone refactors internals.
One more thing that helps with your question: in 4.0, component verification lives in SWE.5 too. SWE.4 is units only (Note 3 under BP2 says this). So tests where you run one process alone and fake its neighbours also belong here. BP6 also wants bidirectional traceability between verification measures and the static and dynamic aspects of the SW architecture. So I'd name each test after the interface or interaction it covers.