-
Notifications
You must be signed in to change notification settings - Fork 44
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
mmk_mock/mmk_when question #5
Comments
I have two more questions:
|
The thing is that mmk_when is supposed to be called multiple times -- it just setups an input-output binding for an existing mock. Think of it as it inserting an It might be a bit awkward when you have a really simple behaviour to describe, but when you want to make a mock that does something a bit more complicated depending on inputs, putting that complex handling in one big mmk_when makes things hard, when you could split that into multiple mmk_when. As for your questions:
|
ffi is really low-level too. I'm not aware that it calls libc functions besides mmap() and mprotect() to get writable, then executable sections. It goes great lengths for many architectures to install trampoline functions with any number of parameters and even variadic functions (the trampoline functions can call back into user code which can then introspect the parameters). It can also be linked statically. Just saying, it would be help to get rid of assembler code and support more architectures. |
I'll send an email to their mailing list to get some more info. libffi seems to heavily rely on the assumption that callers know exactly the types & calling conventions of their functions are, which is sadly not the case for mimick -- we just forward a call to another function, preserving registers along the way as they are. I hope there's a way for me to use libffi for just that, but I don't know enough of the library yet. |
So I investigated some more on how I could "convince" libffi (or dyncall, for that matter), but I don't think this is going anywhere. Fundamentally, the problem is very delicate for Mimick:
All in all, libffi & dyncall both address the problem of calling foreign functions, but that's not the problem we are trying to solve with trampolines in Mimick. It's a shame because that means that I'll have to maintain & test a bunch of different architectures, but I don't know any other project that does this. |
* Drop conflicting type aliasing. * Force C linkage if compiling for C++. * Cast explicitly and deal with C99 features. * Handle array arguments properly. * Avoid brace initializers for scalars. * Force C++11. Signed-off-by: Michel Hidalgo <[email protected]>
Hello,
I know this is very experimental, but we're playing around with mimick in the need for a decent mocking framework.
I'm mainly asking for clarification. I found that the mock is installed by calling mmk_mock(). It doesn't seem to matter when mmk_when() is called, so long it's called after mmk_mock().
Is this intended like this? I think it makes the API a bit awkward, if you want to install the mock in the middle of a test. It would seem more natural to have the mmk_when() call at the beginning of a scope, and making it effective with a later mmk_mock() call.
Also, maybe I'm missing something, but as of now mmk_mock() could also be folded into mmk_when(), and then calling mmk_when() when the mock should be installed.
Don't think of this as a bug report, I just want to understand mimick better, because it seems very useful.
The text was updated successfully, but these errors were encountered: