Esempio n. 1
0
 def test_write(self):
     value = "something"
     cgroup_fs = cgroup.CgroupFs(self.scratch)
     cgroup_fs.write(value, "foo")
     with open(os.path.join(self.scratch, value), 'r') as f:
         contents = f.read()
     self.assertEquals(contents, "foo")
Esempio n. 2
0
 def test_read(self):
     value = "something"
     with open(os.path.join(self.scratch, value), 'w') as f:
         f.write("foo 1\n")
         f.write("bar 2\n")
         f.write("baz 3\n")
     cgroup_fs = cgroup.CgroupFs(self.scratch)
     self.assertEquals(list(cgroup_fs.read(value)),
                       [['foo', '1'], ['bar', '2'], ['baz', '3']])
Esempio n. 3
0
 def test_write_fail(self):
     badscratch = os.path.join(self.scratch, 'badpath')
     cgroup_fs = cgroup.CgroupFs(badscratch)
     cgroup_fs.write('garbage', "foo")
     self.assertFalse(os.path.exists(badscratch))
Esempio n. 4
0
 def test_read_fail(self):
     cgroup_fs = cgroup.CgroupFs(self.scratch)
     self.assertEquals(list(cgroup_fs.read('nonexistent')), [])