Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -393,6 +393,52 @@ func TestRunCorpusAuditGOOS(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRunCorpusAuditBuildConstraint covers the //go:build classification end
|
||||
// to end: a generic-named file whose constraint admits one target is
|
||||
// attempted there alone (cpu_x86.s on amd64), and a file whose constraint
|
||||
// admits none of the four targets is never attempted (the msan and
|
||||
// goexperiment trees).
|
||||
func TestRunCorpusAuditBuildConstraint(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
write := func(name, src string) {
|
||||
t.Helper()
|
||||
if err := os.WriteFile(filepath.Join(dir, name), []byte(src), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
write("x86.s", "//go:build 386 || amd64\n\nTEXT \xc2\xb7f(SB), NOSPLIT, $0\n\tRET\n")
|
||||
write("racey.s", "//go:build race\n\nTEXT \xc2\xb7r(SB), NOSPLIT, $0\n\tRET\n")
|
||||
write("plain.s", "TEXT \xc2\xb7p(SB), NOSPLIT, $0\n\tRET\n")
|
||||
|
||||
stats, err := runCorpusAudit(dir, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("runCorpusAudit: %v", err)
|
||||
}
|
||||
tally := func(name string) *corpusTally {
|
||||
for i, tg := range stats.targets {
|
||||
if tg.name == name {
|
||||
return stats.tallies[i]
|
||||
}
|
||||
}
|
||||
t.Fatalf("no tally for %s", name)
|
||||
return nil
|
||||
}
|
||||
if stats.narrowed != 1 || stats.excluded != 1 || stats.generic != 1 {
|
||||
t.Errorf("buckets = narrowed %d, excluded %d, generic %d; want 1, 1, 1", stats.narrowed, stats.excluded, stats.generic)
|
||||
}
|
||||
if a := tally("amd64"); a.attempted != 2 || a.assembled != 2 {
|
||||
t.Errorf("amd64 = %d/%d, want 2/2 (x86.s and plain.s)", a.assembled, a.attempted)
|
||||
}
|
||||
for _, name := range []string{"arm64", "riscv64", "loong64"} {
|
||||
if a := tally(name); a.attempted != 1 || a.assembled != 1 {
|
||||
t.Errorf("%s = %d/%d, want 1/1 (plain.s only)", name, a.assembled, a.attempted)
|
||||
}
|
||||
}
|
||||
if stats.full != 2 {
|
||||
t.Errorf("full = %d, want 2 (x86.s over its one target, plain.s over all four)", stats.full)
|
||||
}
|
||||
}
|
||||
|
||||
// TestGenerateGoAsmHeaderRuntime pins the generator against the real thing:
|
||||
// the runtime package of the ambient toolchain, whose header the toolchain's
|
||||
// own -asmhdr output was sampled from. Skipped in short mode: it type-checks
|
||||
|
||||
Reference in New Issue
Block a user