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: TestProgWideChdir failing on Plan 9 #10422

Closed
0intro opened this issue Apr 11, 2015 · 0 comments
Closed

os: TestProgWideChdir failing on Plan 9 #10422

0intro opened this issue Apr 11, 2015 · 0 comments
Assignees
Milestone

Comments

@0intro
Copy link
Member

@0intro 0intro commented Apr 11, 2015

Running TestProgWideChdir (CL 6382) on Plan 9 leads to a failure
of TestAppend and TestSameFile.

TestAppend and TestSameFile are failing because they are accessing
a file from a relative path, but the current working directory has been
deleted at the end of TestProgWideChdir.

% go test -v -run 'Test(ProgWideChdir|Append|SameFile)'
=== RUN TestProgWideChdir
Chdir /tmp/test401904176
 → getwd /tmp/test401904176
Chdir /usr/go/src/os
  → getwd /usr/go/src/os
Remove /tmp/test401904176
 → getwd /usr/go/src/os
 → Getwd /usr/go/src/os
--- PASS: TestProgWideChdir (0.03s)
=== RUN TestAppend
fixwdLocked
 → getwd err file has been removed
fixwdLocked
 → getwd err file has been removed
Remove append.txt
 → getwd
 → Getwd /usr/go/src/os
--- FAIL: TestAppend (0.01s)
    os_test.go:1330: Open: open append.txt: 'append.txt' file has been removed
=== RUN TestSameFile
fixwdLocked getwd err file has been removed
--- FAIL: TestSameFile (0.00s)
    os_test.go:1416: Create(a): open a: 'a' file has been removed
FAIL
exit status: 'os.test 631609: 1'
FAIL    os  0.095s

At the end of TestProgWideChdir, Chdir is calling chdir to change
the working directory for the current process and set wdStr.
Then the directory is removed.

In TestAppend, it calls Remove, which should fix the working directory.
However, fixwdLocked calls getwd which returns an error, because
the working directory was not yet changed in this process and this
directory was removed.

https://github.com/golang/go/blob/bc9748ee6b/src/syscall/pwd_plan9.go#L28

Since getwd is returning an error, fixwdLocked returns and never calls
chdir(wdStr) to fix the working directory.

I think we should ignore errors from getwd in fixwdLocked to always
be able to fix the working directory.

@0intro 0intro added the repo-main label Apr 11, 2015
@0intro 0intro self-assigned this Apr 11, 2015
@0intro 0intro added this to the Go1.5 milestone Apr 11, 2015
@0intro 0intro closed this in 7d3f81a Apr 12, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.