Exemple #1
0
def test_avoid_duplicate_instrumentation(simple_module):
    tracer = MagicMock(ExecutionTracer)
    instr = BranchDistanceInstrumentation(tracer)
    already_instrumented = instr.instrument_module(
        simple_module.cmp_predicate.__code__)
    with pytest.raises(AssertionError):
        instr.instrument_module(already_instrumented)
Exemple #2
0
 def get_code(self, fullname) -> CodeType:
     """Add instrumentation instructions to the code of the module
     before it is executed."""
     to_instrument = cast(
         CodeType,
         super(InstrumentationLoader, self).get_code(fullname))
     assert to_instrument, "Failed to get code object of module."
     # TODO(fk) apply different instrumentations here
     instrumentation = BranchDistanceInstrumentation(self._tracer)
     return instrumentation.instrument_module(to_instrument)
Exemple #3
0
    def get_code(self, fullname) -> CodeType:
        """Add instrumentation instructions to the code of the module
        before it is executed.

        Args:
            fullname: The name of the module

        Returns:
            The modules code blocks
        """
        to_instrument = cast(CodeType, super().get_code(fullname))
        assert to_instrument, "Failed to get code object of module."
        # TODO(fk) apply different instrumentations here
        if config.configuration.dynamic_constant_seeding:
            dynamic_seeding_instr = DynamicSeedingInstrumentation()
            to_instrument = dynamic_seeding_instr.instrument_module(to_instrument)
        instrumentation = BranchDistanceInstrumentation(self._tracer)
        return instrumentation.instrument_module(to_instrument)