func (s *RunVSuite) SetUpSuite(c *check.C) { var err error s.binaryPath, err = exec.LookPath(binaryName) c.Assert(err, checker.IsNil) // Prepare bundle and rootfs s.bundlePath = c.MkDir() rootfs := filepath.Join(s.bundlePath, rootfsName) err = os.Mkdir(rootfs, 777) c.Assert(err, checker.IsNil) // untar busybox image tar file into bundle/rootfs dir busyboxTarPath := filepath.Join(testDataDir, busyboxTarName) _, err = os.Stat(busyboxTarPath) c.Assert(err, checker.IsNil) cmd := exec.Command("tar", "-xf", busyboxTarPath, "-C", rootfs) var errStr bytes.Buffer cmd.Stderr = &errStr err = cmd.Run() c.Assert(err, checker.IsNil, check.Commentf("errors: %s", errStr.String())) // set kernel path s.kernelPath, err = filepath.Abs(filepath.Join(testDataDir, kernelName)) c.Assert(err, checker.IsNil) _, err = os.Stat(s.kernelPath) c.Assert(err, checker.IsNil) // set initrd path s.initrdPath, err = filepath.Abs(filepath.Join(testDataDir, initrdName)) c.Assert(err, checker.IsNil) _, err = os.Stat(s.initrdPath) c.Assert(err, checker.IsNil) // write spec into config file s.configPath = filepath.Join(s.bundlePath, configFileName) specData, err := json.MarshalIndent(defaultTestSpec, "", "\t") c.Assert(err, checker.IsNil) err = ioutil.WriteFile(s.configPath, specData, 0666) c.Assert(err, checker.IsNil) }