MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestMain

Function TestMain

internal/crashhandler/crashhandler_test.go:15–35  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

13// dispatches to a crash trigger that must never return. The parent asserts on
14// the child's exit status and stderr.
15func 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).

Callers

nothing calls this directly

Calls 3

TriggerCThreadSegfaultFunction · 0.85
TriggerCgoCallSegfaultFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected