Source file
src/internal/poll/error_linux_test.go
1
2
3
4
5 package poll_test
6
7 import (
8 "errors"
9 "internal/poll"
10 "os"
11 "syscall"
12 )
13
14 func badStateFile() (*os.File, error) {
15 if os.Getuid() != 0 {
16 return nil, errors.New("must be root")
17 }
18
19
20
21 return os.OpenFile("/dev/net/tun", os.O_RDWR, 0)
22 }
23
24 func isBadStateFileError(err error) (string, bool) {
25 switch err {
26 case poll.ErrNotPollable, syscall.EBADFD:
27 return "", true
28 default:
29 return "not pollable or file in bad state error", false
30 }
31 }
32
View as plain text