[all-commits] [llvm/llvm-project] f78fcd: [lldb/Test] Rewrite ReproducerInstrumentationTest

Jonas Devlieghere via All-commits all-commits at lists.llvm.org
Fri Apr 10 16:51:00 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f78fcd6906a032bf5feb0e60c9e8991bf31e990e
      https://github.com/llvm/llvm-project/commit/f78fcd6906a032bf5feb0e60c9e8991bf31e990e
  Author: Jonas Devlieghere <jonas at devlieghere.com>
  Date:   2020-04-10 (Fri, 10 Apr 2020)

  Changed paths:
    M lldb/include/lldb/Utility/ReproducerInstrumentation.h
    M lldb/source/Utility/ReproducerInstrumentation.cpp
    M lldb/unittests/Utility/ReproducerInstrumentationTest.cpp

  Log Message:
  -----------
  [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.




More information about the All-commits mailing list