Skip to content

Commit dcdaa63

Browse files
jordanrh1bradfitz
authored andcommitted
windows: use netevent.dll in TestFormatMessage for windows/arm
pdh.dll is not available on Windows IoT core. Use netevent.dll instead. Update golang/go#26148 Change-Id: I80c299ad030944954d5d7d182d91dc15e71341f9 Reviewed-on: https://go-review.googlesource.com/c/154560 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 4d1cda0 commit dcdaa63

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

windows/syscall_windows_test.go

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"path/filepath"
1111
"syscall"
1212
"testing"
13-
"unsafe"
1413

1514
"golang.org/x/sys/windows"
1615
)
@@ -54,34 +53,14 @@ func TestWin32finddata(t *testing.T) {
5453
}
5554

5655
func TestFormatMessage(t *testing.T) {
57-
dll := windows.MustLoadDLL("pdh.dll")
58-
59-
pdhOpenQuery := func(datasrc *uint16, userdata uint32, query *windows.Handle) (errno uintptr) {
60-
r0, _, _ := syscall.Syscall(dll.MustFindProc("PdhOpenQueryW").Addr(), 3, uintptr(unsafe.Pointer(datasrc)), uintptr(userdata), uintptr(unsafe.Pointer(query)))
61-
return r0
62-
}
63-
64-
pdhCloseQuery := func(query windows.Handle) (errno uintptr) {
65-
r0, _, _ := syscall.Syscall(dll.MustFindProc("PdhCloseQuery").Addr(), 1, uintptr(query), 0, 0)
66-
return r0
67-
}
68-
69-
var q windows.Handle
70-
name, err := windows.UTF16PtrFromString("no_such_source")
71-
if err != nil {
72-
t.Fatal(err)
73-
}
74-
errno := pdhOpenQuery(name, 0, &q)
75-
if errno == 0 {
76-
pdhCloseQuery(q)
77-
t.Fatal("PdhOpenQuery succeeded, but expected to fail.")
78-
}
56+
dll := windows.MustLoadDLL("netevent.dll")
7957

58+
const TITLE_SC_MESSAGE_BOX uint32 = 0xC0001B75
8059
const flags uint32 = syscall.FORMAT_MESSAGE_FROM_HMODULE | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS
8160
buf := make([]uint16, 300)
82-
_, err = windows.FormatMessage(flags, uintptr(dll.Handle), uint32(errno), 0, buf, nil)
61+
_, err := windows.FormatMessage(flags, uintptr(dll.Handle), TITLE_SC_MESSAGE_BOX, 0, buf, nil)
8362
if err != nil {
84-
t.Fatalf("FormatMessage for handle=%x and errno=%x failed: %v", dll.Handle, errno, err)
63+
t.Fatalf("FormatMessage for handle=%x and errno=%x failed: %v", dll.Handle, TITLE_SC_MESSAGE_BOX, err)
8564
}
8665
}
8766

0 commit comments

Comments
 (0)