malsyned / pfstest

Professional Firmware Services Unit Test Framework
Other
1 stars 0 forks source link

pfstest-mock: Print invocation log during execution #50

Open malsyned opened 6 years ago

malsyned commented 6 years ago

Since it is not possible to provide information of what mock invocations occurred during the verification phase, it would be very useful as a command line option to print every invocation as it occurs, so that the list can be visually checked against what is expected in the event of a surprise failure.

malsyned commented 6 years ago

This is seeming to be a much more complicated feature than I had originally considered. The main question is: where can pfstest_mock_invoke get printers for each argument? automock.py isn't smart enough to use useful value boxers, it just punts to the_pointer and the_memory for everything. Maybe the_memory's printer is better than nothing in a pinch, but it's not very pretty.

It might be possible to extract printers for the values from arg matchers somehow, but there could be several arg matchers for a given invocation depending on the expectation list, and which to pick? Not to mention arg handlers don't always know, even indirectly, how to print the value they're matching against.

automock.py could get smarter about picking value types, since it knows a great deal about primitives. Resolving typedefs would get tricky: if always, then u8s would be output as chars, if never then many types wouldn't have built-in boxers. Resolving structs even moreso: just punt to the_memory? This could possibly be mitigated by a new autovalue.py and the ability to register boxers in a typedef->boxer table in automock.py.

malsyned commented 6 years ago

Perhaps the easier way to address the same user story is to implement callbacks and let the user do their own printing if they want.