The tests re-execute the test binary with CRASHHANDLER_TEST_MODE set; TestMain dispatches to a crash trigger that must never return. The parent asserts on the child's exit status and stderr.
(m *testing.M)
| 13 | // dispatches to a crash trigger that must never return. The parent asserts on |
| 14 | // the child's exit status and stderr. |
| 15 | func TestMain(m *testing.M) { |
| 16 | switch os.Getenv("CRASHHANDLER_TEST_MODE") { |
| 17 | case "": |
| 18 | os.Exit(m.Run()) |
| 19 | case "c-thread-segv": |
| 20 | // SIGSEGV on a C-created thread (the incident class: a DuckDB |
| 21 | // TaskScheduler thread faulting inside an extension). |
| 22 | TriggerCThreadSegfault() |
| 23 | case "cgo-call-segv": |
| 24 | // SIGSEGV inside a C call made from a Go goroutine (a DuckDB call |
| 25 | // crashing under cgo). |
| 26 | TriggerCgoCallSegfault() |
| 27 | case "go-nil-deref": |
| 28 | // A plain Go nil dereference must still produce a normal Go panic, |
| 29 | // not a native crash report. |
| 30 | var p *int |
| 31 | _ = *p //nolint:govet |
| 32 | } |
| 33 | // Every mode above must have killed the process. |
| 34 | os.Exit(97) |
| 35 | } |
| 36 | |
| 37 | // runCrashChild re-runs the test binary in the given crash mode and returns |
| 38 | // (stderr, waitStatus). |
nothing calls this directly
no test coverage detected