diff options
author | synergydev <synergye@codefi.re> | 2013-10-17 18:16:42 -0700 |
---|---|---|
committer | synergydev <synergye@codefi.re> | 2013-10-17 18:16:42 -0700 |
commit | 61c0330cc243abf13fdd01f377a7f80bd3989eb1 (patch) | |
tree | 119b08ae76294f23e2b1b7e72ff9a06afa9e8509 /gcc-4.8/libgo/go/net/rpc/server_test.go | |
parent | 1c712bf7621f3859c33fd3afaa61fdcaf3fdfd76 (diff) | |
download | toolchain_gcc-61c0330cc243abf13fdd01f377a7f80bd3989eb1.tar.gz toolchain_gcc-61c0330cc243abf13fdd01f377a7f80bd3989eb1.tar.bz2 toolchain_gcc-61c0330cc243abf13fdd01f377a7f80bd3989eb1.zip |
[4.8] Merge GCC 4.8.2
Change-Id: I0f1fcf69c5076d8534c5c45562745e1a37adb197
Diffstat (limited to 'gcc-4.8/libgo/go/net/rpc/server_test.go')
-rw-r--r-- | gcc-4.8/libgo/go/net/rpc/server_test.go | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/gcc-4.8/libgo/go/net/rpc/server_test.go b/gcc-4.8/libgo/go/net/rpc/server_test.go index 2c734a479..eb17210ab 100644 --- a/gcc-4.8/libgo/go/net/rpc/server_test.go +++ b/gcc-4.8/libgo/go/net/rpc/server_test.go @@ -399,12 +399,10 @@ func (WriteFailCodec) WriteRequest(*Request, interface{}) error { func (WriteFailCodec) ReadResponseHeader(*Response) error { select {} - panic("unreachable") } func (WriteFailCodec) ReadResponseBody(interface{}) error { select {} - panic("unreachable") } func (WriteFailCodec) Close() error { @@ -445,8 +443,7 @@ func dialHTTP() (*Client, error) { return DialHTTP("tcp", httpServerAddr) } -func countMallocs(dial func() (*Client, error), t *testing.T) uint64 { - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1)) +func countMallocs(dial func() (*Client, error), t *testing.T) float64 { once.Do(startServer) client, err := dial() if err != nil { @@ -454,11 +451,7 @@ func countMallocs(dial func() (*Client, error), t *testing.T) uint64 { } args := &Args{7, 8} reply := new(Reply) - memstats := new(runtime.MemStats) - runtime.ReadMemStats(memstats) - mallocs := 0 - memstats.Mallocs - const count = 100 - for i := 0; i < count; i++ { + return testing.AllocsPerRun(100, func() { err := client.Call("Arith.Add", args, reply) if err != nil { t.Errorf("Add: expected no error but got string %q", err.Error()) @@ -466,18 +459,21 @@ func countMallocs(dial func() (*Client, error), t *testing.T) uint64 { if reply.C != args.A+args.B { t.Errorf("Add: expected %d got %d", reply.C, args.A+args.B) } - } - runtime.ReadMemStats(memstats) - mallocs += memstats.Mallocs - return mallocs / count + }) } func TestCountMallocs(t *testing.T) { - fmt.Printf("mallocs per rpc round trip: %d\n", countMallocs(dialDirect, t)) + if runtime.GOMAXPROCS(0) > 1 { + t.Skip("skipping; GOMAXPROCS>1") + } + fmt.Printf("mallocs per rpc round trip: %v\n", countMallocs(dialDirect, t)) } func TestCountMallocsOverHTTP(t *testing.T) { - fmt.Printf("mallocs per HTTP rpc round trip: %d\n", countMallocs(dialHTTP, t)) + if runtime.GOMAXPROCS(0) > 1 { + t.Skip("skipping; GOMAXPROCS>1") + } + fmt.Printf("mallocs per HTTP rpc round trip: %v\n", countMallocs(dialHTTP, t)) } type writeCrasher struct { @@ -532,6 +528,23 @@ func TestTCPClose(t *testing.T) { } } +func TestErrorAfterClientClose(t *testing.T) { + once.Do(startServer) + + client, err := dialHTTP() + if err != nil { + t.Fatalf("dialing: %v", err) + } + err = client.Close() + if err != nil { + t.Fatal("close error:", err) + } + err = client.Call("Arith.Add", &Args{7, 9}, new(Reply)) + if err != ErrShutdown { + t.Errorf("Forever: expected ErrShutdown got %v", err) + } +} + func benchmarkEndToEnd(dial func() (*Client, error), b *testing.B) { b.StopTimer() once.Do(startServer) |