Skip to content

net: some tests are skipped on Windows due to os.Getuid() always returns -1 #40886

Open
@zhangyoufu

Description

@zhangyoufu

Does this issue reproduce with the latest release?

Yes

What did you do?

go test -v net

What did you expect to see?

Run all tests that are applicable.

What did you see instead?

=== RUN   TestIPConnLocalName
--- PASS: TestIPConnLocalName (0.00s)
    iprawsock_test.go:93: skipping ip4:icmp test
    iprawsock_test.go:93: skipping ip4:icmp test
    iprawsock_test.go:93: skipping ip4:icmp test
=== RUN   TestIPConnRemoteName
--- SKIP: TestIPConnRemoteName (0.00s)
    iprawsock_test.go:109: ip:tcp test
=== RUN   TestIPv6MulticastListener
--- SKIP: TestIPv6MulticastListener (0.00s)
    listen_test.go:619: must be root

Related code

// testableNetwork reports whether network is testable on the current
// platform configuration.
func testableNetwork(network string) bool {
ss := strings.Split(network, ":")
switch ss[0] {
case "ip+nopriv":
case "ip", "ip4", "ip6":
switch runtime.GOOS {
case "plan9":
return false
default:
if os.Getuid() != 0 {
return false
}
}

go/src/net/listen_test.go

Lines 603 to 620 in d3a411b

// TestIPv6MulticastListener tests both single and double listen to a
// test listener with same address family, same group address and same
// port.
func TestIPv6MulticastListener(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
switch runtime.GOOS {
case "plan9":
t.Skipf("not supported on %s", runtime.GOOS)
case "solaris", "illumos":
t.Skipf("not supported on solaris or illumos, see issue 7399")
}
if !supportsIPv6() {
t.Skip("IPv6 is not supported")
}
if os.Getuid() != 0 {
t.Skip("must be root")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions