forked from jochenvg/go-udev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
udev_test.go
116 lines (102 loc) · 2.16 KB
/
udev_test.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// +build linux
package udev
import (
"fmt"
"testing"
)
func ExampleUdev_NewDeviceFromDevnum() {
u := Udev{}
d := u.NewDeviceFromDevnum('c', MkDev(1, 8))
fmt.Println(d.Syspath())
// Output:
// /sys/devices/virtual/mem/random
}
func TestNewDeviceFromDevnum(t *testing.T) {
u := Udev{}
d := u.NewDeviceFromDevnum('c', MkDev(1, 8))
if d.Devnum().Major() != 1 {
t.Fail()
}
if d.Devnum().Minor() != 8 {
t.Fail()
}
if d.Devpath() != "/devices/virtual/mem/random" {
t.Fail()
}
}
func ExampleUdev_NewDeviceFromSyspath() {
u := Udev{}
d := u.NewDeviceFromSyspath("/sys/devices/virtual/mem/random")
fmt.Println(d.Syspath())
// Output:
// /sys/devices/virtual/mem/random
}
func TestNewDeviceFromSyspath(t *testing.T) {
u := Udev{}
d := u.NewDeviceFromSyspath("/sys/devices/virtual/mem/random")
if d.Devnum().Major() != 1 {
t.Fail()
}
if d.Devnum().Minor() != 8 {
t.Fail()
}
if d.Devpath() != "/devices/virtual/mem/random" {
t.Fail()
}
}
func ExampleUdev_NewDeviceFromSubsystemSysname() {
u := Udev{}
d := u.NewDeviceFromSubsystemSysname("mem", "random")
fmt.Println(d.Syspath())
// Output:
// /sys/devices/virtual/mem/random
}
func TestNewDeviceFromSubsystemSysname(t *testing.T) {
u := Udev{}
d := u.NewDeviceFromSubsystemSysname("mem", "random")
if d.Devnum().Major() != 1 {
t.Fail()
}
if d.Devnum().Minor() != 8 {
t.Fail()
}
if d.Devpath() != "/devices/virtual/mem/random" {
t.Fail()
}
}
func ExampleUdev_NewDeviceFromDeviceID() {
u := Udev{}
d := u.NewDeviceFromDeviceID("c1:8")
fmt.Println(d.Syspath())
// Output:
// /sys/devices/virtual/mem/random
}
func TestNewDeviceFromDeviceID(t *testing.T) {
u := Udev{}
d := u.NewDeviceFromDeviceID("c1:8")
if d.Devnum().Major() != 1 {
t.Fail()
}
if d.Devnum().Minor() != 8 {
t.Fail()
}
if d.Devpath() != "/devices/virtual/mem/random" {
t.Fail()
}
}
func ExampleUdev_NewMonitorFromNetlink() {
u := Udev{}
_ = u.NewMonitorFromNetlink("udev")
}
func TestNewMonitorFromNetlink(t *testing.T) {
u := Udev{}
_ = u.NewMonitorFromNetlink("udev")
}
func ExampleUdev_NewEnumerate() {
u := Udev{}
_ = u.NewEnumerate()
}
func TestNewEnumerate(t *testing.T) {
u := Udev{}
_ = u.NewEnumerate()
}