MCPcopy Index your code
hub / github.com/maruel/panicparse / TestAugment

Function TestAugment

stack/source_test.go:29–1420  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27var allPlatforms goarchList = nil
28
29func TestAugment(t *testing.T) {
30 t.Parallel()
31
32 gm := map[string]string{"/root": "main"}
33 newCallSrc := func(f string, a Args, s string, l int) Call {
34 c := newCall(f, a, s, l)
35 // Simulate findRoots().
36 if !c.updateLocations(goroot, goroot, gm, gopaths) {
37 t.Fatalf("c.updateLocations(%v, %v, %v, %v) failed on %s", goroot, goroot, gm, gopaths, s)
38 }
39 return c
40 }
41
42 // For test case "negative int32".
43 negInt := uint64(4294967173)
44 negPtr := false
45 if bits.UintSize == 64 {
46 negInt = 828928688005
47 negPtr = true
48 }
49
50 type testCase struct {
51 name string
52 input string
53 // Due to inlining, the stack trace may (it depends on tool chain version)
54 // not contain much information about the arguments and shows as elided.
55 // Non-pointer call may show an elided argument, while there was no
56 // argument listed before.
57 mayBeInlined bool
58 // archBlock lists the CPU architectures to skip this test case on.
59 //
60 // Many test are hard to parse in 32 bits. Eventually we should fix these
61 // but I don't have time for this.
62 //
63 // The list is based on https://github.com/maruel/panicparse/issues/80.
64 // I was able to locally reproduce amd64 and 386 but not the rest.
65 archBlock goarchList
66 want Stack
67 }
68 data := []testCase{
69 {
70 "local function doesn't interfere",
71 `func main() {
72 f("yo")
73 }
74 func f(s string) {
75 a := func(i int) int {
76 return 1 + i
77 }
78 _ = a(3)
79 panic("ooh")
80 }`,
81 // The function became inlinable in go 1.17.
82 true,
83 goarchList{"arm", "arm64", "ppc64le", "riscv64"},
84 Stack{
85 Calls: []Call{
86 newCallSrc(

Callers

nothing calls this directly

Calls 4

newCallFunction · 0.85
getCrashFunction · 0.85
testAugmentCommonFunction · 0.85
updateLocationsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…