[lldb/Test] Rewrite ReproducerInstrumentationTest
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 10 Apr 2020 22:42:28 +0000 (15:42 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 10 Apr 2020 23:50:44 +0000 (16:50 -0700)
commitf78fcd6906a032bf5feb0e60c9e8991bf31e990e
tree8cac9124524214e0f5a8bc5d6620bb289bfbe335
parent16206ee07d35814d57349f05823fb17e875f8278
[lldb/Test] Rewrite ReproducerInstrumentationTest

The instrumentation unit tests' current implementation uses global
variables to track constructor calls for the instrumented classes during
replay. This is suboptimal because it indirectly relies on how the
reproducer instrumentation is implemented. I found out when adding
support for passive replay and the test broke because we made an extra
(temporary) copy of the instrumented objects.

Additionally, the old approach wasn't very self-explanatory. It took me
a bit of time to understand why we were expecting the number of objects
in the test.

This patch rewrites the test and uses the index-to-object-mapping to
verify the objects created during replay. You can now specify the
expected objects, in order, and whether they should be valid or not. I
find that it makes the tests much easier to understand. More
importantly, this approach is resilient to implementation detail changes
in the instrumentation.
lldb/include/lldb/Utility/ReproducerInstrumentation.h
lldb/source/Utility/ReproducerInstrumentation.cpp
lldb/unittests/Utility/ReproducerInstrumentationTest.cpp