项目作者: aprimadi

项目描述 :
Delta debugging algorithm implemented in Go.
高级语言: Go
项目地址: git://github.com/aprimadi/go-delta-debugging.git
创建时间: 2020-07-24T19:19:06Z
项目社区:https://github.com/aprimadi/go-delta-debugging

开源协议:MIT License

下载


go-delta-debugging

This library provides an implementation of the delta debugging algorithm described here: http://web2.cs.columbia.edu/~junfeng/09fa-e6998/papers/delta-debug.pdf. Code that uses this library should implement the FSM (Finite State Machine) defined in fsm.go.

Usage

  1. package main
  2. import (
  3. "fmt"
  4. dd "github.com/aprimadi/go-delta-debugging"
  5. )
  6. // A simple FSM that becomes faulty when it contains an event "3"
  7. type SimpleFSM struct {
  8. events []dd.Event
  9. }
  10. // Reset the FSM state
  11. func (f *SimpleFSM) Reset() {}
  12. // Apply events to the FSM
  13. func (f *SimpleFSM) Apply(events []dd.Event) {
  14. f.events = events
  15. }
  16. // Is the FSM in valid state?
  17. func (f *SimpleFSM) Valid() bool {
  18. for _, n := range f.events {
  19. if n == 3 {
  20. return false
  21. }
  22. }
  23. return true
  24. }
  25. func main() {
  26. fsm := &SimpleFSM{}
  27. result := dd.DeltaDebug(fsm, []dd.Event{1, 2, 3, 4, 5, 6, 7, 8})
  28. fmt.Println(result) // Print: [3]
  29. }