golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.27k stars 17.7k forks source link

os/user: TestImpersonated and TestGroupIdsTestUser fail #70396

Closed qiulaidongfeng closed 1 week ago

qiulaidongfeng commented 1 week ago

Go version

go version devel go1.24-493edb2973 Sat Nov 16 15:10:05 2024 +0000 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=auto
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=D:\file\go-build
set GOENV=C:\Users\26454\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\file\gofile\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\file\gofile
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=D:\file\gofile\gogit\go1
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=local
set GOTOOLDIR=D:\file\gofile\gogit\go1\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.24-375129ab Sat Nov 2 04:21:27 2024 +0000
set GODEBUG=
set GOTELEMETRY=on
set GOTELEMETRYDIR=C:\Users\26454\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v3
set AR=ar
set CC=clang
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\file\gofile\gogit\go1\src\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\26454\AppData\Local\Temp\go-build4078409423=/tmp/go-build -gno-record-gcc-switches

What did you do?

go tool dist test -run=user

What did you see happen?

##### Test execution environment.
# GOARCH: amd64
# CPU: AMD Ryzen 7 7840HS w/ Radeon 780M Graphics
# GOOS: windows
# OS Version: 10.0.22631

##### Testing packages.
ok      os/user 0.139s

##### os/user with tag osusergo
--- FAIL: TestImpersonated (0.01s)
    user_windows_test.go:56: The handle is invalid.
--- FAIL: TestGroupIdsTestUser (0.03s)
    user_windows_test.go:76: The user name or password is incorrect.
FAIL
FAIL    os/user 0.172s
FAIL
2024/11/17 19:48:55 Failed: exit status 1

##### Testing without libgcc.
--- FAIL: TestImpersonated (0.03s)
    user_windows_test.go:76: The user name or password is incorrect.
    user_windows_test.go:64: The handle is invalid.
--- FAIL: TestGroupIdsTestUser (0.02s)
    user_windows_test.go:76: The user name or password is incorrect.
FAIL
FAIL    os/user 0.171s
FAIL
2024/11/17 19:48:55 Failed: exit status 1

##### internal linking, -buildmode=pie
--- FAIL: TestImpersonated (0.04s)
    user_windows_test.go:76: The user name or password is incorrect.
--- FAIL: TestGroupIdsTestUser (0.02s)
    user_windows_test.go:76: The user name or password is incorrect.
FAIL
FAIL    os/user 0.173s
FAIL
2024/11/17 19:48:55 Failed: exit status 1
go tool dist: FAILED

What did you expect to see?

test pass

gabyhelp commented 1 week ago

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

gopherbot commented 1 week ago

Change https://go.dev/cl/627877 mentions this issue: os/user: skip tests that create users when running on dev machines

qmuntal commented 1 week ago

The test failures are related to the test setup process rather than the tested code. I've sent CL 627877 with a fix for this issue. It basically skips the tests that creates users on dev machines (so they will only be run now in CI), as depending on the system configuration and permissions, recreating users can get much trickier.