public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "CrossedCarpet" <crossedcarpet@hotmail.com>
To: CrossedCarpet <crossedcarpet@hotmail.com>,devel@edk2.groups.io
Subject: Re: [edk2-devel] Problems mocking UEFI Protocol in gMock
Date: Fri, 29 Sep 2023 09:47:38 -0700	[thread overview]
Message-ID: <27529.1696006058785664800@groups.io> (raw)
In-Reply-To: <10445.1695395049741883261@groups.io>

[-- Attachment #1: Type: text/plain, Size: 1416 bytes --]

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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 2692 bytes --]

      reply	other threads:[~2023-09-29 16:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 15:22 [edk2-devel] Problems mocking UEFI Protocol in gMock CrossedCarpet
2023-09-22 15:04 ` CrossedCarpet
2023-09-29 16:47   ` CrossedCarpet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27529.1696006058785664800@groups.io \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox