aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-04-16 16:35:18 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-04-17 13:48:18 +0000
commitacc528cbf40c42eb112d2ce66c5f778bd4a397fb (patch)
tree1db39cbb9517df790fdf189d3bd1f59e4b7a8b0c /prog
parent18f6e127bf6e515fc3eee0936bde2415e676e160 (diff)
tools/syz-linter: check t.Logf/Errorf/Fatalf messages
Fix checking of Logf, it has string in 0-th arg. Add checking of t.Errorf/Fatalf.
Diffstat (limited to 'prog')
-rw-r--r--prog/alloc_test.go2
-rw-r--r--prog/collide_test.go4
-rw-r--r--prog/encoding_test.go4
-rw-r--r--prog/expr_test.go2
-rw-r--r--prog/heatmap_test.go8
-rw-r--r--prog/minimization_test.go2
-rw-r--r--prog/mutation_test.go8
-rw-r--r--prog/parse_test.go2
-rw-r--r--prog/prio_test.go2
-rw-r--r--prog/prog_test.go2
-rw-r--r--prog/rand_test.go4
-rw-r--r--prog/size_test.go2
-rw-r--r--prog/test_util.go8
13 files changed, 25 insertions, 25 deletions
diff --git a/prog/alloc_test.go b/prog/alloc_test.go
index c1d0317a5..24fef233d 100644
--- a/prog/alloc_test.go
+++ b/prog/alloc_test.go
@@ -92,6 +92,6 @@ func TestVmaAlloc(t *testing.T) {
for i := 0; i < 30; i++ {
size := r.rand(4) + 1
page := va.alloc(r, size)
- t.Logf("alloc(%v) = %3v-%3v\n", size, page, page+size)
+ t.Logf("alloc(%v) = %3v-%3v", size, page, page+size)
}
}
diff --git a/prog/collide_test.go b/prog/collide_test.go
index 0e29777a7..54ac156ab 100644
--- a/prog/collide_test.go
+++ b/prog/collide_test.go
@@ -73,7 +73,7 @@ r4 = dup(r3)
for i := 0; i < iters; i++ {
collided := AssignRandomAsync(p, r)
if !test.check(collided) {
- t.Fatalf("bad async assignment:\n%s\n", collided.Serialize())
+ t.Fatalf("bad async assignment:\n%s", collided.Serialize())
}
for _, call := range collided.Calls {
anyAsync = anyAsync || call.Props.Async
@@ -143,7 +143,7 @@ dup(r3)
}
serialized := string(woProps.Serialize())
if serialized != test.duplicated {
- t.Fatalf("expected:%s\ngot:%s\n", test.duplicated, serialized)
+ t.Fatalf("expected:%s\ngot:%s", test.duplicated, serialized)
}
}
// TODO: also test the `async` assignment.
diff --git a/prog/encoding_test.go b/prog/encoding_test.go
index bf4f708d1..608f94371 100644
--- a/prog/encoding_test.go
+++ b/prog/encoding_test.go
@@ -432,8 +432,8 @@ func testSerializeDeserialize(t *testing.T, p0 *Prog) ([]byte, []byte, bool) {
t.Fatal(err)
}
if !bytes.Equal(data0, data1) {
- t.Logf("PROG0:\n%s\n", p0.Serialize())
- t.Logf("PROG1:\n%s\n", p1.Serialize())
+ t.Logf("PROG0:\n%s", p0.Serialize())
+ t.Logf("PROG1:\n%s", p1.Serialize())
return data0, data1, false
}
return nil, nil, true
diff --git a/prog/expr_test.go b/prog/expr_test.go
index adff50c6a..8188436e1 100644
--- a/prog/expr_test.go
+++ b/prog/expr_test.go
@@ -36,7 +36,7 @@ func TestGenerateConditionalFields(t *testing.T) {
for _, first := range []int{0, 1} {
for _, second := range []int{0, 1} {
if !combinations[first][second] {
- t.Fatalf("Did not generate a combination f1=%v f2=%v", first, second)
+ t.Fatalf("did not generate a combination f1=%v f2=%v", first, second)
}
}
}
diff --git a/prog/heatmap_test.go b/prog/heatmap_test.go
index 585bc095c..62a0c45e5 100644
--- a/prog/heatmap_test.go
+++ b/prog/heatmap_test.go
@@ -64,7 +64,7 @@ func TestGenericHeatmap(t *testing.T) {
index := hm.ChooseLocation()
if !checkIndex(index, len(data), test.regions) {
hm.debugPrint(t, data, test.regions)
- t.Fatalf("selected index %d does not fall in a region\n", index)
+ t.Fatalf("selected index %d does not fall in a region", index)
}
}
}
@@ -100,7 +100,7 @@ func (hm *GenericHeatmap) debugPrint(t *testing.T, data []byte, regions []region
}
t.Logf("%8d: %x", j*granularity, data[j:end])
}
- t.Logf("\n")
+ t.Log("\n")
// Print selected regions in data.
sort.Slice(regions, func(i, j int) bool {
@@ -109,12 +109,12 @@ func (hm *GenericHeatmap) debugPrint(t *testing.T, data []byte, regions []region
for j, region := range regions {
t.Logf("region %4d: %8v - %8v", j, region.start, region.end)
}
- t.Logf("\n")
+ t.Log("\n")
// Print heatmap.
t.Logf("generic heatmap (total segment length %d)", hm.length)
for j, seg := range hm.segments {
t.Logf("segment %4d: %8v - %8v", j, seg.offset, seg.offset+seg.length)
}
- t.Logf("\n\n\n")
+ t.Log("\n\n\n")
}
diff --git a/prog/minimization_test.go b/prog/minimization_test.go
index f5b4c34d1..9b7652908 100644
--- a/prog/minimization_test.go
+++ b/prog/minimization_test.go
@@ -254,7 +254,7 @@ func TestMinimize(t *testing.T) {
p1, ci := Minimize(p, test.callIndex, false, test.pred)
res := p1.Serialize()
if string(res) != test.result {
- t.Fatalf("minimization produced wrong result #%v\norig:\n%v\nexpect:\n%v\ngot:\n%v\n",
+ t.Fatalf("minimization produced wrong result #%v\norig:\n%v\nexpect:\n%v\ngot:\n%v",
ti, test.orig, test.result, string(res))
}
if ci != test.resultCallIndex {
diff --git a/prog/mutation_test.go b/prog/mutation_test.go
index 29bf7a34a..14e80a73b 100644
--- a/prog/mutation_test.go
+++ b/prog/mutation_test.go
@@ -191,7 +191,7 @@ func TestSizeMutateArg(t *testing.T) {
limit := uint64(1<<bits - 1)
val := arg.(*ConstArg).Val
if val > limit {
- t.Fatalf("Invalid argument value: %d. (arg size: %d; max value: %d)", val, arg.Size(), limit)
+ t.Fatalf("invalid argument value: %d. (arg size: %d; max value: %d)", val, arg.Size(), limit)
}
})
}
@@ -207,7 +207,7 @@ func TestClone(t *testing.T) {
data := p.Serialize()
data1 := p1.Serialize()
if !bytes.Equal(data, data1) {
- t.Fatalf("program changed after clone\noriginal:\n%s\n\nnew:\n%s\n", data, data1)
+ t.Fatalf("program changed after clone\noriginal:\n%s\n\nnew:\n%s", data, data1)
}
}
}
@@ -226,7 +226,7 @@ func TestMutateRandom(t *testing.T) {
p1.Mutate(rs, 10, ct, nil, nil)
data := p.Serialize()
if !bytes.Equal(data0, data) {
- t.Fatalf("program changed after mutate\noriginal:\n%s\n\nnew:\n%s\n",
+ t.Fatalf("program changed after mutate\noriginal:\n%s\n\nnew:\n%s",
data0, data)
}
data1 := p1.Serialize()
@@ -234,7 +234,7 @@ func TestMutateRandom(t *testing.T) {
continue
}
if _, err := target.Deserialize(data1, NonStrict); err != nil {
- t.Fatalf("Deserialize failed after Mutate: %v\n%s", err, data1)
+ t.Fatalf("deserialize failed after mutate: %v\n%s", err, data1)
}
continue next
}
diff --git a/prog/parse_test.go b/prog/parse_test.go
index eddd03873..c1a6aa6aa 100644
--- a/prog/parse_test.go
+++ b/prog/parse_test.go
@@ -49,7 +49,7 @@ func TestParseMulti(t *testing.T) {
entries := target.ParseLog([]byte(execLog))
if len(entries) != 5 {
for i, ent := range entries {
- t.Logf("program #%v: %v\n", i, ent.P)
+ t.Logf("program #%v: %v", i, ent.P)
}
t.Fatalf("got %v programs, want 5", len(entries))
}
diff --git a/prog/prio_test.go b/prog/prio_test.go
index 60802657a..93555818e 100644
--- a/prog/prio_test.go
+++ b/prog/prio_test.go
@@ -63,7 +63,7 @@ func TestStaticPriorities(t *testing.T) {
}
// Checks that prio[callCreatesRes][callUsesRes] > prio[callUsesRes][callCreatesRes]
if count >= counter[call] {
- t.Fatalf("Too high priority for %s -> %s: %d vs %s -> %s: %d",
+ t.Fatalf("too high priority for %s -> %s: %d vs %s -> %s: %d",
call, referenceCall, count, referenceCall, call, counter[call])
}
}
diff --git a/prog/prog_test.go b/prog/prog_test.go
index 8da8d773c..d4301e1e7 100644
--- a/prog/prog_test.go
+++ b/prog/prog_test.go
@@ -87,7 +87,7 @@ func testSerialize(t *testing.T, verbose bool) {
t.Fatalf("different number of calls")
}
if !bytes.Equal(data, data1) {
- t.Fatalf("program changed after serialize/deserialize\noriginal:\n%s\n\nnew:\n%s\n", data, data1)
+ t.Fatalf("program changed after serialize/deserialize\noriginal:\n%s\n\nnew:\n%s", data, data1)
}
}
}
diff --git a/prog/rand_test.go b/prog/rand_test.go
index ef1d03390..00613d42a 100644
--- a/prog/rand_test.go
+++ b/prog/rand_test.go
@@ -110,7 +110,7 @@ func TestEnabledCalls(t *testing.T) {
}
for _, c := range p.Calls {
if _, ok := enabledCalls[c.Meta.Name]; !ok {
- t.Fatalf("program contains a syscall that is not enabled: %v\n", c.Meta.Name)
+ t.Fatalf("program contains a syscall that is not enabled: %v", c.Meta.Name)
}
}
}
@@ -234,7 +234,7 @@ func TestNoGenerate(t *testing.T) {
}
for _, c := range p.Calls {
if c.Meta.Attrs.NoGenerate {
- t.Fatalf("program contains a no_generate syscall: %v\n", c.Meta.Name)
+ t.Fatalf("program contains a no_generate syscall: %v", c.Meta.Name)
}
}
}
diff --git a/prog/size_test.go b/prog/size_test.go
index 5b49c437a..62f6237c1 100644
--- a/prog/size_test.go
+++ b/prog/size_test.go
@@ -18,7 +18,7 @@ func TestAssignSizeRandom(t *testing.T) {
target.assignSizesCall(call)
}
if data1 := p.Serialize(); !bytes.Equal(data0, data1) {
- t.Fatalf("different lens assigned, initial:\n%s\nnew:\n%s\n", data0, data1)
+ t.Fatalf("different lens assigned, initial:\n%s\nnew:\n%s", data0, data1)
}
p.Mutate(rs, 10, ct, nil, nil)
p.Serialize()
diff --git a/prog/test_util.go b/prog/test_util.go
index eb15539ea..fb45a8566 100644
--- a/prog/test_util.go
+++ b/prog/test_util.go
@@ -36,7 +36,7 @@ func TestDeserializeHelper(t *testing.T, OS, arch string, transform func(*Target
t.Errorf("both Err and Out are set")
}
if test.In == test.Out {
- t.Errorf("In and Out are equal, remove Out in such case\n%v", test.In)
+ t.Errorf("in and out are equal, remove Out in such case\n%v", test.In)
}
if test.Out == "" {
test.Out = test.In
@@ -49,7 +49,7 @@ func TestDeserializeHelper(t *testing.T, OS, arch string, transform func(*Target
}
if err != nil {
if wantErr == "" {
- t.Fatalf("deserialization failed with\n%s\ndata:\n%s\n",
+ t.Fatalf("deserialization failed with\n%s\ndata:\n%s",
err, test.In)
}
if !strings.Contains(err.Error(), wantErr) {
@@ -58,7 +58,7 @@ func TestDeserializeHelper(t *testing.T, OS, arch string, transform func(*Target
}
} else {
if wantErr != "" {
- t.Fatalf("deserialization should have failed with:\n%s\ndata:\n%s\n",
+ t.Fatalf("deserialization should have failed with:\n%s\ndata:\n%s",
wantErr, test.In)
}
if transform != nil {
@@ -72,7 +72,7 @@ func TestDeserializeHelper(t *testing.T, OS, arch string, transform func(*Target
// the verbose and non-verbose output don't match -- the strict parsing
// mode does not accept the non-verbose output as input.
if want != output && want != outputVerbose {
- t.Fatalf("wrong serialized data:\n%s\nexpect:\n%s\n", outputVerbose, want)
+ t.Fatalf("wrong serialized data:\n%s\nexpect:\n%s", outputVerbose, want)
}
p.SerializeForExec()
}