Commit a9725396 authored by Yasuhiro Matsumoto's avatar Yasuhiro Matsumoto Committed by Alex Brainman

os: change TestForkExec so it can run on windows

R=brainman, vcc, Joe Poirier, rsc
CC=golang-dev
https://golang.org/cl/2530041
parent a3bcf4b6
...@@ -410,15 +410,24 @@ func TestRename(t *testing.T) { ...@@ -410,15 +410,24 @@ func TestRename(t *testing.T) {
} }
func TestForkExec(t *testing.T) { func TestForkExec(t *testing.T) {
// TODO(brainman): Try to enable this test once ForkExec is working. var cmd, adir, expect string
if syscall.OS == "windows" { var args []string
return
}
r, w, err := Pipe() r, w, err := Pipe()
if err != nil { if err != nil {
t.Fatalf("Pipe: %v", err) t.Fatalf("Pipe: %v", err)
} }
pid, err := ForkExec("/bin/pwd", []string{"pwd"}, nil, "/", []*File{nil, w, Stderr}) if syscall.OS == "windows" {
cmd = Getenv("COMSPEC")
args = []string{Getenv("COMSPEC"), "/c cd"}
adir = Getenv("SystemRoot")
expect = Getenv("SystemRoot") + "\r\n"
} else {
cmd = "/bin/pwd"
args = []string{"pwd"}
adir = "/"
expect = "/\n"
}
pid, err := ForkExec(cmd, args, nil, adir, []*File{nil, w, Stderr})
if err != nil { if err != nil {
t.Fatalf("ForkExec: %v", err) t.Fatalf("ForkExec: %v", err)
} }
...@@ -427,9 +436,9 @@ func TestForkExec(t *testing.T) { ...@@ -427,9 +436,9 @@ func TestForkExec(t *testing.T) {
var b bytes.Buffer var b bytes.Buffer
io.Copy(&b, r) io.Copy(&b, r)
output := b.String() output := b.String()
expect := "/\n"
if output != expect { if output != expect {
t.Errorf("exec /bin/pwd returned %q wanted %q", output, expect) args[0] = cmd
t.Errorf("exec %q returned %q wanted %q", strings.Join(args, " "), output, expect)
} }
Wait(pid, 0) Wait(pid, 0)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment