detached 0885f41

test(conn): build the server tests on every Unix

syscall.FdSet has no Bits field on FreeBSD, so the select-based wait only exists on Linux; other platforms skip the poll-loop test.
commit
0885f41541dec41c19b39c73126e83ce7cf1ff9e
author
brice · · 2026-10-14 21:35 UTC
parent
69ad4ea
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
3 files · +14 -19
M server_test.go +4 -1
@@ -1,6 +1,7 @@
11 package zerobus
22
33 import (
4+ "errors"
45 "net"
56 "path/filepath"
67 "testing"
@@ -228,7 +229,9 @@ func waitReadable(t *testing.T, c *Conn) {
228229 if err := rc.Control(func(f uintptr) { fd = int(f) }); err != nil {
229230 t.Fatal(err)
230231 }
231- if err := waitFd(fd, 5*time.Second); err != nil {
232+ if err := waitFd(fd, 5*time.Second); errors.Is(err, errNoWaitFd) {
233+ t.Skip(err)
234+ } else if err != nil {
232235 t.Fatal(err)
233236 }
234237 }
@@ -1,6 +1,7 @@
1 package zerobus1 package zerobus
2 2
3 import (3 import (
4+ "errors"
4 "net"5 "net"
5 "path/filepath"6 "path/filepath"
6 "testing"7 "testing"
@@ -228,7 +229,9 @@ func waitReadable(t *testing.T, c *Conn) {
228 if err := rc.Control(func(f uintptr) { fd = int(f) }); err != nil {229 if err := rc.Control(func(f uintptr) { fd = int(f) }); err != nil {
229 t.Fatal(err)230 t.Fatal(err)
230 }231 }
231- if err := waitFd(fd, 5*time.Second); err != nil {232+ if err := waitFd(fd, 5*time.Second); errors.Is(err, errNoWaitFd) {
233+ t.Skip(err)
234+ } else if err != nil {
232 t.Fatal(err)235 t.Fatal(err)
233 }236 }
234 }237 }
M waitfd_linux_test.go +4 -0
@@ -1,12 +1,16 @@
11 package zerobus
22
33 import (
4+ "errors"
45 "fmt"
56 "syscall"
67 "time"
78 "unsafe"
89 )
910
11+// errNoWaitFd is returned where waitFd is not supported; never on Linux.
12+var errNoWaitFd = errors.New("waitFd: not supported on this platform")
13+
1014 // waitFd blocks until fd is readable or the timeout passes, as a poll loop
1115 // does.
1216 func waitFd(fd int, timeout time.Duration) error {
@@ -1,12 +1,16 @@
1 package zerobus1 package zerobus
2 2
3 import (3 import (
4+ "errors"
4 "fmt"5 "fmt"
5 "syscall"6 "syscall"
6 "time"7 "time"
7 "unsafe"8 "unsafe"
8 )9 )
9 10
11+// errNoWaitFd is returned where waitFd is not supported; never on Linux.
12+var errNoWaitFd = errors.New("waitFd: not supported on this platform")
13+
10 // waitFd blocks until fd is readable or the timeout passes, as a poll loop14 // waitFd blocks until fd is readable or the timeout passes, as a poll loop
11 // does.15 // does.
12 func waitFd(fd int, timeout time.Duration) error {16 func waitFd(fd int, timeout time.Duration) error {
M waitfd_other_test.go +6 -18
@@ -3,24 +3,12 @@
33 package zerobus
44
55 import (
6- "fmt"
7- "syscall"
6+ "errors"
87 "time"
9- "unsafe"
108 )
119
12-// waitFd blocks until fd is readable or the timeout passes, as a poll loop
13-// does. syscall.Select returns only an error outside Linux.
14-func waitFd(fd int, timeout time.Duration) error {
15- var set syscall.FdSet
16- bits := int(unsafe.Sizeof(set.Bits[0])) * 8
17- set.Bits[fd/bits] |= 1 << (uint(fd) % uint(bits))
18- tv := syscall.NsecToTimeval(timeout.Nanoseconds())
19- if err := syscall.Select(fd+1, &set, nil, nil, &tv); err != nil {
20- return fmt.Errorf("select: %v", err)
21- }
22- if set.Bits[fd/bits]&(1<<(uint(fd)%uint(bits))) == 0 {
23- return fmt.Errorf("select: fd %d not readable after %v", fd, timeout)
24- }
25- return nil
26-}
10+// errNoWaitFd means the platform has no waitFd: syscall.FdSet differs
11+// between the BSDs and Darwin, and the poll tests only run on Linux.
12+var errNoWaitFd = errors.New("waitFd: not supported on this platform")
13+
14+func waitFd(int, time.Duration) error { return errNoWaitFd }
@@ -3,24 +3,12 @@
3 package zerobus3 package zerobus
4 4
5 import (5 import (
6- "fmt"6+ "errors"
7- "syscall"
8 "time"7 "time"
9- "unsafe"
10 )8 )
11 9
12-// waitFd blocks until fd is readable or the timeout passes, as a poll loop10+// errNoWaitFd means the platform has no waitFd: syscall.FdSet differs
13-// does. syscall.Select returns only an error outside Linux.11+// between the BSDs and Darwin, and the poll tests only run on Linux.
14-func waitFd(fd int, timeout time.Duration) error {12+var errNoWaitFd = errors.New("waitFd: not supported on this platform")
15- var set syscall.FdSet13+
16- bits := int(unsafe.Sizeof(set.Bits[0])) * 814+func waitFd(int, time.Duration) error { return errNoWaitFd }
17- set.Bits[fd/bits] |= 1 << (uint(fd) % uint(bits))
18- tv := syscall.NsecToTimeval(timeout.Nanoseconds())
19- if err := syscall.Select(fd+1, &set, nil, nil, &tv); err != nil {
20- return fmt.Errorf("select: %v", err)
21- }
22- if set.Bits[fd/bits]&(1<<(uint(fd)%uint(bits))) == 0 {
23- return fmt.Errorf("select: fd %d not readable after %v", fd, timeout)
24- }
25- return nil
26-}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 3

↑↓ moveenter openesc close