veyron/lib/testutil/integration: add BinaryFromPath function to TestEnvironment

Change-Id: I0c95dfa40dc314ac2fc5a795e1c11862f01c1f29
diff --git a/lib/testutil/integration/testdata/integration_test.go b/lib/testutil/integration/testdata/integration_test.go
new file mode 100644
index 0000000..97308d7
--- /dev/null
+++ b/lib/testutil/integration/testdata/integration_test.go
@@ -0,0 +1,28 @@
+package testdata
+
+import (
+	"testing"
+
+	"v.io/core/veyron/lib/modules"
+	"v.io/core/veyron/lib/testutil/integration"
+	_ "v.io/core/veyron/profiles"
+)
+
+func TestHelperProcess(t *testing.T) {
+	modules.DispatchInTest()
+}
+
+func TestBinaryFromPath(t *testing.T) {
+	env := integration.NewTestEnvironment(t)
+	defer env.Cleanup()
+
+	bash := env.BinaryFromPath("/bin/bash")
+	if want, got := "hello world\n", bash.Start("-c", "echo hello world").Output(); want != got {
+		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)
+	// }
+}
diff --git a/lib/testutil/integration/util.go b/lib/testutil/integration/util.go
index 208fad1..4324302 100644
--- a/lib/testutil/integration/util.go
+++ b/lib/testutil/integration/util.go
@@ -79,6 +79,12 @@
 	// Cleanup cleans up the environment and deletes all its artifacts.
 	Cleanup()
 
+	// BinaryFromPath returns a new TestBinary that, when started, will
+	// execute the executable or script at the given path.
+	//
+	// E.g. env.BinaryFromPath("/bin/bash").Start("-c", "echo hello world").Output() -> "hello world"
+	BinaryFromPath(path string) TestBinary
+
 	// BuildGoPkg expects a Go package path that identifies a "main"
 	// package and returns a TestBinary representing the newly built
 	// binary.
@@ -369,6 +375,15 @@
 	writeStringOrDie(e.t, file, fmt.Sprintf("<< Exited shell: %s\n", state.String()))
 }
 
+func (e *integrationTestEnvironment) BinaryFromPath(path string) TestBinary {
+	return &integrationTestBinary{
+		env:         e,
+		envVars:     nil,
+		path:        path,
+		cleanupFunc: func() {},
+	}
+}
+
 func (e *integrationTestEnvironment) BuildGoPkg(binary_path string) TestBinary {
 	e.t.Logf("building %s...", binary_path)
 	if cached_binary := e.builtBinaries[binary_path]; cached_binary != nil {