Merge "Fix bugs in IPv6 address handling."
diff --git a/lib/testutil/integration/testdata/integration_test.go b/lib/testutil/integration/testdata/integration_test.go
index 97308d7..5d11ed6 100644
--- a/lib/testutil/integration/testdata/integration_test.go
+++ b/lib/testutil/integration/testdata/integration_test.go
@@ -1,6 +1,8 @@
package testdata
import (
+ "bufio"
+ "bytes"
"testing"
"v.io/core/veyron/lib/modules"
@@ -21,8 +23,10 @@
t.Fatalf("unexpected output, want %s, got %s", want, got)
}
- // TODO(sjr): revive this once stderr handling is fixed.
- // if want, got := "hello world\n", bash.Start("-c", "echo hello world 1>&2").ErrorOutput(); want != got {
- // t.Fatalf("unexpected output, want %s, got %s", want, got)
- // }
+ inv := bash.Start("-c", "echo hello world 1>&2")
+ var buf bytes.Buffer
+ inv.WaitOrDie(nil, bufio.NewWriter(&buf))
+ if want, got := "hello world\n", string(buf.Bytes()); want != got {
+ t.Fatalf("unexpected output, want %s, got %s", want, got)
+ }
}
diff --git a/lib/testutil/integration/util.go b/lib/testutil/integration/util.go
index 8f5b314..0511b15 100644
--- a/lib/testutil/integration/util.go
+++ b/lib/testutil/integration/util.go
@@ -126,19 +126,25 @@
WithEnv(env []string) TestBinary
}
+// Invocation represents a single invocation of a TestBinary.
+//
+// Any bytes written by the invocation to its standard error may be recovered
+// using the Wait or WaitOrDie functions.
+//
+// For example:
+// bin := env.BinaryFromPath("/bin/bash")
+// inv := bin.Start("-c", "echo hello world 1>&2")
+// var buf bytes.Buffer
+// inv.WaitOrDie(nil, bufio.NewWriter(&buf))
+// // buf.Bytes() now contains 'hello world\n'
type Invocation interface {
Stdin() io.Writer
Stdout() io.Reader
- Stderr() io.Reader
// Output reads the invocation's stdout until EOF and then returns what
// was read as a string.
Output() string
- // ErrorOutput reads the invocation's stderr until EOF and then returns
- // what was read as a string.
- ErrorOutput() string
-
// Sends the given signal to this invocation. It is up to the test
// author to decide whether failure to deliver the signal is fatal to
// the test.
@@ -232,14 +238,6 @@
return readerToString(i.env.t, i.Stdout())
}
-func (i *integrationTestBinaryInvocation) Stderr() io.Reader {
- return (*i.handle).Stderr()
-}
-
-func (i *integrationTestBinaryInvocation) ErrorOutput() string {
- return readerToString(i.env.t, i.Stderr())
-}
-
func (i *integrationTestBinaryInvocation) Wait(stdout, stderr io.Writer) error {
return (*i.handle).Shutdown(stdout, stderr)
}
diff --git a/runtimes/google/rt/security.go b/runtimes/google/rt/security.go
index e3cc484..fd3226a 100644
--- a/runtimes/google/rt/security.go
+++ b/runtimes/google/rt/security.go
@@ -81,8 +81,8 @@
return -1, nil
}
ifd, err := strconv.Atoi(fd)
- if err == nil && handle != nil {
- // If we're using a handle, children can't inherit the agent.
+ if err == nil {
+ // Don't let children accidentally inherit the agent connection.
syscall.CloseOnExec(ifd)
}
return ifd, err
diff --git a/tools/naming/simulator/testdata/integration_test.go b/tools/naming/simulator/testdata/integration_test.go
index 9cee3bf..be038a7 100644
--- a/tools/naming/simulator/testdata/integration_test.go
+++ b/tools/naming/simulator/testdata/integration_test.go
@@ -1,6 +1,8 @@
package testdata
import (
+ "bufio"
+ "bytes"
"fmt"
"io/ioutil"
"os"
@@ -34,8 +36,10 @@
}
for _, script := range scripts {
invocation := binary.Start("--file", script)
- output, errorOutput := invocation.Output(), invocation.ErrorOutput()
- if err := invocation.Wait(nil, nil); err != nil {
+ output := invocation.Output()
+ var buf bytes.Buffer
+ if err := invocation.Wait(nil, bufio.NewWriter(&buf)); err != nil {
+ errorOutput := string(buf.Bytes())
fmt.Fprintf(os.Stderr, "Script %v failed\n", script)
fmt.Fprintln(os.Stderr, output)
fmt.Fprintln(os.Stderr, errorOutput)