github.com/GuanceCloud/cliutils@v1.1.21/pprofparser/service/parsing/pprof_test.go (about) 1 package parsing 2 3 import ( 4 "fmt" 5 "io" 6 "os" 7 "testing" 8 9 "github.com/GuanceCloud/cliutils/testutil" 10 "github.com/google/pprof/profile" 11 ) 12 13 func TestNewDecompressor(t *testing.T) { 14 15 f, err := os.Open("testdata/auto.pprof.lz4") 16 17 testutil.Ok(t, err) 18 19 rc := NewDecompressor(f) 20 21 prof, err := profile.Parse(rc) 22 23 testutil.Ok(t, err) 24 25 fmt.Println(len(prof.Sample)) 26 27 buf := make([]byte, 1) 28 _, err = f.Read(buf) 29 testutil.Equals(t, io.EOF, err) 30 31 err = rc.Close() 32 testutil.Ok(t, err) 33 34 _, err = f.Read(buf) 35 fmt.Println(err) 36 testutil.NotOk(t, err, "expect err, got nil") 37 38 }