package stacktrace

import "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("expteced function %q but recevied %q", expected, frame.Function)
	}
	if expected := "github.com/opencontainers/runc/libcontainer/stacktrace"; 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)
	}
}

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("expteced function %q but recevied %q", expected, frame.Function)
	}
	expected := "github.com/opencontainers/runc/libcontainer/stacktrace"
	if !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)
	}
}

Fix to allow for build in different path
Fix to allow for build in different path

The path in the stacktrace might not be:
  "github.com/opencontainers/runc/libcontainer/stacktrace"
For example, for me its:
  "_/go/src/github.com/opencontainers/runc/libcontainer/stacktrace"
so I changed the check to make sure the tail end of the path matches instead
of the entire thing

Signed-off-by: Doug Davis <ff3bde741799c0eff815b83a54eda3fc494df54f@us.ibm.com>
