Skip to content

Commit

Permalink
Fix TestHttpsInsecure on Plan 9 (#254)
Browse files Browse the repository at this point in the history
* Handle "listen hungup" error on Plan 9 in TestHttpsInsecure

Plan 9 returns the "listen hungup" error when closing a closed listener.

See https://github.com/0intro/plan9/blob/4225c3e/sys/src/9/ip/devip.c#L476

Fixes #253.

* Handle empty profile on Plan 9 in TestHttpsInsecure

CPU profiling isn't implemented on Plan 9.

See golang.org/issues/22564.

Fixes #253.
  • Loading branch information
0intro authored and aalexand committed Nov 3, 2017
1 parent 4fc39a0 commit 79c4198
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/driver/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ func stubHTTPGet(source string, _ time.Duration) (*http.Response, error) {
return c.Get("file:///" + file)
}

func closedError() string {
if runtime.GOOS == "plan9" {
return "listen hungup"
}
return "use of closed"
}

func TestHttpsInsecure(t *testing.T) {
if runtime.GOOS == "nacl" {
t.Skip("test assumes tcp available")
Expand All @@ -372,7 +379,7 @@ func TestHttpsInsecure(t *testing.T) {
donec <- http.Serve(l, nil)
}(donec)
defer func() {
if got, want := <-donec, "use of closed"; !strings.Contains(got.Error(), want) {
if got, want := <-donec, closedError(); !strings.Contains(got.Error(), want) {
t.Fatalf("Serve got error %v, want %q", got, want)
}
}()
Expand Down Expand Up @@ -416,6 +423,10 @@ func TestHttpsInsecure(t *testing.T) {
if len(p.SampleType) == 0 {
t.Fatalf("fetchProfiles(%s) got empty profile: len(p.SampleType)==0", address)
}
if runtime.GOOS == "plan9" {
// CPU profiling is not supported on Plan9; see golang.org/issues/22564.
return
}
if len(p.Function) == 0 {
t.Fatalf("fetchProfiles(%s) got non-symbolized profile: len(p.Function)==0", address)
}
Expand All @@ -429,7 +440,6 @@ func TestHttpsInsecure(t *testing.T) {
var badSigprofOS = map[string]bool{
"darwin": true,
"netbsd": true,
"plan9": true,
}

func checkProfileHasFunction(p *profile.Profile, fname string) error {
Expand Down

0 comments on commit 79c4198

Please sign in to comment.