github.com/cloudfoundry-attic/garden-linux@v0.333.2-candidate/containerizer/system/system_suite_linux_test.go (about)

     1  package system_test
     2  
     3  import (
     4  	"io/ioutil"
     5  
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  
     9  	"encoding/json"
    10  	"testing"
    11  
    12  	"github.com/onsi/gomega/gexec"
    13  )
    14  
    15  var (
    16  	fakeMounterBin   string
    17  	fakeContainerBin string
    18  	tempDirPath      string
    19  )
    20  
    21  func TestSystem(t *testing.T) {
    22  	var beforeSuite struct {
    23  		FakeMounterPath   string
    24  		FakeContainerPath string
    25  		TempDirPath       string
    26  	}
    27  
    28  	SynchronizedBeforeSuite(func() []byte {
    29  		var err error
    30  		beforeSuite.FakeMounterPath, err = gexec.Build("github.com/cloudfoundry-incubator/garden-linux/containerizer/system/fake_mounter", "-race")
    31  		Expect(err).ToNot(HaveOccurred())
    32  
    33  		beforeSuite.FakeContainerPath, err = gexec.Build("github.com/cloudfoundry-incubator/garden-linux/containerizer/system/fake_container", "-race")
    34  		Expect(err).ToNot(HaveOccurred())
    35  
    36  		beforeSuite.TempDirPath, err = ioutil.TempDir("", "system-tempdir")
    37  		Expect(err).NotTo(HaveOccurred())
    38  
    39  		b, err := json.Marshal(beforeSuite)
    40  		Expect(err).ToNot(HaveOccurred())
    41  
    42  		return b
    43  	}, func(paths []byte) {
    44  		err := json.Unmarshal(paths, &beforeSuite)
    45  		Expect(err).ToNot(HaveOccurred())
    46  
    47  		fakeMounterBin = beforeSuite.FakeMounterPath
    48  		Expect(fakeMounterBin).NotTo(BeEmpty())
    49  
    50  		fakeContainerBin = beforeSuite.FakeContainerPath
    51  		Expect(fakeContainerBin).NotTo(BeEmpty())
    52  
    53  		tempDirPath = beforeSuite.TempDirPath
    54  		Expect(tempDirPath).NotTo(BeEmpty())
    55  	})
    56  
    57  	SynchronizedAfterSuite(func() {
    58  		//noop
    59  	}, func() {
    60  		gexec.CleanupBuildArtifacts()
    61  
    62  		// Cleaning up this directoy causes the VM to hang occasionally.
    63  		// Expect(os.RemoveAll(tempDirPath)).To(Succeed())
    64  	})
    65  
    66  	RegisterFailHandler(Fail)
    67  	RunSpecs(t, "System Suite")
    68  }