forked from vishvananda/netlink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandle_linux_test.go
More file actions
36 lines (29 loc) · 835 Bytes
/
Copy pathhandle_linux_test.go
File metadata and controls
36 lines (29 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package netlink
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestSetGetSocketTimeout(t *testing.T) {
timeout := 10 * time.Second
if err := SetSocketTimeout(10 * time.Second); err != nil {
t.Fatalf("Set socket timeout for default handle failed: %v", err)
}
if val := GetSocketTimeout(); val != timeout {
t.Fatalf("Unexpected socket timeout value: got=%v, expected=%v", val, timeout)
}
}
func TestConfigureHandle(t *testing.T) {
orig := pkgHandle
origDone := configDone
t.Cleanup(func() {
configMu.Lock()
defer configMu.Unlock()
pkgHandle = orig
configDone = origDone
})
assert.NoError(t, ConfigureHandle(HandleOptions{DisableVFInfoCollection: true}))
assert.NotEqual(t, orig, pkgHandle)
assert.NoError(t, pkgHandle.Close())
assert.Error(t, ConfigureHandle(HandleOptions{}))
}