Exemplo n.º 1
0
func (s *LxcUtilsSuite) TestRunningInsideLXCMalformedCgroupFile(c *gc.C) {
	baseDir := c.MkDir()
	cgroup := filepath.Join(baseDir, "cgroup")

	ft.File{"cgroup", malformedCgroupFile, 0400}.Create(c, baseDir)

	s.PatchValue(lxcutils.InitProcessCgroupFile, cgroup)
	_, err := lxcutils.RunningInsideLXC()
	c.Assert(err.Error(), gc.Equals, "malformed cgroup file")
}
Exemplo n.º 2
0
func (s *LxcUtilsSuite) TestRunningInsideLXCOnLXCContainer(c *gc.C) {
	baseDir := c.MkDir()
	cgroup := filepath.Join(baseDir, "cgroup")

	ft.File{"cgroup", lxcCgroupContents, 0400}.Create(c, baseDir)

	s.PatchValue(lxcutils.InitProcessCgroupFile, cgroup)
	runningInLXC, err := lxcutils.RunningInsideLXC()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(runningInLXC, jc.IsTrue)
}
Exemplo n.º 3
0
func (s *LxcUtilsSuite) TestRunningInsideLXCMissingCgroupFile(c *gc.C) {
	s.PatchValue(lxcutils.InitProcessCgroupFile, "")
	_, err := lxcutils.RunningInsideLXC()
	c.Assert(err.Error(), gc.Matches, "open : no such file or directory")
}