File: capture_test.go

package info (click to toggle)
runc 1.0.0~rc93%2Bds1-5%2Bdeb11u5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,760 kB
  • sloc: sh: 1,679; ansic: 1,050; makefile: 139
file content (31 lines) | stat: -rw-r--r-- 820 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package stacktrace

import (
	"strings"
	"testing"
)

func captureFunc() Stacktrace {
	return Capture(0)
}

func TestCaptureTestFunc(t *testing.T) {
	stack := captureFunc()

	if len(stack.Frames) == 0 {
		t.Fatal("expected stack frames to be returned")
	}

	// the first frame is the caller
	frame := stack.Frames[0]
	if expected := "captureFunc"; frame.Function != expected {
		t.Fatalf("expected function %q but received %q", expected, frame.Function)
	}
	// captureFunc is inlined in gccgo, so don't expect the full package path
	if expected := "stacktrace"; !strings.HasSuffix(frame.Package, expected) {
		t.Fatalf("expected package %q but received %q", expected, frame.Package)
	}
	if expected := "capture_test.go"; frame.File != expected {
		t.Fatalf("expected file %q but received %q", expected, frame.File)
	}
}