Skip to content

Commit

Permalink
lower case beginning for all error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
zimmski committed Jul 27, 2014
1 parent 2af6de3 commit 292d769
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 143 deletions.
32 changes: 16 additions & 16 deletions bin/tavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var opts struct {

Validate struct {
InputFile flags.Filename `long:"input-file" description:"Input file which gets parsed and validated via the format file" required:"true"`
} `command:"validate" description:"Validate the given format file"`
} `command:"validate" description:"Validate the given input file"`
}

type FuzzFilter string
Expand Down Expand Up @@ -188,7 +188,7 @@ func checkArguments() string {
}
}

log.Infof("Using seed %d", opts.Global.Seed)
log.Infof("using seed %d", opts.Global.Seed)

return p.Active.Name
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func applyFilters(filterNames []FuzzFilter, doc token.Token) token.Token {

filters = append(filters, filt)

log.Infof("Using %s fuzzing filter", name)
log.Infof("using %s fuzzing filter", name)
}

doc, err = fuzzFilter.ApplyFilters(filters, doc)
Expand All @@ -246,7 +246,7 @@ func applyFilters(filterNames []FuzzFilter, doc token.Token) token.Token {
func main() {
command := checkArguments()

log.Infof("Open file %s", opts.Format.FormatFile)
log.Infof("open file %s", opts.Format.FormatFile)

file, err := os.Open(string(opts.Format.FormatFile))
if err != nil {
Expand All @@ -259,7 +259,7 @@ func main() {
exitError("cannot parse tavor file: %v", err)
}

log.Info("Format file is valid")
log.Info("format file is valid")

if opts.Format.PrintInternal {
tavor.PrettyPrintInternalTree(os.Stdout, doc)
Expand All @@ -275,14 +275,14 @@ func main() {
case "fuzz":
doc = applyFilters(opts.Fuzz.Filters, doc)

log.Infof("Counted %d overall permutations", doc.PermutationsAll())
log.Infof("counted %d overall permutations", doc.PermutationsAll())

strat, err := fuzzStrategy.New(string(opts.Fuzz.Strategy), doc)
if err != nil {
exitError(err.Error())
}

log.Infof("Using %s fuzzing strategy", opts.Fuzz.Strategy)
log.Infof("using %s fuzzing strategy", opts.Fuzz.Strategy)

ch, err := strat.Fuzz(r)
if err != nil {
Expand All @@ -305,7 +305,7 @@ func main() {
}
}

log.Debug("Result:")
log.Debug("result:")
fmt.Print(doc.String())
fmt.Print(opts.Fuzz.ResultSeparator)
} else {
Expand All @@ -314,7 +314,7 @@ func main() {

file := fmt.Sprintf("%s%x%s", folder, sum, opts.Fuzz.ResultExtensions)

log.Infof("Write result to %s", file)
log.Infof("write result to %s", file)

if err := ioutil.WriteFile(file, []byte(out), 0644); err != nil {
exitError("error writing to %s: %v", file, err)
Expand Down Expand Up @@ -343,9 +343,9 @@ func main() {
errs := parser.ParseInternal(doc, input)

if len(errs) == 0 {
log.Info("Input file is valid")
log.Info("input file is valid")
} else {
log.Info("Input file is invalid")
log.Info("input file is invalid")

for _, err := range errs {
log.Error(err)
Expand All @@ -360,7 +360,7 @@ func main() {
exitError(err.Error())
}

log.Infof("Using %s reducing strategy", opts.Reduce.Strategy)
log.Infof("using %s reducing strategy", opts.Reduce.Strategy)

contin, feedback, err := strat.Reduce()
if err != nil {
Expand All @@ -370,7 +370,7 @@ func main() {
readCLI := bufio.NewReader(os.Stdin)

for i := range contin {
log.Debug("Result:")
log.Debug("result:")
fmt.Print(doc.String())
fmt.Print(opts.Reduce.ResultSeparator)

Expand All @@ -396,14 +396,14 @@ func main() {
contin <- i
}

log.Info("Reduced to minimum")
log.Info("reduced to minimum")

log.Debug("Result:")
log.Debug("result:")
fmt.Print(doc.String())
fmt.Print(opts.Reduce.ResultSeparator)
}
default:
exitError("Unknown command %q", command)
exitError("unknown command %q", command)
}

os.Exit(returnOk)
Expand Down
28 changes: 14 additions & 14 deletions fuzz/strategy/allpermutations.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *AllPermutationsStrategy) getTree(root token.Token, fromChildren bool) [
}

func (s *AllPermutationsStrategy) setPermutation(tok token.Token, permutation int) {
log.Debugf("Set %#v(%p) to permutation %d", tok, tok, permutation)
log.Debugf("set %#v(%p) to permutation %d", tok, tok, permutation)

if err := tok.Permutation(permutation); err != nil {
panic(err)
Expand All @@ -82,25 +82,25 @@ func (s *AllPermutationsStrategy) setPermutation(tok token.Token, permutation in
func (s *AllPermutationsStrategy) Fuzz(r rand.Rand) (chan struct{}, error) {
if tavor.LoopExists(s.root) {
return nil, &StrategyError{
Message: "Found endless loop in graph. Cannot proceed.",
Message: "found endless loop in graph. Cannot proceed.",
Type: StrategyErrorEndlessLoopDetected,
}
}

continueFuzzing := make(chan struct{})

go func() {
log.Debug("Start all permutations routine")
log.Debug("start all permutations routine")

tree := s.getTree(s.root, false)

log.Debug("Start fuzzing step")
log.Debug("start fuzzing step")

if contin, _ := s.fuzz(continueFuzzing, tree, false); !contin {
return
}

log.Debug("Finished fuzzing.")
log.Debug("finished fuzzing.")

close(continueFuzzing)
}()
Expand All @@ -109,7 +109,7 @@ func (s *AllPermutationsStrategy) Fuzz(r rand.Rand) (chan struct{}, error) {
}

func (s *AllPermutationsStrategy) fuzz(continueFuzzing chan struct{}, tree []allPermutationsLevel, justastep bool) (bool, bool) {
log.Debugf("Fuzzing level %d->%#v", len(tree), tree)
log.Debugf("fuzzing level %d->%#v", len(tree), tree)

STEP:
for {
Expand All @@ -126,7 +126,7 @@ STEP:

log.Debugf("PERMUTATE after child step")
} else {
log.Debugf("Permute %d->%#v", 0, tree[0])
log.Debugf("permute %d->%#v", 0, tree[0])

if tree[0].permutation != 1 {
s.setPermutation(tree[0].token, tree[0].permutation)
Expand Down Expand Up @@ -158,14 +158,14 @@ STEP:

if tree[0].permutation > tree[0].maxPermutations {
for i := 0; i < len(tree); i++ {
log.Debugf("Check %d vs %d for %#v", tree[i].permutation, tree[i].maxPermutations, tree[i])
log.Debugf("check %d vs %d for %#v", tree[i].permutation, tree[i].maxPermutations, tree[i])
}

i := 0

for {
if i == len(tree)-1 {
log.Debugf("Done with fuzzing this level because %#v", tree)
log.Debugf("done with fuzzing this level because %#v", tree)

break STEP
}
Expand Down Expand Up @@ -205,7 +205,7 @@ STEP:
tree[j].children = s.getTree(tree[j].token, true)
}

log.Debugf("Permute %d->%#v", i, tree[i])
log.Debugf("permute %d->%#v", i, tree[i])

s.setPermutation(tree[i].token, tree[i].permutation)
tree[i].children = s.getTree(tree[i].token, true)
Expand Down Expand Up @@ -233,19 +233,19 @@ STEP:
func (s *AllPermutationsStrategy) nextStep(continueFuzzing chan struct{}) bool {
s.resetResetTokens()

log.Debug("Done with fuzzing step")
log.Debug("done with fuzzing step")

// done with this fuzzing step
continueFuzzing <- struct{}{}

// wait until we are allowed to continue
if _, ok := <-continueFuzzing; !ok {
log.Debug("Fuzzing channel closed from outside")
log.Debug("fuzzing channel closed from outside")

return false
}

log.Debug("Start fuzzing step")
log.Debug("start fuzzing step")

return true
}
Expand All @@ -260,7 +260,7 @@ func (s *AllPermutationsStrategy) resetResetTokens() {

switch tok := v.(type) {
case token.ResetToken:
log.Debugf("Reset %#v(%p)", tok, tok)
log.Debugf("reset %#v(%p)", tok, tok)

tok.Reset()
}
Expand Down
28 changes: 14 additions & 14 deletions fuzz/strategy/almostallpermutations.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *AlmostAllPermutationsStrategy) getLevel(root token.Token, fromChildren
func (s *AlmostAllPermutationsStrategy) Fuzz(r rand.Rand) (chan struct{}, error) {
if tavor.LoopExists(s.root) {
return nil, &StrategyError{
Message: "Found endless loop in graph. Cannot proceed.",
Message: "found endless loop in graph. Cannot proceed.",
Type: StrategyErrorEndlessLoopDetected,
}
}
Expand All @@ -99,12 +99,12 @@ func (s *AlmostAllPermutationsStrategy) Fuzz(r rand.Rand) (chan struct{}, error)
s.resetedLookup = make(map[token.Token]int)

go func() {
log.Debug("Start almost all permutations routine")
log.Debug("start almost all permutations routine")

level := s.getLevel(s.root, false)

if len(level) != 0 {
log.Debug("Start fuzzing step")
log.Debug("start fuzzing step")

if !s.fuzz(continueFuzzing, level) {
return
Expand All @@ -113,15 +113,15 @@ func (s *AlmostAllPermutationsStrategy) Fuzz(r rand.Rand) (chan struct{}, error)

s.resetResetTokens()

log.Debug("Done with fuzzing step")
log.Debug("done with fuzzing step")

// done with the last fuzzing step
continueFuzzing <- struct{}{}

log.Debug("Finished fuzzing. Wait till the outside is ready to close.")
log.Debug("finished fuzzing. Wait till the outside is ready to close.")

if _, ok := <-continueFuzzing; ok {
log.Debug("Close fuzzing channel")
log.Debug("close fuzzing channel")

close(continueFuzzing)
}
Expand All @@ -140,7 +140,7 @@ func (s *AlmostAllPermutationsStrategy) resetResetTokens() {

switch tok := v.(type) {
case token.ResetToken:
log.Debugf("Reset %#v(%p)", tok, tok)
log.Debugf("reset %#v(%p)", tok, tok)

tok.Reset()
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func (s *AlmostAllPermutationsStrategy) setTokenPermutation(tok token.Token, per
}

func (s *AlmostAllPermutationsStrategy) fuzz(continueFuzzing chan struct{}, level []almostAllPermutationsLevel) bool {
log.Debugf("Fuzzing level %d->%#v", len(level), level)
log.Debugf("fuzzing level %d->%#v", len(level), level)

last := len(level) - 1

Expand All @@ -179,7 +179,7 @@ STEP:
for i := range level {
if level[i].permutation > level[i].maxPermutations {
if i <= last {
log.Debugf("Max reached redo everything <= %d and increment next", i)
log.Debugf("max reached redo everything <= %d and increment next", i)

level[i+1].permutation++
s.setTokenPermutation(level[i+1].token, level[i+1].permutation)
Expand All @@ -195,7 +195,7 @@ STEP:
continue STEP
}

log.Debugf("Permute %d->%#v", i, level[i])
log.Debugf("permute %d->%#v", i, level[i])

s.setTokenPermutation(level[i].token, level[i].permutation)

Expand Down Expand Up @@ -224,27 +224,27 @@ STEP:
}
}
if !found {
log.Debug("Done with fuzzing this level")
log.Debug("done with fuzzing this level")

break STEP
}
}

s.resetResetTokens()

log.Debug("Done with fuzzing step")
log.Debug("done with fuzzing step")

// done with this fuzzing step
continueFuzzing <- struct{}{}

// wait until we are allowed to continue
if _, ok := <-continueFuzzing; !ok {
log.Debug("Fuzzing channel closed from outside")
log.Debug("fuzzing channel closed from outside")

return false
}

log.Debug("Start fuzzing step")
log.Debug("start fuzzing step")

s.resetedLookup = make(map[token.Token]int)
}
Expand Down
Loading

0 comments on commit 292d769

Please sign in to comment.