Переглянути джерело

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 роки тому
джерело
коміт
79c4198ef7
1 змінених файлів з 12 додано та 2 видалено
  1. 12
    2
      internal/driver/fetch_test.go

+ 12
- 2
internal/driver/fetch_test.go Переглянути файл

351
 	return c.Get("file:///" + file)
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
 func TestHttpsInsecure(t *testing.T) {
361
 func TestHttpsInsecure(t *testing.T) {
355
 	if runtime.GOOS == "nacl" {
362
 	if runtime.GOOS == "nacl" {
356
 		t.Skip("test assumes tcp available")
363
 		t.Skip("test assumes tcp available")
372
 		donec <- http.Serve(l, nil)
379
 		donec <- http.Serve(l, nil)
373
 	}(donec)
380
 	}(donec)
374
 	defer func() {
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
 			t.Fatalf("Serve got error %v, want %q", got, want)
383
 			t.Fatalf("Serve got error %v, want %q", got, want)
377
 		}
384
 		}
378
 	}()
385
 	}()
416
 	if len(p.SampleType) == 0 {
423
 	if len(p.SampleType) == 0 {
417
 		t.Fatalf("fetchProfiles(%s) got empty profile: len(p.SampleType)==0", address)
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
 	if len(p.Function) == 0 {
430
 	if len(p.Function) == 0 {
420
 		t.Fatalf("fetchProfiles(%s) got non-symbolized profile: len(p.Function)==0", address)
431
 		t.Fatalf("fetchProfiles(%s) got non-symbolized profile: len(p.Function)==0", address)
421
 	}
432
 	}
429
 var badSigprofOS = map[string]bool{
440
 var badSigprofOS = map[string]bool{
430
 	"darwin": true,
441
 	"darwin": true,
431
 	"netbsd": true,
442
 	"netbsd": true,
432
-	"plan9":  true,
433
 }
443
 }
434
 
444
 
435
 func checkProfileHasFunction(p *profile.Profile, fname string) error {
445
 func checkProfileHasFunction(p *profile.Profile, fname string) error {