1// fgprof is a sampling Go profiler that allows you to analyze On-CPU as well
2// as [Off-CPU](http://www.brendangregg.com/offcpuanalysis.html) (e.g. I/O)
3// time together.
4package fgprof
5
6import (
7	"bytes"
8	"strings"
9	"testing"
10	"time"
11)
12
13// TestStart is a simple smoke test that checks that the profiler doesn't
14// produce errors and catches the TestStart function itself. It'd be nice to
15// add better testing in the future, but writing test cases for a profiler is
16// a little tricky : ).
17func TestStart(t *testing.T) {
18	out := &bytes.Buffer{}
19	stop := Start(out, FormatFolded)
20	time.Sleep(100 * time.Millisecond)
21	if err := stop(); err != nil {
22		t.Fatal(err)
23	}
24
25	if !strings.Contains(out.String(), "fgprof.TestStart") {
26		t.Fatalf("invalid output:\n%s", out)
27	}
28}
29