Greetings,
A week long collaboration between me and GDB, figuring out how to reproduce my 
CounterProtocol with function arguments, made me reach the conclusion that 
mocking a UEFI protocol is indeed documented and the solution had to do with 
copying the style of a global table Mock.

This is the relevant piece of documentation: 
https://fuchsia.googlesource.com/third_party/edk2/+/refs/heads/main/UnitTestFrameworkPkg/#functionmocklib-mocks-declaration

And this would be my Sample Protocol:

// header file
struct MockCounterProtocol: CounterProtocol {
MOCK_INTERFACE_DECLARATION(MockCounterProtocol);
MOCK_FUNCTION_DECLARTION(INTN, CounterProtocol_Count, ());
}

extern "C" {
extern CounterProtocol *gCounterProtocol;
}

// source file

MOCK_INTERFACE_DEFINITION (MockCounterProtocol)
MOCK_FUNCTION_DEFINITION (MockCounterProtocol, Count, 0, EFIAPI)

static CounterProtocol localCounterProtocol = {
current_count
};

extern "C" {
CounterProtocol *gCounterProtocol = &localCounterProtocol;
}

Best Regards,
Me & Gdb


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109213): https://edk2.groups.io/g/devel/message/109213
Mute This Topic: https://groups.io/mt/101360319/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to