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
}
// Determinism: a second parse-and-assemble from scratch must produce
// the same bytes, which also catches the assembler mutating the
// syntax tree it was handed.
file2, _ := parser.ParseWithOptions("fuzz_amd64.s", src,
parser.Options{Expand: true, IncludeDirs: fuzzIncludeDirs})
if file2 == nil {
t.Fatal("the second ParseWithOptions returned a nil file")
}
img2, err2 := AssembleFile(file2)
// Determinism: a second assembly of the same file must produce the
// same bytes. One parse serves both runs, so any mutation the
// assembler makes to the syntax tree it was handed shows up as
// differing bytes, and the workers' footprint under the shared
// memory fence stays that of a single parse.
img2, err2 := AssembleFile(file)
if err2 != nil {
t.Fatalf("the second assembly failed where the first succeeded: %v", err2)
}