synchronize concurrent access to map in test

This commit is contained in:
Özgür Kesim 2020-01-16 10:50:06 +01:00
parent 29be1b5000
commit 509d6e5505

View File

@ -7,6 +7,7 @@ import (
"os/exec"
"regexp"
"strconv"
"sync"
"testing"
)
@ -35,9 +36,12 @@ func TestSimpleGDB(t *testing.T) {
}
scanner := NewScanner("_PyRuntime", "*python3*")
var m sync.Mutex
scanner.OnFound(func(pid int, offset uint64) error {
t.Logf("scanner setting pid %d to offset %x", pid, offset)
m.Lock()
ourResults[pid] = offset
m.Unlock()
return nil
})