diff options
author | Simon Rozman <simon@rozman.si> | 2019-02-04 11:52:42 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-02-05 12:59:42 +0100 |
commit | dd998ca86ac47869e2ff577b63b961e470a88c9b (patch) | |
tree | c7dea0ce9a708c77b6674bc359e479859a8ddde1 /setupapi/setupapi_windows_test.go | |
parent | 024a4916c245ca6b15b65995fae2002f50b11186 (diff) |
Add support for setupapi.SetupDiCreateDeviceInfo()
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'setupapi/setupapi_windows_test.go')
-rw-r--r-- | setupapi/setupapi_windows_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/setupapi/setupapi_windows_test.go b/setupapi/setupapi_windows_test.go index c99da6f..bfe82f6 100644 --- a/setupapi/setupapi_windows_test.go +++ b/setupapi/setupapi_windows_test.go @@ -70,6 +70,29 @@ func TestSetupDiClassGuidsFromNameEx(t *testing.T) { } } +func TestSetupDiCreateDeviceInfo(t *testing.T) { + devInfoList, err := SetupDiCreateDeviceInfoListEx(&deviceClassNetGUID, 0, computerName) + if err != nil { + t.Errorf("Error calling SetupDiCreateDeviceInfoListEx: %s", err.Error()) + } + defer devInfoList.Close() + + deviceClassNetName, err := SetupDiClassNameFromGuidEx(&deviceClassNetGUID, computerName) + if err != nil { + t.Errorf("Error calling SetupDiClassNameFromGuidEx: %s", err.Error()) + } + + devInfoData, err := SetupDiCreateDeviceInfo(devInfoList, 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 { + t.Errorf("Error calling SetupDiCreateDeviceInfo: %s", err.Error()) + } + } else if devInfoData.ClassGUID != deviceClassNetGUID { + t.Error("SetupDiCreateDeviceInfo returned different class GUID") + } +} + func TestSetupDiCreateDeviceInfoListEx(t *testing.T) { devInfoList, err := SetupDiCreateDeviceInfoListEx(&deviceClassNetGUID, 0, "") if err == nil { |