diff options
| author | Monty Taylor <mordred@inaugust.com> | 2012-10-25 11:39:31 -0700 |
|---|---|---|
| committer | Monty Taylor <mordred@inaugust.com> | 2012-10-25 11:40:10 -0700 |
| commit | b0529de679056935a48b6a1e9879765ffdc1799b (patch) | |
| tree | 5697906c085d1bca27786a240e585c700879ab25 | |
| parent | 4f6571b38b428b5c72c76a38440a7d62952e381f (diff) | |
Use cat instead of sleep for rootwrap test.
Sleep is a race condition. cat will block indefinitely.
Fixes bug 1071443
Change-Id: Ia731580ed335e53646aa67b2e7b9424118f0c9d5
| -rw-r--r-- | nova/tests/test_nova_rootwrap.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/nova/tests/test_nova_rootwrap.py b/nova/tests/test_nova_rootwrap.py index 10d528613..e9a48dbb4 100644 --- a/nova/tests/test_nova_rootwrap.py +++ b/nova/tests/test_nova_rootwrap.py @@ -66,9 +66,11 @@ class RootwrapTestCase(test.TestCase): @test.skip_if(not os.path.exists("/proc/%d" % os.getpid()), "Test requires /proc filesystem (procfs)") def test_KillFilter(self): - p = subprocess.Popen(["sleep", "5"]) - f = filters.KillFilter("root", "/bin/sleep", "-9", "-HUP") - f2 = filters.KillFilter("root", "/usr/bin/sleep", "-9", "-HUP") + p = subprocess.Popen(["cat"], stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + f = filters.KillFilter("root", "/bin/cat", "-9", "-HUP") + f2 = filters.KillFilter("root", "/usr/bin/cat", "-9", "-HUP") usercmd = ['kill', '-ALRM', p.pid] # Incorrect signal should fail self.assertFalse(f.match(usercmd) or f2.match(usercmd)) @@ -79,8 +81,8 @@ class RootwrapTestCase(test.TestCase): usercmd = ['kill', '-9', p.pid] self.assertTrue(f.match(usercmd) or f2.match(usercmd)) - f = filters.KillFilter("root", "/bin/sleep") - f2 = filters.KillFilter("root", "/usr/bin/sleep") + f = filters.KillFilter("root", "/bin/cat") + f2 = filters.KillFilter("root", "/usr/bin/cat") usercmd = ['kill', os.getpid()] # Our own PID does not match /bin/sleep, so it should fail self.assertFalse(f.match(usercmd) or f2.match(usercmd)) |
