diff options
Diffstat (limited to 'src/pkg/runtime/runtime_test.go')
| -rw-r--r-- | src/pkg/runtime/runtime_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pkg/runtime/runtime_test.go b/src/pkg/runtime/runtime_test.go index c673275620..83489480da 100644 --- a/src/pkg/runtime/runtime_test.go +++ b/src/pkg/runtime/runtime_test.go @@ -10,9 +10,11 @@ import ( "os" "os/exec" . "runtime" + "runtime/debug" "strconv" "strings" "testing" + "unsafe" ) var errf error @@ -131,3 +133,19 @@ func TestRuntimeGogoBytes(t *testing.T) { func TestStopCPUProfilingWithProfilerOff(t *testing.T) { SetCPUProfileRate(0) } + +func TestSetPanicOnFault(t *testing.T) { + old := debug.SetPanicOnFault(true) + defer debug.SetPanicOnFault(old) + + defer func() { + if err := recover(); err == nil { + t.Fatalf("did not find error in recover") + } + }() + + var p *int + p = (*int)(unsafe.Pointer(^uintptr(0))) + println(*p) + t.Fatalf("still here - should have faulted") +} |
