]> Cypherpunks repositories - gostls13.git/commitdiff
internal/fuzz: use consistent log format
authorRoland Shoemaker <roland@golang.org>
Tue, 8 Jun 2021 00:25:21 +0000 (17:25 -0700)
committerRoland Shoemaker <roland@golang.org>
Tue, 8 Jun 2021 20:46:17 +0000 (20:46 +0000)
Match the existing "fuzzing, ..." logging style for debug logs, so that
processing everything is considerably simpler.

Change-Id: I4da4071700b3d9f8fb1ebf0c2de91ac693fd492f
Reviewed-on: https://go-review.googlesource.com/c/go/+/325876
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

src/go/build/deps_test.go
src/internal/fuzz/fuzz.go

index 2dc2939eec98634498a0bc31f6451cc3fa01bb19..67989d2e38d2028aee5a4b8435880a0ddaef84ce 100644 (file)
@@ -509,7 +509,7 @@ var depsRules = `
        FMT, flag, runtime/debug, runtime/trace, internal/sysinfo, math/rand
        < testing;
 
-       FMT, crypto/sha256, encoding/json, go/ast, go/parser, go/token, math/rand, encoding/hex, crypto/sha256, log
+       FMT, crypto/sha256, encoding/json, go/ast, go/parser, go/token, math/rand, encoding/hex, crypto/sha256
        < internal/fuzz;
 
        internal/fuzz, internal/testlog, runtime/pprof, regexp
index 572a0f04d25c8e4651fbf2e3bd790ccf6458e8f0..929f78bb177e92cfa33390c3f492bd5d20cf2f80 100644 (file)
@@ -14,7 +14,6 @@ import (
        "fmt"
        "io"
        "io/ioutil"
-       "log"
        "os"
        "path/filepath"
        "reflect"
@@ -240,7 +239,16 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
                                                }
                                        }
                                        if printDebugInfo() {
-                                               log.Printf("DEBUG new crasher, id: %s, parent: %s, gen: %d, size: %d, exec time: %s\n", result.entry.Name, result.entry.Parent, result.entry.Generation, len(result.entry.Data), result.entryDuration)
+                                               fmt.Fprintf(
+                                                       c.opts.Log,
+                                                       "DEBUG new crasher, elapsed: %s, id: %s, parent: %s, gen: %d, size: %d, exec time: %s\n",
+                                                       time.Since(c.startTime),
+                                                       result.entry.Name,
+                                                       result.entry.Parent,
+                                                       result.entry.Generation,
+                                                       len(result.entry.Data),
+                                                       result.entryDuration,
+                                               )
                                        }
                                        stop(err)
                                }
@@ -263,12 +271,31 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
                                                }
                                        }
                                        if printDebugInfo() {
-                                               log.Printf("DEBUG new interesting input, id: %s, parent: %s, gen: %d, new edges: %d, total edges: %d, size: %d, exec time: %s\n", result.entry.Name, result.entry.Parent, result.entry.Generation, newEdges, countEdges(c.coverageData), len(result.entry.Data), result.entryDuration)
+                                               fmt.Fprintf(
+                                                       c.opts.Log,
+                                                       "DEBUG new interesting input, elapsed: %s, id: %s, parent: %s, gen: %d, new edges: %d, total edges: %d, size: %d, exec time: %s\n",
+                                                       time.Since(c.startTime),
+                                                       result.entry.Name,
+                                                       result.entry.Parent,
+                                                       result.entry.Generation,
+                                                       newEdges,
+                                                       countEdges(c.coverageData),
+                                                       len(result.entry.Data),
+                                                       result.entryDuration,
+                                               )
                                        }
                                } else if c.coverageOnlyRun() {
                                        c.covOnlyInputs--
                                        if printDebugInfo() {
-                                               log.Printf("DEBUG processed an initial input, id: %s, new edges: %d, size: %d, exec time: %s\n", result.entry.Parent, newEdges, len(result.entry.Data), result.entryDuration)
+                                               fmt.Fprintf(
+                                                       c.opts.Log,
+                                                       "DEBUG processed an initial input, elapsed: %s, id: %s, new edges: %d, size: %d, exec time: %s\n",
+                                                       time.Since(c.startTime),
+                                                       result.entry.Parent,
+                                                       newEdges,
+                                                       len(result.entry.Data),
+                                                       result.entryDuration,
+                                               )
                                        }
                                        if c.covOnlyInputs == 0 {
                                                // The coordinator has finished getting a baseline for
@@ -277,12 +304,24 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err
                                                // to 0).
                                                c.interestingCount = 0
                                                if printDebugInfo() {
-                                                       log.Printf("DEBUG finished processing input corpus, entries: %d, initial coverage edges: %d\n", len(c.corpus.entries), countEdges(c.coverageData))
+                                                       fmt.Fprintf(
+                                                               c.opts.Log,
+                                                               "DEBUG finished processing input corpus, elapsed: %s, entries: %d, initial coverage edges: %d\n",
+                                                               time.Since(c.startTime),
+                                                               len(c.corpus.entries),
+                                                               countEdges(c.coverageData),
+                                                       )
                                                }
                                        }
                                } else {
                                        if printDebugInfo() {
-                                               log.Printf("DEBUG worker reported interesting input that doesn't expand coverage, id: %s, parent: %s\n", result.entry.Name, result.entry.Parent)
+                                               fmt.Fprintf(
+                                                       c.opts.Log,
+                                                       "DEBUG worker reported interesting input that doesn't expand coverage, elapsed: %s, id: %s, parent: %s\n",
+                                                       time.Since(c.startTime),
+                                                       result.entry.Name,
+                                                       result.entry.Parent,
+                                               )
                                        }
                                }
                        }