mirror of
https://github.com/golang/go
synced 2024-11-18 09:04:49 -07:00
runtime/race: also unmap memory if TestNonGoMemory fails
Change-Id: I7ea150e4896fc9b2e3a6dbdd9a1c2b651e74b844 Reviewed-on: https://go-review.googlesource.com/c/go/+/428778 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
861885841d
commit
600db8a514
@ -19,11 +19,11 @@ func TestNonGoMemory(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to mmap memory: %v", err)
|
||||
}
|
||||
defer syscall.Munmap(data)
|
||||
p := (*uint32)(unsafe.Pointer(&data[0]))
|
||||
atomic.AddUint32(p, 1)
|
||||
(*p)++
|
||||
if *p != 2 {
|
||||
t.Fatalf("data[0] = %v, expect 2", *p)
|
||||
}
|
||||
syscall.Munmap(data)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user