aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec/exec_windows_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/exec/exec_windows_test.go')
-rw-r--r--src/os/exec/exec_windows_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/os/exec/exec_windows_test.go b/src/os/exec/exec_windows_test.go
new file mode 100644
index 0000000000..fbccffec0e
--- /dev/null
+++ b/src/os/exec/exec_windows_test.go
@@ -0,0 +1,43 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build windows
+// +build windows
+
+package exec_test
+
+import (
+ "io"
+ "os"
+ "strconv"
+ "syscall"
+ "testing"
+)
+
+func TestPipePassing(t *testing.T) {
+ r, w, err := os.Pipe()
+ if err != nil {
+ t.Error(err)
+ }
+ const marker = "arrakis, dune, desert planet"
+ childProc := helperCommand(t, "pipehandle", strconv.FormatUint(uint64(w.Fd()), 16), marker)
+ childProc.SysProcAttr = &syscall.SysProcAttr{AdditionalInheritedHandles: []syscall.Handle{syscall.Handle(w.Fd())}}
+ err = childProc.Start()
+ if err != nil {
+ t.Error(err)
+ }
+ w.Close()
+ response, err := io.ReadAll(r)
+ if err != nil {
+ t.Error(err)
+ }
+ r.Close()
+ if string(response) != marker {
+ t.Errorf("got %q; want %q", string(response), marker)
+ }
+ err = childProc.Wait()
+ if err != nil {
+ t.Error(err)
+ }
+}