synchronize concurrent access to map in test
This commit is contained in:
parent
29be1b5000
commit
509d6e5505
@ -7,6 +7,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,9 +36,12 @@ func TestSimpleGDB(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scanner := NewScanner("_PyRuntime", "*python3*")
|
scanner := NewScanner("_PyRuntime", "*python3*")
|
||||||
|
var m sync.Mutex
|
||||||
scanner.OnFound(func(pid int, offset uint64) error {
|
scanner.OnFound(func(pid int, offset uint64) error {
|
||||||
t.Logf("scanner setting pid %d to offset %x", pid, offset)
|
t.Logf("scanner setting pid %d to offset %x", pid, offset)
|
||||||
|
m.Lock()
|
||||||
ourResults[pid] = offset
|
ourResults[pid] = offset
|
||||||
|
m.Unlock()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user