debug_test.go 770 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package controlclient
  5. import "testing"
  6. func TestScrubbedGoroutineDump(t *testing.T) {
  7. t.Logf("Got:\n%s\n", scrubbedGoroutineDump())
  8. }
  9. func TestScrubHex(t *testing.T) {
  10. tests := []struct {
  11. in, want string
  12. }{
  13. {"foo", "foo"},
  14. {"", ""},
  15. {"0x", "?_"},
  16. {"0x001 and same 0x001", "v1%1_ and same v1%1_"},
  17. {"0x008 and same 0x008", "v1%0_ and same v1%0_"},
  18. {"0x001 and diff 0x002", "v1%1_ and diff v2%2_"},
  19. }
  20. for _, tt := range tests {
  21. got := scrubHex([]byte(tt.in))
  22. if string(got) != tt.want {
  23. t.Errorf("for input:\n%s\n\ngot:\n%s\n\nwant:\n%s\n", tt.in, got, tt.want)
  24. }
  25. }
  26. }