コード例 #1
0
 def test_release_not_acquired(self):
     fs = FakeSanlock()
     fs.write_resource("lockspace", "resource", [("path", 1048576)])
     fs.add_lockspace("lockspace", 1, "path")
     fd = fs.register()
     with self.assertRaises(fs.SanlockException) as e:
         fs.release("lockspace", "resource", [("path", 1048576)], slkfd=fd)
     self.assertEqual(e.exception.errno, errno.EPERM)
コード例 #2
0
 def test_release(self):
     fs = FakeSanlock()
     fs.write_resource("lockspace", "resource", [("path", 1048576)])
     fs.add_lockspace("lockspace", 1, "path")
     fd = fs.register()
     fs.acquire("lockspace", "resource", [("path", 1048576)], slkfd=fd)
     fs.release("lockspace", "resource", [("path", 1048576)], slkfd=fd)
     res = fs.read_resource("path", 1048576)
     self.assertFalse(res["acquired"], "resource is not acquired")