test(asm): parse once and assemble twice in the fuzz body

Assisted-by: GLM 5.3 Flash
This commit is contained in:
petrbalvin committed 2026-10-07 01:14:58 +02:00
1 parent 7878112b93
commit de2f28504a
1 file changed
+6 -9
+6 -9
View File
@@ -105,15 +105,12 @@ func FuzzAssembleAMD64(f *testing.F) {
} }
return return
} }
// Determinism: a second parse-and-assemble from scratch must produce // Determinism: a second assembly of the same file must produce the
// the same bytes, which also catches the assembler mutating the // same bytes. One parse serves both runs, so any mutation the
// syntax tree it was handed. // assembler makes to the syntax tree it was handed shows up as
file2, _ := parser.ParseWithOptions("fuzz_amd64.s", src, // differing bytes, and the workers' footprint under the shared
parser.Options{Expand: true, IncludeDirs: fuzzIncludeDirs}) // memory fence stays that of a single parse.
if file2 == nil { img2, err2 := AssembleFile(file)
t.Fatal("the second ParseWithOptions returned a nil file")
}
img2, err2 := AssembleFile(file2)
if err2 != nil { if err2 != nil {
t.Fatalf("the second assembly failed where the first succeeded: %v", err2) t.Fatalf("the second assembly failed where the first succeeded: %v", err2)
} }