func (s *TestSuite) SetUpTest(c *C) { s.driver = nil err := exec.Command("mkdir", "-p", devCfgRoot).Run() c.Assert(err, IsNil) err = exec.Command("mkdir", "-p", devDataRoot).Run() c.Assert(err, IsNil) s.dataFile = filepath.Join(devDataRoot, dataFile) s.metadataFile = filepath.Join(devDataRoot, metadataFile) err = exec.Command("truncate", "-s", strconv.Itoa(dataSize), s.dataFile).Run() c.Assert(err, IsNil) err = exec.Command("truncate", "-s", strconv.Itoa(metadataSize), s.metadataFile).Run() c.Assert(err, IsNil) s.dataDev, err = util.AttachLoopbackDevice(s.dataFile, false) c.Assert(err, IsNil) s.metadataDev, err = util.AttachLoopbackDevice(s.metadataFile, false) c.Assert(err, IsNil) s.initDriver(c) }
func (s *TestSuite) SetUpSuite(c *C) { logrus.SetLevel(logrus.DebugLevel) logrus.SetOutput(os.Stderr) var err error err = exec.Command("mkdir", "-p", devRoot).Run() c.Assert(err, IsNil) err = exec.Command("mkdir", "-p", devMount).Run() c.Assert(err, IsNil) // Prepare base image s.imageFile = filepath.Join(devRoot, imageFile) err = exec.Command("truncate", "-s", strconv.Itoa(volumeSize), s.imageFile).Run() c.Assert(err, IsNil) tmpDev, err := util.AttachLoopbackDevice(s.imageFile, false) c.Assert(err, IsNil) err = exec.Command("mkfs", "-t", "ext4", tmpDev).Run() c.Assert(err, IsNil) err = exec.Command("mount", tmpDev, devMount).Run() c.Assert(err, IsNil) err = exec.Command("touch", filepath.Join(devMount, imageTestFile)).Run() c.Assert(err, IsNil) err = exec.Command("umount", devMount).Run() c.Assert(err, IsNil) err = util.DetachLoopbackDevice(s.imageFile, tmpDev) c.Assert(err, IsNil) }