diff --git a/eventlet/httpd_test.py b/eventlet/httpd_test.py index 19b2c9d..803e84e 100644 --- a/eventlet/httpd_test.py +++ b/eventlet/httpd_test.py @@ -131,7 +131,9 @@ class TestHttpd(tests.TestCase): def test_005_run_apachebench(self): url = 'http://localhost:12346/' - out = processes.Process('/usr/sbin/ab', ['-c','64','-n','1024', '-k', url]) + # ab is apachebench + out = processes.Process(tests.find_command('ab'), + ['-c','64','-n','1024', '-k', url]) print out.read() diff --git a/eventlet/tests.py b/eventlet/tests.py index 971509a..378fa18 100644 --- a/eventlet/tests.py +++ b/eventlet/tests.py @@ -24,6 +24,8 @@ THE SOFTWARE. """ import atexit +import errno +import os import sys import unittest @@ -34,3 +36,11 @@ TestCase = unittest.TestCase name = getattr(sys.modules['__main__'], '__name__', None) main = unittest.main + + +def find_command(command): + for dir in os.getenv('PATH', '/usr/bin:/usr/sbin').split(os.pathsep): + p = os.path.join(dir, command) + if os.access(p, os.X_OK): + return p + raise IOError(errno.ENOENT, 'Command not found: %r' % command)