Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't seem to mock a call to a function that lives on a windows dll when that dll is loaded #305

Open
alexapio opened this issue Jul 10, 2023 · 1 comment

Comments

@alexapio
Copy link

Hi,
The code I'm testing is on a Windows dll. I wrote a test program that links in the dll and runs tests on it.
It looks like this:
test_runner<-library<-collaborator (another library being mocked).

This pseudocode fails with "mock_func not called" and upon step-debugging I step into the real function.
REQUIRE_CALL(mock_api, mocked_func(_)).RETURN(retval);
err = mocked_func(arg);
REQUIRE(err == ERR_OK);

I'm assuming (haven't verified) that Windows us loading the real collaborator library (as it's a dependency for it) and then the test binary runs that code instead of the mocked call. The issue is that I can't run tests that mock return values to test error handling.

Does this make sense? I'm a firmware guy, my windows-fu is not the strongest.

Thanks!

@alexapio alexapio changed the title Can't seem to mock a function on a windows dll Can't seem to mock a call to a function that lives on a windows dll when that dll is loaded Jul 10, 2023
@rollbear
Copy link
Owner

I'm afraid I don't understand the problem at all, but I'm almost certainly even less of a windows person.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants