Skip to content

os/exec: The TestImplicitPWD test fails when running under a soft link folder. #52537

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

Closed
zhangfannie opened this issue Apr 25, 2022 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 release-blocker Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@zhangfannie
Copy link
Contributor

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

$ go version
go version devel go1.19-96c8cc7fea Sun Apr 24 01:22:21 2022 +0000 linux/arm64

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="auto"
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/fanzha02/.cache/go-build"
GOENV="/home/fanzha02/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/fanzha02/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/fanzha02/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/fanzha02/sharefolder/golang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/fanzha02/sharefolder/golang/pkg/tool/linux_arm64"
GOVCS=""
GOVERSION="devel go1.19-96c8cc7fea Sun Apr 24 01:22:21 2022 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/fanzha02/sharefolder/golang/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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1974904193=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Run the TestImplicitPWD test under a soft link folder.

What did you expect to see?

pass

What did you see instead?

~/sharefolder/golang/src/os/exec$ ../../../bin/go test -run=TestImplicitPWD
--- FAIL: TestImplicitPWD (0.00s)
--- FAIL: TestImplicitPWD/empty (0.00s)
exec_posix_test.go:161: in

        `pwd` reported
            /mnt/share/homes/fanzha02/golang/src/os/exec
    exec_posix_test.go:163: want
            /home/fanzha02/sharefolder/golang/src/os/exec
--- FAIL: TestImplicitPWD/PWD (0.00s)
    exec_posix_test.go:161: in
            /home/fanzha02/sharefolder/golang/src/os/exec
        `pwd` reported
            /mnt/share/homes/fanzha02/golang/src/os/exec
    exec_posix_test.go:163: want
            /home/fanzha02/sharefolder/golang/src/os/exec
--- FAIL: TestImplicitPWD/dot (0.02s)
    exec_posix_test.go:161: in
            .
        `pwd` reported
            /mnt/share/homes/fanzha02/golang/src/os/exec
    exec_posix_test.go:163: want
            /home/fanzha02/sharefolder/golang/src/os/exec
--- FAIL: TestImplicitPWD/dotdot (0.02s)
    exec_posix_test.go:161: in
            ..
        `pwd` reported
            /mnt/share/homes/fanzha02/golang/src/os
    exec_posix_test.go:163: want
            /home/fanzha02/sharefolder/golang/src/os
--- FAIL: TestImplicitPWD/PWDdotdot (0.02s)
    exec_posix_test.go:161: in
            /home/fanzha02/sharefolder/golang/src/os/exec/..
        `pwd` reported
            /mnt/share/homes/fanzha02/golang/src/os
    exec_posix_test.go:163: want
            /home/fanzha02/sharefolder/golang/src/os

FAIL
exit status 1

@zhangfannie
Copy link
Contributor Author

zhangfannie commented Apr 25, 2022

The folder where I run the test is a soft link folder.

 > ls -all ~/sharefolder
 /home/fanzha02/sharefolder -> /mnt/share/homes/fanzha02

The TestImplicitPWD test is to compare whether the output of os.Getwd() and the output of exec.Command("pwd") are equal. When run it under a soft link folder, the os.Getwd() returns the directory of soft link folder, it is /home/fanzha02/sharefolder, the exec.Command("pwd") returns the directory of source folder, it is /mnt/share/homes/fanzha02, different outputs cause the test to fail.

I am not familar with the destination of the TestImplicitPWD test, is this failure expected? Thank you.

@zhangfannie
Copy link
Contributor Author

@bcmills

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 25, 2022
@bcmills
Copy link
Contributor

bcmills commented Apr 25, 2022

Heh, looks like /bin/pwd doesn't actually behave the same as the pwd built-in:

/tmp$ ln -s ~/go-review goroot-link

/tmp$ cd goroot-link/src/os/exec

/tmp/goroot-link/src/os/exec$ pwd
/tmp/goroot-link/src/os/exec

/tmp/goroot-link/src/os/exec$ /bin/pwd
/usr/local/google/home/bcmills/go-review/src/os/exec

This is fixed by CL 401934, but a more local fix seems possible.

@bcmills bcmills self-assigned this Apr 25, 2022
@bcmills bcmills added Testing An issue that has been verified to require only test changes, not just a test failure. release-blocker okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 labels Apr 25, 2022
@bcmills bcmills added this to the Go1.19 milestone Apr 25, 2022
@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 25, 2022
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 25, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/402158 mentions this issue: os/exec: in TestImplicitPWD, explicitly request the logical path

@rsc rsc unassigned bcmills Jun 22, 2022
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. okay-after-beta1 Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1 release-blocker Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

4 participants