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) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_