1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-28 13:48:49 +08:00
Dejan Mijic c966a7802d
Integrate manager service
Setup top-level glide dependencies file. Migrated all of the manager
service code into this repository. Fixed docker build procedure.
Extracted executable to the top-level.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 01:03:27 +02:00

66 lines
1.1 KiB
Go

package stack
import (
"runtime"
"testing"
)
func TestFindSigpanic(t *testing.T) {
t.Parallel()
sp := findSigpanic()
if got, want := sp.Name(), "runtime.sigpanic"; got != want {
t.Errorf("got == %v, want == %v", got, want)
}
}
func TestCaller(t *testing.T) {
t.Parallel()
c := Caller(0)
_, file, line, ok := runtime.Caller(0)
line--
if !ok {
t.Fatal("runtime.Caller(0) failed")
}
if got, want := c.file(), file; got != want {
t.Errorf("got file == %v, want file == %v", got, want)
}
if got, want := c.line(), line; got != want {
t.Errorf("got line == %v, want line == %v", got, want)
}
}
type fholder struct {
f func() CallStack
}
func (fh *fholder) labyrinth() CallStack {
for {
return fh.f()
}
panic("this line only needed for go 1.0")
}
func TestTrace(t *testing.T) {
t.Parallel()
fh := fholder{
f: func() CallStack {
cs := Trace()
return cs
},
}
cs := fh.labyrinth()
lines := []int{51, 41, 56}
for i, line := range lines {
if got, want := cs[i].line(), line; got != want {
t.Errorf("got line[%d] == %v, want line[%d] == %v", i, got, i, want)
}
}
}