-
Notifications
You must be signed in to change notification settings - Fork 3
/
ioctl_linux_test.go
29 lines (26 loc) · 998 Bytes
/
ioctl_linux_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
// +build linux
package gpio
import (
"github.com/stretchr/testify/assert"
"testing"
"unsafe"
)
func TestIoctlHelper(t *testing.T) {
cases := []struct {
name string
expect uintptr
actual uintptr
}{
{"GPIO_GET_CHIPINFO_IOCTL", GPIO_GET_CHIPINFO_IOCTL, ioR(0xb4, 0x01, unsafe.Sizeof(ChipInfo{}))},
{"GPIO_GET_LINEINFO_IOCTL", GPIO_GET_LINEINFO_IOCTL, ioWR(0xb4, 0x02, unsafe.Sizeof(LineInfo{}))},
{"GPIO_GET_LINEHANDLE_IOCTL", GPIO_GET_LINEHANDLE_IOCTL, ioWR(0xb4, 0x03, unsafe.Sizeof(HandleRequest{}))},
{"GPIO_GET_LINEEVENT_IOCTL", GPIO_GET_LINEEVENT_IOCTL, ioWR(0xb4, 0x04, unsafe.Sizeof(EventRequest{}))},
{"GPIOHANDLE_GET_LINE_VALUES_IOCTL", GPIOHANDLE_GET_LINE_VALUES_IOCTL, ioWR(0xb4, 0x08, unsafe.Sizeof(HandleData{}))},
{"GPIOHANDLE_SET_LINE_VALUES_IOCTL", GPIOHANDLE_SET_LINE_VALUES_IOCTL, ioWR(0xb4, 0x09, unsafe.Sizeof(HandleData{}))},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
assert.Equal(t, c.expect, c.actual, c.name)
})
}
}