Topology-based simulation and diagnosis of faulty program spectra, inspired by TU Delft’s SFL simulator.
Our simulator uses DendoPy’s phylogenetic tree simulation to generate a random tree-based topology of components, which emulates a system’s structure. Tests are generated by activating components, and propagating these activations in the topology. The simulator is also able to perform fault injection conditioned by a goodness parameter.
To run a simulation:
make run desc=example.yml
In the example above, the option desc=example.yml
tells the simulator to use
the experiment description from file example.yml. A full-fledged experimental
description file is also included in the repository: tse.yml.
After running a simulation, results can be plotted by:
make plot desc=example.yml
Below is a step-by-step example of simulating and diagnosing faulty spectra with our simulator library.
import simulator
components = 20
topology_generator = simulator.TopologyGenerator(components)
topology = topology_generator.generate()
topology.print_plot()
activator = simulator.CoverageActivator(topology)
simulated_transactions = activator.generate(reps = 20)
print("Simulated ", simulated_transactions.transactions, "transactions")
spectrum1 = [s for s in simulated_transactions.sample_spectra(1)][0]
spectrum1.print_spectrum()
simulator.print_metrics(spectrum1)
simulated_transactions = activator.generate(reps = 20, coefs=[0.5])
spectrum2 = [s for s in simulated_transactions.sample_spectra(1)][0]
spectrum2.print_spectrum()
simulator.print_metrics(spectrum2)
simulated_transactions = activator.generate(reps = 20, coefs=[3.0])
spectrum3 = [s for s in simulated_transactions.sample_spectra(1)][0]
spectrum3.print_spectrum()
simulator.print_metrics(spectrum3)
faulty_spectrum1 = spectrum1.copy()
faults = faulty_spectrum1.inject_fault(cardinality=1)
print("Faults: ", faulty_spectrum1.faults)
faulty_spectrum1.print_spectrum()
faulty_spectrum2 = spectrum1.copy()
faults = faulty_spectrum2.inject_fault(cardinality=1)
faults = faulty_spectrum2.inject_fault(cardinality=1)
print("Faults: ", faulty_spectrum2.faults)
faulty_spectrum2.print_spectrum()
faulty_spectrum3 = spectrum1.copy()
faults = faulty_spectrum3.inject_fault(cardinality=2)
print("Faults: ", faulty_spectrum3.faults)
faulty_spectrum3.print_spectrum()
mhs = simulator.MHS()
barinel = simulator.Barinel()
trie = mhs.calculate(faulty_spectrum1)
report = barinel.diagnose(faulty_spectrum1, trie)
for index, (candidate, probability) in enumerate(report):
if index >= 5: break
print(candidate, probability)
effort = simulator.effort_reduced(faulty_spectrum1, report)
print("Effort to diagnose: ", effort)