Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(924)

Side by Side Diff: src/pkg/net/fd_unix_test.go

Issue 6842127: code review 6842127: net: align deadline fields on 8 byte boundaries (Closed)
Patch Set: diff -r 87d3b86bcc68 https://code.google.com/p/go Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/net/fd_unix.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux netbsd openbsd 5 // +build darwin freebsd linux netbsd openbsd
6 6
7 package net 7 package net
8 8
9 import ( 9 import (
10 "io" 10 "io"
11 "syscall" 11 "syscall"
12 "testing" 12 "testing"
13 "unsafe"
13 ) 14 )
14 15
15 // Issue 3590. netFd.AddFD should return an error 16 // Issue 3590. netFd.AddFD should return an error
16 // from the underlying pollster rather than panicing. 17 // from the underlying pollster rather than panicing.
17 func TestAddFDReturnsError(t *testing.T) { 18 func TestAddFDReturnsError(t *testing.T) {
18 ln := newLocalListener(t).(*TCPListener) 19 ln := newLocalListener(t).(*TCPListener)
19 defer ln.Close() 20 defer ln.Close()
20 connected := make(chan bool) 21 connected := make(chan bool)
21 go func() { 22 go func() {
22 for { 23 for {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 98 }
98 99
99 func TestChkReadErr(t *testing.T) { 100 func TestChkReadErr(t *testing.T) {
100 for _, tt := range chkReadErrTests { 101 for _, tt := range chkReadErrTests {
101 actual := chkReadErr(tt.n, tt.err, tt.fd) 102 actual := chkReadErr(tt.n, tt.err, tt.fd)
102 if actual != tt.expected { 103 if actual != tt.expected {
103 t.Errorf("chkReadError(%v, %v, %v): expected %v, actual %v", tt.n, tt.err, tt.fd.sotype, tt.expected, actual) 104 t.Errorf("chkReadError(%v, %v, %v): expected %v, actual %v", tt.n, tt.err, tt.fd.sotype, tt.expected, actual)
104 } 105 }
105 } 106 }
106 } 107 }
108
109 // see comment in fd_unix.go
110 func TestDeadlineFieldAlignment(t *testing.T) {
111 var fd netFD
112 if size := unsafe.Sizeof(fd) % 8; size != 0 {
113 t.Errorf("size of fd %% 8 is %d not 0", size)
114 }
115 if offset := unsafe.Offsetof(fd.rdeadline) % 8; offset != 0 {
116 t.Errorf("offset of fd.rdeadline %% 8 is %d not 0", offset)
117 }
118 if offset := unsafe.Offsetof(fd.wdeadline) % 8; offset != 0 {
119 t.Errorf("offset of fd.wdeadline %% 8 is %d not 0", offset)
120 }
121 }
OLDNEW
« no previous file with comments | « src/pkg/net/fd_unix.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b