Esempio n. 1
0
	"os/exec"
	"syscall"

	"github.com/cloudfoundry-incubator/garden-linux/container_daemon"
	"github.com/cloudfoundry-incubator/garden-linux/container_daemon/fake_ptyopener"
	"github.com/cloudfoundry-incubator/garden-linux/container_daemon/fake_runner"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Spawning", func() {
	var (
		runner    *fake_runner.FakeRunner
		ptyOpener *fake_ptyopener.FakePTYOpener
		spawner   *container_daemon.Spawn

		cmd         *exec.Cmd
		returnedFds []*os.File
		returnedErr error
		withTty     bool
	)

	BeforeEach(func() {
		withTty = false
		runner = new(fake_runner.FakeRunner)
		ptyOpener = new(fake_ptyopener.FakePTYOpener)

		cmd = exec.Command("foo")
		spawner = &container_daemon.Spawn{
			Runner: runner,
			PTY:    ptyOpener,
		}
	"fmt"
	"io/ioutil"
	"os"
	"os/exec"

	"github.com/cloudfoundry-incubator/garden-linux/container_daemon"
	"github.com/cloudfoundry-incubator/garden-linux/container_daemon/fake_ptyopener"
	"github.com/cloudfoundry-incubator/garden-linux/container_daemon/fake_runner"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Closing Pipes after Spawning", func() {
	var (
		runner            *fake_runner.FakeRunner
		ptyOpener         *fake_ptyopener.FakePTYOpener
		spawner           *container_daemon.Spawn
		originalOpenFiles int
	)

	openFileCount := func() int {
		procFd := fmt.Sprintf("/proc/%d/fd", os.Getpid())
		files, err := ioutil.ReadDir(procFd)
		Expect(err).ToNot(HaveOccurred())
		return len(files)
	}

	BeforeEach(func() {
		originalOpenFiles = openFileCount()

		runner = new(fake_runner.FakeRunner)
		ptyOpener = new(fake_ptyopener.FakePTYOpener)