style: modernize the new tooling code to match the repo conventions

This commit is contained in:
2026-08-29 16:15:14 +02:00
parent 9beff4ae85
commit 15e8b88d32
3 changed files with 19 additions and 23 deletions
+4 -4
View File
@@ -80,7 +80,7 @@ bodies, place the file in the kernel's package, and run it in CI.
fmt.Fprintf(&out, "func Test%sDifferential(t *testing.T) {\n", strings.ToUpper(name[:1])+name[1:])
fmt.Fprintf(&out, "\trng := rand.New(rand.NewSource(1))\n")
fmt.Fprintf(&out, "\tfor iter := 0; iter < 1000; iter++ {\n")
fmt.Fprintf(&out, "\tfor range 1000 {\n")
// Seed two independent argument sets per iteration: the kernel runs
// on set A, the portable reference on set B, so in-place writes
// through pointer/slice arguments cannot contaminate the other side.
@@ -97,11 +97,11 @@ bodies, place the file in the kernel's package, and run it in CI.
fmt.Fprintf(&out, "\t\tgot := %s(%s)\n", name, strings.Join(aArgs, ", "))
fmt.Fprintf(&out, "\t\twant := %sPortable(%s)\n", name, strings.Join(bArgs, ", "))
fmt.Fprintf(&out, "\t\tif !bytes.Equal(outputBytes(got), outputBytes(want)) {\n")
fmt.Fprintf(&out, "\t\t\tt.Fatalf(\"iter %%d: kernel diverges from the portable spec\", iter)\n")
fmt.Fprintf(&out, "\t\t\tt.Fatalf(\"kernel diverges from the portable spec (seed 1, deterministic)\")\n")
fmt.Fprintf(&out, "\t\t}\n")
for _, s := range sliceNames {
fmt.Fprintf(&out, "\t\tif !bytes.Equal(outputBytes(%sA), outputBytes(%sB)) {\n", s, s)
fmt.Fprintf(&out, "\t\t\tt.Fatalf(\"iter %%d: kernel mutated %%s differently\", iter, %q)\n", s)
fmt.Fprintf(&out, "\t\t\tt.Fatalf(\"kernel mutated %%q differently (seed 1, deterministic)\", %q)\n", s)
fmt.Fprintf(&out, "\t\t}\n")
}
fmt.Fprintf(&out, "\t}\n}\n\n")
@@ -334,7 +334,7 @@ func outputBytes(v any) []byte {
return b
case int:
b := make([]byte, 8)
for i := 0; i < 8; i++ {
for i := range 8 {
b[i] = byte(uint64(t) >> (8 * i))
}
return b