mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
8
vendor/golang.org/x/sys/windows/svc/svc_test.go
generated
vendored
8
vendor/golang.org/x/sys/windows/svc/svc_test.go
generated
vendored
@ -121,13 +121,9 @@ func TestExample(t *testing.T) {
|
||||
t.Fatalf("Delete failed: %s", err)
|
||||
}
|
||||
|
||||
cmd := `Get-Eventlog -LogName Application -Newest 100` +
|
||||
` | Where Source -eq "myservice"` +
|
||||
` | Select -first 10` +
|
||||
` | Format-table -HideTableHeaders -property ReplacementStrings`
|
||||
out, err := exec.Command("powershell", "-Command", cmd).CombinedOutput()
|
||||
out, err := exec.Command("wevtutil.exe", "qe", "Application", "/q:*[System[Provider[@Name='myservice']]]", "/rd:true", "/c:10").CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("powershell failed: %v\n%v", err, string(out))
|
||||
t.Fatalf("wevtutil failed: %v\n%v", err, string(out))
|
||||
}
|
||||
if want := strings.Join(append([]string{name}, args...), "-"); !strings.Contains(string(out), want) {
|
||||
t.Errorf("%q string does not contain %q", string(out), want)
|
||||
|
29
vendor/golang.org/x/sys/windows/syscall_windows_test.go
generated
vendored
29
vendor/golang.org/x/sys/windows/syscall_windows_test.go
generated
vendored
@ -10,7 +10,6 @@ import (
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
@ -54,34 +53,14 @@ func TestWin32finddata(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFormatMessage(t *testing.T) {
|
||||
dll := windows.MustLoadDLL("pdh.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.")
|
||||
}
|
||||
dll := windows.MustLoadDLL("netevent.dll")
|
||||
|
||||
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
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user