File: socket_linux_test.go

package info (click to toggle)
golang-github-hugelgupf-socketpair 0.0~git20240723.9246f21-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 88 kB
  • sloc: makefile: 2
file content (31 lines) | stat: -rw-r--r-- 445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package socketpair

import (
	"log"
	"sync"
	"testing"
	"time"
)

func TestHanging(t *testing.T) {
	pc1, _, err := PacketSocketPair()
	if err != nil {
		t.Fatal(err)
	}

	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		defer wg.Done()
		b := make([]byte, 1)
		log.Printf("reading...")
		pc1.ReadFrom(b)
		log.Printf("reading returned")
	}()

	time.Sleep(2 * time.Second)
	log.Printf("closing...")
	pc1.Close()
	log.Printf("closed")
	wg.Wait()
}