test: enable debug testing

This commit is contained in:
Li Jie
2024-11-26 14:39:29 +08:00
parent 954cc0e8bc
commit 43c4a3bfdc
5 changed files with 26 additions and 47 deletions

View File

@@ -107,32 +107,12 @@ func Pkg(t *testing.T, pkgPath, outFile string) {
}
}
func isDbgSymEnabled(flagsFile string) bool {
data, err := os.ReadFile(flagsFile)
if err != nil {
return false
}
toks := strings.Split(strings.Join(strings.Split(string(data), "\n"), " "), " ")
for _, tok := range toks {
if tok == "-dbg" {
return true
}
}
return false
}
func testFrom(t *testing.T, pkgDir, sel string) {
if sel != "" && !strings.Contains(pkgDir, sel) {
return
}
log.Println("Parsing", pkgDir)
out := pkgDir + "/out.ll"
dbg := isDbgSymEnabled(pkgDir + "/flags.txt")
if dbg {
cl.EnableDebugSymbols(true)
defer cl.EnableDebugSymbols(false)
cl.DebugSymbols() // just for coverage
}
b, err := os.ReadFile(out)
if err != nil {
t.Fatal("ReadFile failed:", err)

View File

@@ -57,15 +57,10 @@ func SetDebug(dbgFlags dbgFlags) {
debugGoSSA = (dbgFlags & DbgFlagGoSSA) != 0
}
// EnableDebugSymbols enables debug symbols.
func EnableDebugSymbols(b bool) {
debugSymbols = b
}
func DebugSymbols() bool {
return debugSymbols
}
// -----------------------------------------------------------------------------
type instrOrValue interface {