Commit dcdaa632 authored by Jordan Rhee's avatar Jordan Rhee Committed by Brad Fitzpatrick

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/154560Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 4d1cda03
...@@ -10,7 +10,6 @@ import ( ...@@ -10,7 +10,6 @@ import (
"path/filepath" "path/filepath"
"syscall" "syscall"
"testing" "testing"
"unsafe"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
...@@ -54,34 +53,14 @@ func TestWin32finddata(t *testing.T) { ...@@ -54,34 +53,14 @@ func TestWin32finddata(t *testing.T) {
} }
func TestFormatMessage(t *testing.T) { func TestFormatMessage(t *testing.T) {
dll := windows.MustLoadDLL("pdh.dll") dll := windows.MustLoadDLL("netevent.dll")
pdhOpenQuery := func(datasrc *uint16, userdata uint32, query *windows.Handle) (errno uintptr) {
r0, _, _ := syscall.Syscall(dll.MustFindProc("PdhOpenQueryW").Addr(), 3, uintptr(unsafe.Pointer(datasrc)), uintptr(userdata), uintptr(unsafe.Pointer(query)))
return r0
}
pdhCloseQuery := func(query windows.Handle) (errno uintptr) {
r0, _, _ := syscall.Syscall(dll.MustFindProc("PdhCloseQuery").Addr(), 1, uintptr(query), 0, 0)
return r0
}
var q windows.Handle
name, err := windows.UTF16PtrFromString("no_such_source")
if err != nil {
t.Fatal(err)
}
errno := pdhOpenQuery(name, 0, &q)
if errno == 0 {
pdhCloseQuery(q)
t.Fatal("PdhOpenQuery succeeded, but expected to fail.")
}
const TITLE_SC_MESSAGE_BOX uint32 = 0xC0001B75
const flags uint32 = syscall.FORMAT_MESSAGE_FROM_HMODULE | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS const flags uint32 = syscall.FORMAT_MESSAGE_FROM_HMODULE | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS
buf := make([]uint16, 300) buf := make([]uint16, 300)
_, err = windows.FormatMessage(flags, uintptr(dll.Handle), uint32(errno), 0, buf, nil) _, err := windows.FormatMessage(flags, uintptr(dll.Handle), TITLE_SC_MESSAGE_BOX, 0, buf, nil)
if err != nil { if err != nil {
t.Fatalf("FormatMessage for handle=%x and errno=%x failed: %v", dll.Handle, errno, err) t.Fatalf("FormatMessage for handle=%x and errno=%x failed: %v", dll.Handle, TITLE_SC_MESSAGE_BOX, err)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment