Commit ef7e8499 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler
Browse files

Don't create temp directories for lock testing



There were not used anyway.
Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 42effe0f
Pipeline #72733 passed with stage
in 1 minute and 41 seconds
...@@ -27,7 +27,6 @@ from __future__ import absolute_import ...@@ -27,7 +27,6 @@ from __future__ import absolute_import
import copy import copy
import os import os
import tempfile
import types import types
import unittest import unittest
...@@ -57,7 +56,7 @@ class lockwrapper(lock.lock): ...@@ -57,7 +56,7 @@ class lockwrapper(lock.lock):
class teststate(object): class teststate(object):
def __init__(self, dir, pidoffset=0): def __init__(self, pidoffset=0):
self._acquirecalled = False self._acquirecalled = False
self._releasecalled = False self._releasecalled = False
self._postreleasecalled = False self._postreleasecalled = False
...@@ -131,7 +130,7 @@ class teststate(object): ...@@ -131,7 +130,7 @@ class teststate(object):
class testlock(unittest.TestCase): class testlock(unittest.TestCase):
def testlock(self): def testlock(self):
state = teststate(tempfile.mkdtemp(dir=os.getcwd())) state = teststate()
lock = state.makelock() lock = state.makelock()
state.assertacquirecalled(self, True) state.assertacquirecalled(self, True)
lock.release() lock.release()
...@@ -140,7 +139,7 @@ class testlock(unittest.TestCase): ...@@ -140,7 +139,7 @@ class testlock(unittest.TestCase):
state.assertlockexists(self, False) state.assertlockexists(self, False)
def testrecursivelock(self): def testrecursivelock(self):
state = teststate(tempfile.mkdtemp(dir=os.getcwd())) state = teststate()
lock = state.makelock() lock = state.makelock()
state.assertacquirecalled(self, True) state.assertacquirecalled(self, True)
...@@ -160,7 +159,7 @@ class testlock(unittest.TestCase): ...@@ -160,7 +159,7 @@ class testlock(unittest.TestCase):
state.assertlockexists(self, False) state.assertlockexists(self, False)
def testlockfork(self): def testlockfork(self):
state = teststate(tempfile.mkdtemp(dir=os.getcwd())) state = teststate()
lock = state.makelock() lock = state.makelock()
state.assertacquirecalled(self, True) state.assertacquirecalled(self, True)
...@@ -179,8 +178,7 @@ class testlock(unittest.TestCase): ...@@ -179,8 +178,7 @@ class testlock(unittest.TestCase):
state.assertlockexists(self, False) state.assertlockexists(self, False)
def testinheritlock(self): def testinheritlock(self):
d = tempfile.mkdtemp(dir=os.getcwd()) parentstate = teststate()
parentstate = teststate(d)
parentlock = parentstate.makelock() parentlock = parentstate.makelock()
parentstate.assertacquirecalled(self, True) parentstate.assertacquirecalled(self, True)
...@@ -190,7 +188,7 @@ class testlock(unittest.TestCase): ...@@ -190,7 +188,7 @@ class testlock(unittest.TestCase):
parentstate.assertpostreleasecalled(self, False) parentstate.assertpostreleasecalled(self, False)
parentstate.assertlockexists(self, True) parentstate.assertlockexists(self, True)
childstate = teststate(d, pidoffset=1) childstate = teststate(pidoffset=1)
childlock = childstate.makelock(parentlock=lockname) childlock = childstate.makelock(parentlock=lockname)
childstate.assertacquirecalled(self, True) childstate.assertacquirecalled(self, True)
...@@ -209,8 +207,7 @@ class testlock(unittest.TestCase): ...@@ -209,8 +207,7 @@ class testlock(unittest.TestCase):
parentstate.assertlockexists(self, False) parentstate.assertlockexists(self, False)
def testmultilock(self): def testmultilock(self):
d = tempfile.mkdtemp(dir=os.getcwd()) state0 = teststate()
state0 = teststate(d)
lock0 = state0.makelock() lock0 = state0.makelock()
state0.assertacquirecalled(self, True) state0.assertacquirecalled(self, True)
...@@ -219,7 +216,7 @@ class testlock(unittest.TestCase): ...@@ -219,7 +216,7 @@ class testlock(unittest.TestCase):
state0.assertpostreleasecalled(self, False) state0.assertpostreleasecalled(self, False)
state0.assertlockexists(self, True) state0.assertlockexists(self, True)
state1 = teststate(d, pidoffset=1) state1 = teststate(pidoffset=1)
lock1 = state1.makelock(parentlock=lock0name) lock1 = state1.makelock(parentlock=lock0name)
state1.assertacquirecalled(self, True) state1.assertacquirecalled(self, True)
...@@ -229,7 +226,7 @@ class testlock(unittest.TestCase): ...@@ -229,7 +226,7 @@ class testlock(unittest.TestCase):
# name # name
self.assertEqual(lock0name, lock1name) self.assertEqual(lock0name, lock1name)
state2 = teststate(d, pidoffset=2) state2 = teststate(pidoffset=2)
lock2 = state2.makelock(parentlock=lock1name) lock2 = state2.makelock(parentlock=lock1name)
state2.assertacquirecalled(self, True) state2.assertacquirecalled(self, True)
...@@ -250,14 +247,13 @@ class testlock(unittest.TestCase): ...@@ -250,14 +247,13 @@ class testlock(unittest.TestCase):
lock0.release() lock0.release()
def testinheritlockfork(self): def testinheritlockfork(self):
d = tempfile.mkdtemp(dir=os.getcwd()) parentstate = teststate()
parentstate = teststate(d)
parentlock = parentstate.makelock() parentlock = parentstate.makelock()
parentstate.assertacquirecalled(self, True) parentstate.assertacquirecalled(self, True)
# set up lock inheritance # set up lock inheritance
with parentlock.inherit() as lockname: with parentlock.inherit() as lockname:
childstate = teststate(d, pidoffset=1) childstate = teststate(pidoffset=1)
childlock = childstate.makelock(parentlock=lockname) childlock = childstate.makelock(parentlock=lockname)
childstate.assertacquirecalled(self, True) childstate.assertacquirecalled(self, True)
...@@ -278,8 +274,7 @@ class testlock(unittest.TestCase): ...@@ -278,8 +274,7 @@ class testlock(unittest.TestCase):
parentlock.release() parentlock.release()
def testinheritcheck(self): def testinheritcheck(self):
d = tempfile.mkdtemp(dir=os.getcwd()) state = teststate()
state = teststate(d)
def check(): def check():
raise error.LockInheritanceContractViolation('check failed') raise error.LockInheritanceContractViolation('check failed')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment