Exemplo n.º 1
0
func (tc *netTestCase) Clean() {
	tc.sockS.Close()
	tc.sockC.Close()
	os.RemoveAll(tc.tmp)
	if tc.startSplices != splice.Used() {
		tc.tester.Fatalf("Splice leak before %d after %d",
			tc.startSplices, splice.Used())
	}
}
Exemplo n.º 2
0
func newNetTestCase(t *testing.T) *netTestCase {
	me := &netTestCase{}
	me.tester = t
	me.startSplices = splice.Used()
	me.tmp, _ = ioutil.TempDir("", "term-cba")

	optS := StoreOptions{
		Dir: me.tmp + "/server",
	}
	me.server = NewStore(&optS, nil)

	optC := optS
	optC.Dir = me.tmp + "/client"
	me.clientStore = NewStore(&optC, nil)
	var err error
	me.sockS, me.sockC = net.Pipe()
	if err != nil {
		t.Fatalf("unixSocketpair: %v", err)
	}

	go me.server.ServeConn(me.sockS)
	me.client = me.clientStore.NewClient(me.sockC)
	return me
}