summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pkg
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2019-01-10 10:57:50 +0100
committerOndrej Fabry <ofabry@cisco.com>2019-01-10 11:05:35 +0100
commit08266e35878f198e2fa59fcfc9f0fc3a4b1dfbf5 (patch)
tree1269acfc3bf6fdd47414eb64da3ecad4865e37d6 /vendor/github.com/pkg
parent3ef6f210edcf7dd753733d46ec3f2dd5dc795b61 (diff)
Add support for string types
- strings are now generated as two fields for length and string itself - aliases are now sorted by name to prevent generating different code - dependencies are now managed by dep - binapi files are regenerated using VPP 19.01-rc0~622-g7b01e9e8 - old stats binary api has been deprecated and removed from VPP Change-Id: Ieb8515c73021339a45f407386f8e3d87dcf4469e Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'vendor/github.com/pkg')
-rw-r--r--vendor/github.com/pkg/profile/example_test.go58
-rw-r--r--vendor/github.com/pkg/profile/profile_test.go330
-rw-r--r--vendor/github.com/pkg/profile/trace_test.go8
3 files changed, 0 insertions, 396 deletions
diff --git a/vendor/github.com/pkg/profile/example_test.go b/vendor/github.com/pkg/profile/example_test.go
deleted file mode 100644
index 98a54b5..0000000
--- a/vendor/github.com/pkg/profile/example_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package profile_test
-
-import (
- "flag"
- "os"
-
- "github.com/pkg/profile"
-)
-
-func ExampleStart() {
- // start a simple CPU profile and register
- // a defer to Stop (flush) the profiling data.
- defer profile.Start().Stop()
-}
-
-func ExampleCPUProfile() {
- // CPU profiling is the default profiling mode, but you can specify it
- // explicitly for completeness.
- defer profile.Start(profile.CPUProfile).Stop()
-}
-
-func ExampleMemProfile() {
- // use memory profiling, rather than the default cpu profiling.
- defer profile.Start(profile.MemProfile).Stop()
-}
-
-func ExampleMemProfileRate() {
- // use memory profiling with custom rate.
- defer profile.Start(profile.MemProfileRate(2048)).Stop()
-}
-
-func ExampleProfilePath() {
- // set the location that the profile will be written to
- defer profile.Start(profile.ProfilePath(os.Getenv("HOME"))).Stop()
-}
-
-func ExampleNoShutdownHook() {
- // disable the automatic shutdown hook.
- defer profile.Start(profile.NoShutdownHook).Stop()
-}
-
-func ExampleStart_withFlags() {
- // use the flags package to selectively enable profiling.
- mode := flag.String("profile.mode", "", "enable profiling mode, one of [cpu, mem, mutex, block]")
- flag.Parse()
- switch *mode {
- case "cpu":
- defer profile.Start(profile.CPUProfile).Stop()
- case "mem":
- defer profile.Start(profile.MemProfile).Stop()
- case "mutex":
- defer profile.Start(profile.MutexProfile).Stop()
- case "block":
- defer profile.Start(profile.BlockProfile).Stop()
- default:
- // do nothing
- }
-}
diff --git a/vendor/github.com/pkg/profile/profile_test.go b/vendor/github.com/pkg/profile/profile_test.go
deleted file mode 100644
index e33012c..0000000
--- a/vendor/github.com/pkg/profile/profile_test.go
+++ /dev/null
@@ -1,330 +0,0 @@
-package profile
-
-import (
- "bufio"
- "bytes"
- "io"
- "io/ioutil"
- "os"
- "os/exec"
- "path/filepath"
- "strings"
- "testing"
-)
-
-type checkFn func(t *testing.T, stdout, stderr []byte, err error)
-
-func TestProfile(t *testing.T) {
- f, err := ioutil.TempFile("", "profile_test")
- if err != nil {
- t.Fatal(err)
- }
- defer os.Remove(f.Name())
-
- var profileTests = []struct {
- name string
- code string
- checks []checkFn
- }{{
- name: "default profile (cpu)",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- defer profile.Start().Stop()
-}
-`,
- checks: []checkFn{
- NoStdout,
- Stderr("profile: cpu profiling enabled"),
- NoErr,
- },
- }, {
- name: "memory profile",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- defer profile.Start(profile.MemProfile).Stop()
-}
-`,
- checks: []checkFn{
- NoStdout,
- Stderr("profile: memory profiling enabled"),
- NoErr,
- },
- }, {
- name: "memory profile (rate 2048)",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- defer profile.Start(profile.MemProfileRate(2048)).Stop()
-}
-`,
- checks: []checkFn{
- NoStdout,
- Stderr("profile: memory profiling enabled (rate 2048)"),
- NoErr,
- },
- }, {
- name: "double start",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- profile.Start()
- profile.Start()
-}
-`,
- checks: []checkFn{
- NoStdout,
- Stderr("cpu profiling enabled", "profile: Start() already called"),
- Err,
- },
- }, {
- name: "block profile",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- defer profile.Start(profile.BlockProfile).Stop()
-}
-`,
- checks: []checkFn{
- NoStdout,
- Stderr("profile: block profiling enabled"),
- NoErr,
- },
- }, {
- name: "mutex profile",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- defer profile.Start(profile.MutexProfile).Stop()
-}
-`,
- checks: []checkFn{
- NoStdout,
- Stderr("profile: mutex profiling enabled"),
- NoErr,
- },
- }, {
- name: "profile path",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- defer profile.Start(profile.ProfilePath(".")).Stop()
-}
-`,
- checks: []checkFn{
- NoStdout,
- Stderr("profile: cpu profiling enabled, cpu.pprof"),
- NoErr,
- },
- }, {
- name: "profile path error",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- defer profile.Start(profile.ProfilePath("` + f.Name() + `")).Stop()
-}
-`,
- checks: []checkFn{
- NoStdout,
- Stderr("could not create initial output"),
- Err,
- },
- }, {
- name: "multiple profile sessions",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- profile.Start(profile.CPUProfile).Stop()
- profile.Start(profile.MemProfile).Stop()
- profile.Start(profile.BlockProfile).Stop()
- profile.Start(profile.CPUProfile).Stop()
- profile.Start(profile.MutexProfile).Stop()
-}
-`,
- checks: []checkFn{
- NoStdout,
- Stderr("profile: cpu profiling enabled",
- "profile: cpu profiling disabled",
- "profile: memory profiling enabled",
- "profile: memory profiling disabled",
- "profile: block profiling enabled",
- "profile: block profiling disabled",
- "profile: cpu profiling enabled",
- "profile: cpu profiling disabled",
- "profile: mutex profiling enabled",
- "profile: mutex profiling disabled"),
- NoErr,
- },
- }, {
- name: "profile quiet",
- code: `
-package main
-
-import "github.com/pkg/profile"
-
-func main() {
- defer profile.Start(profile.Quiet).Stop()
-}
-`,
- checks: []checkFn{NoStdout, NoStderr, NoErr},
- }}
- for _, tt := range profileTests {
- t.Log(tt.name)
- stdout, stderr, err := runTest(t, tt.code)
- for _, f := range tt.checks {
- f(t, stdout, stderr, err)
- }
- }
-}
-
-// NoStdout checks that stdout was blank.
-func NoStdout(t *testing.T, stdout, _ []byte, _ error) {
- if len := len(stdout); len > 0 {
- t.Errorf("stdout: wanted 0 bytes, got %d", len)
- }
-}
-
-// Stderr verifies that the given lines match the output from stderr
-func Stderr(lines ...string) checkFn {
- return func(t *testing.T, _, stderr []byte, _ error) {
- r := bytes.NewReader(stderr)
- if !validateOutput(r, lines) {
- t.Errorf("stderr: wanted '%s', got '%s'", lines, stderr)
- }
- }
-}
-
-// NoStderr checks that stderr was blank.
-func NoStderr(t *testing.T, _, stderr []byte, _ error) {
- if len := len(stderr); len > 0 {
- t.Errorf("stderr: wanted 0 bytes, got %d", len)
- }
-}
-
-// Err checks that there was an error returned
-func Err(t *testing.T, _, _ []byte, err error) {
- if err == nil {
- t.Errorf("expected error")
- }
-}
-
-// NoErr checks that err was nil
-func NoErr(t *testing.T, _, _ []byte, err error) {
- if err != nil {
- t.Errorf("error: expected nil, got %v", err)
- }
-}
-
-// validatedOutput validates the given slice of lines against data from the given reader.
-func validateOutput(r io.Reader, want []string) bool {
- s := bufio.NewScanner(r)
- for _, line := range want {
- if !s.Scan() || !strings.Contains(s.Text(), line) {
- return false
- }
- }
- return true
-}
-
-var validateOutputTests = []struct {
- input string
- lines []string
- want bool
-}{{
- input: "",
- want: true,
-}, {
- input: `profile: yes
-`,
- want: true,
-}, {
- input: `profile: yes
-`,
- lines: []string{"profile: yes"},
- want: true,
-}, {
- input: `profile: yes
-profile: no
-`,
- lines: []string{"profile: yes"},
- want: true,
-}, {
- input: `profile: yes
-profile: no
-`,
- lines: []string{"profile: yes", "profile: no"},
- want: true,
-}, {
- input: `profile: yes
-profile: no
-`,
- lines: []string{"profile: no"},
- want: false,
-}}
-
-func TestValidateOutput(t *testing.T) {
- for _, tt := range validateOutputTests {
- r := strings.NewReader(tt.input)
- got := validateOutput(r, tt.lines)
- if tt.want != got {
- t.Errorf("validateOutput(%q, %q), want %v, got %v", tt.input, tt.lines, tt.want, got)
- }
- }
-}
-
-// runTest executes the go program supplied and returns the contents of stdout,
-// stderr, and an error which may contain status information about the result
-// of the program.
-func runTest(t *testing.T, code string) ([]byte, []byte, error) {
- chk := func(err error) {
- if err != nil {
- t.Fatal(err)
- }
- }
- gopath, err := ioutil.TempDir("", "profile-gopath")
- chk(err)
- defer os.RemoveAll(gopath)
-
- srcdir := filepath.Join(gopath, "src")
- err = os.Mkdir(srcdir, 0755)
- chk(err)
- src := filepath.Join(srcdir, "main.go")
- err = ioutil.WriteFile(src, []byte(code), 0644)
- chk(err)
-
- cmd := exec.Command("go", "run", src)
-
- var stdout, stderr bytes.Buffer
- cmd.Stdout = &stdout
- cmd.Stderr = &stderr
- err = cmd.Run()
- return stdout.Bytes(), stderr.Bytes(), err
-}
diff --git a/vendor/github.com/pkg/profile/trace_test.go b/vendor/github.com/pkg/profile/trace_test.go
deleted file mode 100644
index 6a61d79..0000000
--- a/vendor/github.com/pkg/profile/trace_test.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package profile_test
-
-import "github.com/pkg/profile"
-
-func ExampleTraceProfile() {
- // use execution tracing, rather than the default cpu profiling.
- defer profile.Start(profile.TraceProfile).Stop()
-}