Merge pull request #69484 from ddebroy/ddebroy-winpipe1

Correctly handle named pipe host mounts for Windows
This commit is contained in:
k8s-ci-robot
2018-10-30 16:15:57 -07:00
committed by GitHub
4 changed files with 219 additions and 9 deletions

View File

@@ -2373,6 +2373,148 @@ func TestGetWindowsPath(t *testing.T) {
}
}
func TestIsWindowsUNCPath(t *testing.T) {
tests := []struct {
goos string
path string
isUNCPath bool
}{
{
goos: "linux",
path: `/usr/bin`,
isUNCPath: false,
},
{
goos: "linux",
path: `\\.\pipe\foo`,
isUNCPath: false,
},
{
goos: "windows",
path: `C:\foo`,
isUNCPath: false,
},
{
goos: "windows",
path: `\\server\share\foo`,
isUNCPath: true,
},
{
goos: "windows",
path: `\\?\server\share`,
isUNCPath: true,
},
{
goos: "windows",
path: `\\?\c:\`,
isUNCPath: true,
},
{
goos: "windows",
path: `\\.\pipe\valid_pipe`,
isUNCPath: true,
},
}
for _, test := range tests {
result := IsWindowsUNCPath(test.goos, test.path)
if result != test.isUNCPath {
t.Errorf("IsWindowsUNCPath(%v) returned (%v), expected (%v)", test.path, result, test.isUNCPath)
}
}
}
func TestIsWindowsLocalPath(t *testing.T) {
tests := []struct {
goos string
path string
isWindowsLocalPath bool
}{
{
goos: "linux",
path: `/usr/bin`,
isWindowsLocalPath: false,
},
{
goos: "linux",
path: `\\.\pipe\foo`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `C:\foo`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `:\foo`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `X:\foo`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `\\server\share\foo`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `\\?\server\share`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `\\?\c:\`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `\\.\pipe\valid_pipe`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `foo`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `:foo`,
isWindowsLocalPath: false,
},
{
goos: "windows",
path: `\foo`,
isWindowsLocalPath: true,
},
{
goos: "windows",
path: `\foo\bar`,
isWindowsLocalPath: true,
},
{
goos: "windows",
path: `/foo`,
isWindowsLocalPath: true,
},
{
goos: "windows",
path: `/foo/bar`,
isWindowsLocalPath: true,
},
}
for _, test := range tests {
result := IsWindowsLocalPath(test.goos, test.path)
if result != test.isWindowsLocalPath {
t.Errorf("isWindowsLocalPath(%v) returned (%v), expected (%v)", test.path, result, test.isWindowsLocalPath)
}
}
}
func TestMakeAbsolutePath(t *testing.T) {
tests := []struct {
goos string