Przeglądaj źródła

Fix TestHttpsInsecure on Plan 9 (#254)

* 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.
David du Colombier 7 lat temu
rodzic
commit
79c4198ef7
1 zmienionych plików z 12 dodań i 2 usunięć
  1. 12
    2
      internal/driver/fetch_test.go

+ 12
- 2
internal/driver/fetch_test.go Wyświetl plik

@@ -351,6 +351,13 @@ func stubHTTPGet(source string, _ time.Duration) (*http.Response, error) {
351 351
 	return c.Get("file:///" + file)
352 352
 }
353 353
 
354
+func closedError() string {
355
+	if runtime.GOOS == "plan9" {
356
+		return "listen hungup"
357
+	}
358
+	return "use of closed"
359
+}
360
+
354 361
 func TestHttpsInsecure(t *testing.T) {
355 362
 	if runtime.GOOS == "nacl" {
356 363
 		t.Skip("test assumes tcp available")
@@ -372,7 +379,7 @@ func TestHttpsInsecure(t *testing.T) {
372 379
 		donec <- http.Serve(l, nil)
373 380
 	}(donec)
374 381
 	defer func() {
375
-		if got, want := <-donec, "use of closed"; !strings.Contains(got.Error(), want) {
382
+		if got, want := <-donec, closedError(); !strings.Contains(got.Error(), want) {
376 383
 			t.Fatalf("Serve got error %v, want %q", got, want)
377 384
 		}
378 385
 	}()
@@ -416,6 +423,10 @@ func TestHttpsInsecure(t *testing.T) {
416 423
 	if len(p.SampleType) == 0 {
417 424
 		t.Fatalf("fetchProfiles(%s) got empty profile: len(p.SampleType)==0", address)
418 425
 	}
426
+	if runtime.GOOS == "plan9" {
427
+		// CPU profiling is not supported on Plan9; see golang.org/issues/22564.
428
+		return
429
+	}
419 430
 	if len(p.Function) == 0 {
420 431
 		t.Fatalf("fetchProfiles(%s) got non-symbolized profile: len(p.Function)==0", address)
421 432
 	}
@@ -429,7 +440,6 @@ func TestHttpsInsecure(t *testing.T) {
429 440
 var badSigprofOS = map[string]bool{
430 441
 	"darwin": true,
431 442
 	"netbsd": true,
432
-	"plan9":  true,
433 443
 }
434 444
 
435 445
 func checkProfileHasFunction(p *profile.Profile, fname string) error {