diff options
| author | Alex Brainman <alex.brainman@gmail.com> | 2017-08-09 11:33:40 +1000 |
|---|---|---|
| committer | Alex Brainman <alex.brainman@gmail.com> | 2017-10-05 04:16:00 +0000 |
| commit | 66c03d39f3aa65ec522c41e56c569391786539a7 (patch) | |
| tree | a9951c90ce45fecb2cd9dbd2cc50c8f0419bf159 /src/path/filepath/path_windows_test.go | |
| parent | 56462d0f10f4d88f30e0b9a6763835c85c3cd632 (diff) | |
| download | go-66c03d39f3aa65ec522c41e56c569391786539a7.tar.xz | |
path/filepath: re-implement windows EvalSymlinks
CL 41834 used approach suggested by Raymond Chen in
https://blogs.msdn.microsoft.com/oldnewthing/20100212-00/?p=14963/
to implement os.Stat by getting Windows I/O manager
follow symbolic links.
Do the same for filepath.EvalSymlinks, when existing
strategy fails.
Updates #19922
Fixes #20506
Change-Id: I15f3d3a80256bae86ac4fb321fd8877e84d8834f
Reviewed-on: https://go-review.googlesource.com/55612
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/path/filepath/path_windows_test.go')
| -rw-r--r-- | src/path/filepath/path_windows_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go index d1b89bbc71..2ec5f5ef44 100644 --- a/src/path/filepath/path_windows_test.go +++ b/src/path/filepath/path_windows_test.go @@ -516,3 +516,37 @@ func TestWalkDirectorySymlink(t *testing.T) { testenv.MustHaveSymlink(t) testWalkMklink(t, "D") } + +func TestNTNamespaceSymlink(t *testing.T) { + output, _ := exec.Command("cmd", "/c", "mklink", "/?").Output() + if !strings.Contains(string(output), " /J ") { + t.Skip("skipping test because mklink command does not support junctions") + } + + tmpdir, err := ioutil.TempDir("", "TestNTNamespaceSymlink") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tmpdir) + + vol := filepath.VolumeName(tmpdir) + output, err = exec.Command("cmd", "/c", "mountvol", vol, "/L").CombinedOutput() + if err != nil { + t.Fatalf("failed to run mountvol %v /L: %v %q", vol, err, output) + } + target := strings.Trim(string(output), " \n\r") + + link := filepath.Join(tmpdir, "link") + output, err = exec.Command("cmd", "/c", "mklink", "/J", link, target).CombinedOutput() + if err != nil { + t.Fatalf("failed to run mklink %v %v: %v %q", link, target, err, output) + } + + got, err := filepath.EvalSymlinks(link) + if err != nil { + t.Fatal(err) + } + if want := vol + `\`; got != want { + t.Errorf(`EvalSymlinks(%q): got %q, want %q`, link, got, want) + } +} |
