Sfoglia il codice sorgente

x/sys/windows/svc/mgr: skip tests when we are not authorised to manage services

It seems some Windows versions requires you to be
an Administrator to manage services. Just google for
"openscmanager access denied windows 2008" or similar.

Fixes golang/go#11156.

Change-Id: I4b09d244a61179ece7a1319234e5c3199423cbe9
Reviewed-on: https://go-review.googlesource.com/10933
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Alex Brainman 10 anni fa
parent
commit
b4e2899615
1 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 7 0
      windows/svc/mgr/mgr_test.go

+ 7 - 0
windows/svc/mgr/mgr_test.go

@@ -11,6 +11,7 @@ import (
 	"path/filepath"
 	"sort"
 	"strings"
+	"syscall"
 	"testing"
 	"time"
 
@@ -20,6 +21,9 @@ import (
 func TestOpenLanManServer(t *testing.T) {
 	m, err := mgr.Connect()
 	if err != nil {
+		if errno, ok := err.(syscall.Errno); ok && errno == syscall.ERROR_ACCESS_DENIED {
+			t.Skip("Skipping test: we don't have rights to manage services.")
+		}
 		t.Fatalf("SCM connection failed: %s", err)
 	}
 	defer m.Disconnect()
@@ -107,6 +111,9 @@ func TestMyService(t *testing.T) {
 
 	m, err := mgr.Connect()
 	if err != nil {
+		if errno, ok := err.(syscall.Errno); ok && errno == syscall.ERROR_ACCESS_DENIED {
+			t.Skip("Skipping test: we don't have rights to manage services.")
+		}
 		t.Fatalf("SCM connection failed: %s", err)
 	}
 	defer m.Disconnect()