summaryrefslogtreecommitdiffhomepage
path: root/setupapi/setupapi_windows_test.go
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-02-04 08:23:55 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-05 12:59:42 +0100
commit9635a0b3a69272aac998fad700344fac392d2adf (patch)
treed6ff68dea9ac416df4de0bae05ce936d94cdcea6 /setupapi/setupapi_windows_test.go
parent90b6938ca04d49240ddcd1a50650489f3fe3f26b (diff)
Add support for setupapi.SetupDiClassNameFromGuid()
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'setupapi/setupapi_windows_test.go')
-rw-r--r--setupapi/setupapi_windows_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/setupapi/setupapi_windows_test.go b/setupapi/setupapi_windows_test.go
index 1d3c33d..e26032d 100644
--- a/setupapi/setupapi_windows_test.go
+++ b/setupapi/setupapi_windows_test.go
@@ -6,6 +6,7 @@
package setupapi
import (
+ "strings"
"syscall"
"testing"
@@ -19,6 +20,24 @@ func init() {
computerName, _ = windows.ComputerName()
}
+func TestSetupDiClassNameFromGuid(t *testing.T) {
+ className, err := SetupDiClassNameFromGuid(&deviceClassNetGUID)
+ if err != nil {
+ t.Errorf("Error calling SetupDiClassNameFromGuid: %s", err.Error())
+ } else if strings.ToLower(className) != "net" {
+ t.Errorf("SetupDiClassNameFromGuid(%x) should return \"Net\"", deviceClassNetGUID)
+ }
+
+ _, err = SetupDiClassNameFromGuid(nil)
+ if err == nil {
+ t.Errorf("SetupDiClassNameFromGuid(nil) should fail")
+ } else {
+ if errWin, ok := err.(syscall.Errno); !ok || errWin != 1784 /*ERROR_INVALID_USER_BUFFER*/ {
+ t.Errorf("SetupDiClassNameFromGuid(nil) should fail with ERROR_INVALID_USER_BUFFER")
+ }
+ }
+}
+
func TestSetupDiGetClassDevsEx(t *testing.T) {
devInfoList, err := SetupDiGetClassDevsEx(&deviceClassNetGUID, "PCI", 0, DIGCF_PRESENT, DevInfo(0), computerName)
if err == nil {