Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: hostname path hardcoded as /bin/hostname in test #52402

Closed
silkeh opened this issue Apr 18, 2022 · 4 comments
Closed

os: hostname path hardcoded as /bin/hostname in test #52402

silkeh opened this issue Apr 18, 2022 · 4 comments
Labels
NeedsFix Testing
Milestone

Comments

@silkeh
Copy link
Contributor

@silkeh silkeh commented Apr 18, 2022

What version of Go are you using (go version)?

$ go version
go version devel go1.19-740a490f71 Sun Apr 17 01:33:13 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="$HOME/.cache/go-build"
GOENV="$HOME/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="$HOME/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="$HOME/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="$HOME/Development/go/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="$HOME/Development/go/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.19-740a490f71 Sun Apr 17 01:33:13 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="$HOME/Development/go/go/src/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1509945181=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Run the TestHostname test for the OS package:

$HOME/Development/go/go/bin/go test os -run TestHostname -v

Note that hostname is located at /usr/bin/hostname.

What did you expect to see?

$HOME/Development/go/go/bin/go test os -run TestHostname -v
=== RUN   TestHostname
--- PASS: TestHostname (0.00s)
PASS
ok  	os	0.003s

What did you see instead?

=== RUN   TestHostname
    os_test.go:1687: skipping test; test requires /bin/hostname but it does not exist
--- SKIP: TestHostname (0.00s)
PASS
ok  	os	0.002s

This is caused by hostname being hardcoded as /bin/hostname (see here).

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 18, 2022

Change https://go.dev/cl/400794 mentions this issue: os: look up hostname from PATH in test

@thanm thanm added the NeedsInvestigation label Apr 18, 2022
@thanm
Copy link
Contributor

@thanm thanm commented Apr 18, 2022

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Apr 18, 2022

Which system doesn't have /bin/hostname? A skip isn't a terrible outcome, at least. (A failure would be more concerning.)

@silkeh
Copy link
Contributor Author

@silkeh silkeh commented Apr 18, 2022

Which system doesn't have /bin/hostname? A skip isn't a terrible outcome, at least. (A failure would be more concerning.)

My systems (running Solus) have hostname installed in /usr/bin, which seems valid to me. I agree that a skip isn't a terrible outcome, but I also think the test should check PATH for the location of hostname instead of having /bin/hostname hardcoded (see linked patch).

@dmitshur dmitshur added NeedsFix Testing and removed NeedsInvestigation labels May 18, 2022
@dmitshur dmitshur added this to the Go1.19 milestone May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix Testing
Projects
None yet
Development

No branches or pull requests

5 participants