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
import copy
import os
import tempfile
import types
import unittest
......@@ -57,7 +56,7 @@ class lockwrapper(lock.lock):
class teststate(object):
def __init__(self, dir, pidoffset=0):
def __init__(self, pidoffset=0):
self._acquirecalled = False
self._releasecalled = False
self._postreleasecalled = False
......@@ -131,7 +130,7 @@ class teststate(object):
class testlock(unittest.TestCase):
def testlock(self):
state = teststate(tempfile.mkdtemp(dir=os.getcwd()))
state = teststate()
lock = state.makelock()
state.assertacquirecalled(self, True)
lock.release()
......@@ -140,7 +139,7 @@ class testlock(unittest.TestCase):
state.assertlockexists(self, False)
def testrecursivelock(self):
state = teststate(tempfile.mkdtemp(dir=os.getcwd()))
state = teststate()
lock = state.makelock()
state.assertacquirecalled(self, True)
......@@ -160,7 +159,7 @@ class testlock(unittest.TestCase):
state.assertlockexists(self, False)
def testlockfork(self):
state = teststate(tempfile.mkdtemp(dir=os.getcwd()))
state = teststate()
lock = state.makelock()
state.assertacquirecalled(self, True)
......@@ -179,8 +178,7 @@ class testlock(unittest.TestCase):
state.assertlockexists(self, False)
def testinheritlock(self):
d = tempfile.mkdtemp(dir=os.getcwd())
parentstate = teststate(d)
parentstate = teststate()
parentlock = parentstate.makelock()
parentstate.assertacquirecalled(self, True)
......@@ -190,7 +188,7 @@ class testlock(unittest.TestCase):
parentstate.assertpostreleasecalled(self, False)
parentstate.assertlockexists(self, True)
childstate = teststate(d, pidoffset=1)
childstate = teststate(pidoffset=1)
childlock = childstate.makelock(parentlock=lockname)
childstate.assertacquirecalled(self, True)
......@@ -209,8 +207,7 @@ class testlock(unittest.TestCase):
parentstate.assertlockexists(self, False)
def testmultilock(self):
d = tempfile.mkdtemp(dir=os.getcwd())
state0 = teststate(d)
state0 = teststate()
lock0 = state0.makelock()
state0.assertacquirecalled(self, True)
......@@ -219,7 +216,7 @@ class testlock(unittest.TestCase):
state0.assertpostreleasecalled(self, False)
state0.assertlockexists(self, True)
state1 = teststate(d, pidoffset=1)
state1 = teststate(pidoffset=1)
lock1 = state1.makelock(parentlock=lock0name)
state1.assertacquirecalled(self, True)
......@@ -229,7 +226,7 @@ class testlock(unittest.TestCase):
# name
self.assertEqual(lock0name, lock1name)
state2 = teststate(d, pidoffset=2)
state2 = teststate(pidoffset=2)
lock2 = state2.makelock(parentlock=lock1name)
state2.assertacquirecalled(self, True)
......@@ -250,14 +247,13 @@ class testlock(unittest.TestCase):
lock0.release()
def testinheritlockfork(self):
d = tempfile.mkdtemp(dir=os.getcwd())
parentstate = teststate(d)
parentstate = teststate()
parentlock = parentstate.makelock()
parentstate.assertacquirecalled(self, True)
# set up lock inheritance
with parentlock.inherit() as lockname:
childstate = teststate(d, pidoffset=1)
childstate = teststate(pidoffset=1)
childlock = childstate.makelock(parentlock=lockname)
childstate.assertacquirecalled(self, True)
......@@ -278,8 +274,7 @@ class testlock(unittest.TestCase):
parentlock.release()
def testinheritcheck(self):
d = tempfile.mkdtemp(dir=os.getcwd())
state = teststate(d)
state = teststate()
def check():
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