|
Post by Oliver (by email) on Jun 26, 2013 16:51:51 GMT -5
Hello Martin,
i got your mailaddress from Stephan.
My question about the wrappers.
We used a lot of ALLOW_VALIDATE. e.g. ALLOW_VALIDATE(funcA, wrapper_funcA)
after this ALLOW_VALIDATE in an other testcase (same Testsuite / and exe) we have to test this function. so we made ALLOW_VALIDATE(wrapper_funcA, funcA).
Is there an other way to DISALLOW wrapping a function?
with best regards Oliver
|
|
|
Post by Martin Nielsen on Jun 26, 2013 17:04:10 GMT -5
Hi Oliver
Now I understand the problem - I never imagined that it would be used like this, but I am happy to hear that it sort of works though :-)
It is the intention that ALLOW's made in one test, should only take effect within the scope of that test, hence the backward ALLOW's should not be necessary in the first place.
So, the question is then what is triggering this problem ? Can you send me one example where you need a backward ALLOW, then I will either fix the problem or come up with some new macro's that can support what you're trying to achieve.
Br, Martin
|
|
|
Post by Oliver by email on Aug 20, 2013 17:09:52 GMT -5
Hello Martin,
sorry it's a long time a go.
Here is an example
//File A int funcA(void) { funcB() }
int funcB(void) { funcD() }
int TestsFuncA() { ALLOW_VALIDATE(funcB, wrapper_FuncB) funcA(); // check values and so }
int TestsFuncB() { ALLOW_VALIDATE(funcD, wrapper_FuncD) funcB(); // check values and so }
int TestFileA() { TestsFuncA() TestsFuncB() }
//------------------------------------------------- //File B int funcC(void) { funcB() funcD() }
int funcD(void) { }
int TestsFuncC() { ALLOW_VALIDATE(funcB, wrapper_FuncB) ALLOW_VALIDATE(funcD, wrapper_FuncD) funcC(); // check values and so }
int TestsFuncD() { funcD(); // check values and so }
int TestFileB() { TestsFuncC() TestsFuncD() }
//------------------------------------------------- // File C int AllTests() { TestFileA(); TestFileB(); }
Conditions: the functions must be place3d at there files.
With this example and condition it is not possible to test allfunctions without an "DISALLOW"
is it possible to get an DISALLOW(funcA) Makro??
with best regards Oliver
|
|
|
Post by Martin Nielsen on Aug 20, 2013 17:14:54 GMT -5
Hi Oliver - Thanks for your example. It is clear and easy to understand. It is my experience that these issues are best resolved by examples that showcases the problem.
I will spend some more time with this, but just from the top of my head, I can see that you're not using the EXECUTE macro. This has the effect that all allows are within the same scope. The execute macro will execute the test, but it also handles mocking scopes and among other things it will restore all function moking done by a test upon exit.
e.g
//------------------------------------------------- // File C int AllTests() { EXECUTE(TestFileA); // all mocking done by file a, are no longer active EXECUTE(TestFileB);// all mocking done by file b, are no longer active }
Now, there can be good reasons why you don't want to use EXECUTE and I don't mind providing disallow functionality. Would ALLOW_VALIDATE(FuncA, FuncA) work for you ?
I think the reason for the error is because of stack exhaustion - I'll put up a debugger to verify that. As I recall, there are no constraints for this except memory, so if it is a stack problem, there is nothing else I can do, but provide you with a disalllow macro.
I will be back later next week with my results. Br, Martin
|
|
|
Post by Martin Nielsen on Aug 20, 2013 17:16:54 GMT -5
Hi again
I just realized that perhaps you're only using the mocking part of TestApe and not really interested in the other parts. Perhaps you're using TestApe together with another test system. In that case you would probably be better off with some simpler macros, e.g MOCK(func, mock_func) and UNMOCK(func) that works outside the scope system. If that is the case, let me know and I'll change the instrumenter with an option -mockingonly - so that it can optimize the code it generates for this scenario. It will probably work better for you.
In any case, I like the MOCK/UNMOCK syntax, so I think I'll go with that solution.
Br, Martin
|
|
|
Post by Martin Nielsen on Aug 20, 2013 17:18:15 GMT -5
Hi Oliver
There is now a new beta version available. It is a bit premature, but I dont't relly have much for this later this week. I'll have to do some more testing, but its there if you would like to try it out.
Martin
|
|
|
Post by Oliver by email on Aug 20, 2013 17:19:57 GMT -5
Hi Martin,
i'm testing witrh your beta version, but for my "big" project it doesn't work.
Some (not all ) MOCK==> UNMOCK==> MOCK ==> UNMOCK or MOCK==> MOCK==> MOCK ==> UNMOCK sequences doesn't work.
Br Oliver
|
|