Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the existing test/mock infrastructure to support new unit tests for Iarmmgr, primarily by adding additional wrapped libc APIs and expanding mocked IARM/Telemetry surfaces used by tests.
Changes:
- Added Wraps support for
fclose/fgetsincluding linker__wrap_*entry points and mock interfaces. - Extended Telemetry mocks/API with a new
t2_event_fentry point. - Extended IARM mocks/API with
IARM_Bus_RegisterEventand added additional SYSMgr/IARM type guards and fields to the mock header.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/mocks/WrapsMock.h | Adds gmock methods for fclose/fgets. |
| Tests/mocks/Wraps.h | Extends WrapsImpl and Wraps with fclose/fgets declarations. |
| Tests/mocks/Wraps.cpp | Adds __wrap_fclose/__wrap_fgets and changes Wraps::fopen behavior to require a mock impl. |
| Tests/mocks/TelemetryMock.h | Adds gmock method for t2_event_f. |
| Tests/mocks/Telemetry.h | Extends Telemetry interface/API and function-pointer surface with t2_event_f. |
| Tests/mocks/Telemetry.cpp | Implements TelemetryApi::t2_event_f and exports function pointer t2_event_f. |
| Tests/mocks/IarmBusMock.h | Adds gmock method for IARM_Bus_RegisterEvent. |
| Tests/mocks/Iarm.h | Extends IARM interface/API and adds additional type guards/fields for SYSMgr-related mock types. |
| Tests/mocks/Iarm.cpp | Implements IARM_Bus_Disconnect, IARM_Bus_Term, IARM_Bus_RegisterEvent and exports corresponding function pointers. |
Comments suppressed due to low confidence (1)
Tests/mocks/Wraps.cpp:533
Wraps::fopenno longer falls back to::fopenwhenimplis null (it now hard-asserts). This is a behavior change relative to the previous implementation and is inconsistent with other wrappers here (e.g.Wraps::open/Wraps::statstill fall back to the real libc call). If tests rely on real file I/O when no mock is installed, this will now fail; either restore the fallback or apply a consistent policy across these wrappers.
FILE *Wraps::fopen(const char *pathname, const char *mode)
{
FILE *result = nullptr;
if (impl != nullptr)
{
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| virtual void t2_init(char* component) = 0; | ||
| virtual void t2_uninit(void) = 0; | ||
| virtual T2ERROR t2_event_s(const char* marker, const char* value) = 0; | ||
| virtual T2ERROR t2_event_d(const char* marker, int value) = 0; | ||
| virtual T2ERROR t2_event_f(char* marker, double value) = 0; | ||
| }; | ||
|
|
||
| class TelemetryApi { | ||
| protected: | ||
| static TelemetryApiImpl* impl; | ||
| public: | ||
| TelemetryApi(); | ||
| TelemetryApi(const TelemetryApi &obj) = delete; | ||
| static void setImpl(TelemetryApiImpl* newImpl); | ||
| static void t2_init(char* component); | ||
| static void t2_uninit(void); | ||
| static T2ERROR t2_event_s(const char* marker, const char* value); | ||
| static T2ERROR t2_event_d(const char* marker, int value); | ||
| static T2ERROR t2_event_f(char* marker, double value); | ||
| }; |
There was a problem hiding this comment.
t2_event_f takes char* marker, which is inconsistent with t2_event_s/d (const char*) and unnecessarily drops constness. This makes common call sites like passing string literals or const char* markers fail to compile. Consider changing the marker parameter type to const char* (and update the corresponding mock method, implementation, and function pointer typedefs to match).
No description provided.