diff options
Diffstat (limited to 'tun/wintun/setupapi/setupapi_windows_test.go')
-rw-r--r-- | tun/wintun/setupapi/setupapi_windows_test.go | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/tun/wintun/setupapi/setupapi_windows_test.go b/tun/wintun/setupapi/setupapi_windows_test.go index ede1078..a2edab8 100644 --- a/tun/wintun/setupapi/setupapi_windows_test.go +++ b/tun/wintun/setupapi/setupapi_windows_test.go @@ -8,7 +8,6 @@ package setupapi import ( "runtime" "strings" - "syscall" "testing" "golang.org/x/sys/windows" @@ -114,7 +113,7 @@ func TestSetupDiCreateDeviceInfo(t *testing.T) { devInfoData, err := devInfoList.CreateDeviceInfo(deviceClassNetName, &deviceClassNetGUID, "This is a test device", 0, DICD_GENERATE_ID) if err != nil { // Access denied is expected, as the SetupDiCreateDeviceInfo() require elevation to succeed. - if errWin, ok := err.(syscall.Errno); !ok || errWin != windows.ERROR_ACCESS_DENIED { + if errWin, ok := err.(windows.Errno); !ok || errWin != windows.ERROR_ACCESS_DENIED { t.Errorf("Error calling SetupDiCreateDeviceInfo: %s", err.Error()) } } else if devInfoData.ClassGUID != deviceClassNetGUID { @@ -132,7 +131,7 @@ func TestSetupDiEnumDeviceInfo(t *testing.T) { for i := 0; true; i++ { data, err := devInfoList.EnumDeviceInfo(i) if err != nil { - if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { + if errWin, ok := err.(windows.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { break } continue @@ -154,7 +153,7 @@ func TestDevInfo_BuildDriverInfoList(t *testing.T) { for i := 0; true; i++ { deviceData, err := devInfoList.EnumDeviceInfo(i) if err != nil { - if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { + if errWin, ok := err.(windows.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { break } continue @@ -171,7 +170,7 @@ func TestDevInfo_BuildDriverInfoList(t *testing.T) { for j := 0; true; j++ { driverData, err := devInfoList.EnumDriverInfo(deviceData, driverType, j) if err != nil { - if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { + if errWin, ok := err.(windows.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { break } continue @@ -265,7 +264,7 @@ func TestSetupDiGetClassDevsEx(t *testing.T) { devInfoList.Close() t.Errorf("SetupDiGetClassDevsEx(nil, ...) should fail") } else { - if errWin, ok := err.(syscall.Errno); !ok || errWin != windows.ERROR_INVALID_PARAMETER { + if errWin, ok := err.(windows.Errno); !ok || errWin != windows.ERROR_INVALID_PARAMETER { t.Errorf("SetupDiGetClassDevsEx(nil, ...) should fail with ERROR_INVALID_PARAMETER") } } @@ -281,7 +280,7 @@ func TestSetupDiOpenDevRegKey(t *testing.T) { for i := 0; true; i++ { data, err := devInfoList.EnumDeviceInfo(i) if err != nil { - if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { + if errWin, ok := err.(windows.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { break } continue @@ -305,7 +304,7 @@ func TestSetupDiGetDeviceRegistryProperty(t *testing.T) { for i := 0; true; i++ { data, err := devInfoList.EnumDeviceInfo(i) if err != nil { - if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { + if errWin, ok := err.(windows.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { break } continue @@ -335,7 +334,7 @@ func TestSetupDiGetDeviceRegistryProperty(t *testing.T) { val, err = devInfoList.DeviceRegistryProperty(data, SPDRP_COMPATIBLEIDS) if err != nil { // Some devices have no SPDRP_COMPATIBLEIDS. - if errWin, ok := err.(syscall.Errno); !ok || errWin != windows.ERROR_INVALID_DATA { + if errWin, ok := err.(windows.Errno); !ok || errWin != windows.ERROR_INVALID_DATA { t.Errorf("Error calling SetupDiGetDeviceRegistryProperty(SPDRP_COMPATIBLEIDS): %s", err.Error()) } } @@ -362,7 +361,7 @@ func TestSetupDiGetDeviceInstallParams(t *testing.T) { for i := 0; true; i++ { data, err := devInfoList.EnumDeviceInfo(i) if err != nil { - if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { + if errWin, ok := err.(windows.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { break } continue @@ -400,7 +399,7 @@ func TestSetupDiClassNameFromGuidEx(t *testing.T) { if err == nil { t.Errorf("SetupDiClassNameFromGuidEx(nil) should fail") } else { - if errWin, ok := err.(syscall.Errno); !ok || errWin != windows.ERROR_INVALID_USER_BUFFER { + if errWin, ok := err.(windows.Errno); !ok || errWin != windows.ERROR_INVALID_USER_BUFFER { t.Errorf("SetupDiClassNameFromGuidEx(nil) should fail with ERROR_INVALID_USER_BUFFER") } } @@ -441,7 +440,7 @@ func TestSetupDiGetSelectedDevice(t *testing.T) { for i := 0; true; i++ { data, err := devInfoList.EnumDeviceInfo(i) if err != nil { - if errWin, ok := err.(syscall.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { + if errWin, ok := err.(windows.Errno); ok && errWin == windows.ERROR_NO_MORE_ITEMS { break } continue @@ -464,7 +463,7 @@ func TestSetupDiGetSelectedDevice(t *testing.T) { if err == nil { t.Errorf("SetupDiSetSelectedDevice(nil) should fail") } else { - if errWin, ok := err.(syscall.Errno); !ok || errWin != windows.ERROR_INVALID_PARAMETER { + if errWin, ok := err.(windows.Errno); !ok || errWin != windows.ERROR_INVALID_PARAMETER { t.Errorf("SetupDiSetSelectedDevice(nil) should fail with ERROR_INVALID_USER_BUFFER") } } |