test-lock.py: add a lock wrapper that allows faking the PID
This will be used in upcoming patches to create locks that appear as if they're
being created by child processes.
--- a/tests/test-lock.py Thu Sep 24 21:26:37 2015 -0700
+++ b/tests/test-lock.py Thu Sep 24 20:22:59 2015 -0700
@@ -12,6 +12,15 @@
testlockname = 'testlock'
+class lockwrapper(lock.lock):
+ def __init__(self, pidoffset, *args, **kwargs):
+ # lock.lock.__init__() calls lock(), so the pidoffset assignment needs
+ # to be earlier
+ self._pidoffset = pidoffset
+ super(lockwrapper, self).__init__(*args, **kwargs)
+ def _getpid(self):
+ return os.getpid() + self._pidoffset
+
class teststate(object):
def __init__(self, testcase, dir):
self._testcase = testcase