...
1 package devices
2
3 import (
4 "io/fs"
5 "path/filepath"
6 )
7
8 var (
9 testDevice Device
10 testRootDevPath = "testdata/dev"
11 testRootSysPath = "testdata/sys"
12 testDevicePath = filepath.Join(testRootSysPath, "devices", "usb")
13 mockSubsystemFn = func(path string) (string, error) { return filepath.Dir(path), nil }
14 mockDeviceTypeFn = func(_ string) (string, error) { return "char", nil }
15 )
16
17 func SetTestEnvs() {
18
19 DevPath = testRootDevPath
20 SysPath = testRootSysPath
21 sysDevicePath = filepath.Join(testRootSysPath, "devices")
22 sysBusPath = filepath.Join(testRootSysPath, "bus")
23 sysClassPath = filepath.Join(testRootSysPath, "class")
24
25 subSystemSymlinkFn = mockSubsystemFn
26 deviceTypeFn = mockDeviceTypeFn
27 isSymlinkFn = func(fileInfo fs.FileInfo) bool {
28 return fileInfo.Mode()&fs.ModeSymlink != 0
29 }
30 }
31
View as plain text