summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorSoren Hansen <soren@linux2go.dk>2011-03-09 10:30:18 +0100
committerSoren Hansen <soren@linux2go.dk>2011-03-09 10:30:18 +0100
commit7d31fe9ef316f49379818259a55a84deb5b850cd (patch)
tree84d5cd6acd168ace72b1400fbf9fc9bb9ea276c6 /nova
parent9a61a49eee126b333f82c3b129f88996e9f4d97f (diff)
downloadnova-7d31fe9ef316f49379818259a55a84deb5b850cd.tar.gz
nova-7d31fe9ef316f49379818259a55a84deb5b850cd.tar.xz
nova-7d31fe9ef316f49379818259a55a84deb5b850cd.zip
Stop assuming anything about the order in which the two processes are scheduled.
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/test_misc.py47
1 files changed, 25 insertions, 22 deletions
diff --git a/nova/tests/test_misc.py b/nova/tests/test_misc.py
index 9f572b58e..a658e4978 100644
--- a/nova/tests/test_misc.py
+++ b/nova/tests/test_misc.py
@@ -71,30 +71,33 @@ class LockTestCase(test.TestCase):
"got mangled")
def test_synchronized(self):
- rpipe, wpipe = os.pipe()
+ rpipe1, wpipe1 = os.pipe()
+ rpipe2, wpipe2 = os.pipe()
+
+ @synchronized('testlock')
+ def f(rpipe, wpipe):
+ try:
+ os.write(wpipe, "foo")
+ except OSError, e:
+ self.assertEquals(e.errno, errno.EPIPE)
+ return
+
+ rfds, _, __ = select.select([rpipe], [], [], 1)
+ self.assertEquals(len(rfds), 0, "The other process, which was"
+ " supposed to be locked, "
+ "wrote on its end of the "
+ "pipe")
+ os.close(rpipe)
+
pid = os.fork()
if pid > 0:
- os.close(wpipe)
-
- @synchronized('testlock')
- def f():
- rfds, _, __ = select.select([rpipe], [], [], 1)
- self.assertEquals(len(rfds), 0, "The other process, which was"
- " supposed to be locked, "
- "wrote on its end of the "
- "pipe")
- os.close(rpipe)
-
- f()
+ os.close(wpipe1)
+ os.close(rpipe2)
+
+ f(rpipe1, wpipe2)
else:
- os.close(rpipe)
+ os.close(rpipe1)
+ os.close(wpipe2)
- @synchronized('testlock')
- def g():
- try:
- os.write(wpipe, "foo")
- except OSError, e:
- self.assertEquals(e.errno, errno.EPIPE)
- return
- g()
+ f(rpipe2, wpipe1)
os._exit(0)