[svn r21] Make httpd_test look for apachebench more carefully.

Reviewed by Ryan.
This commit is contained in:
sardonyx.linden
2007-10-17 20:01:56 -04:00
parent 21c953273b
commit c2bb3afd93
2 changed files with 13 additions and 1 deletions

View File

@@ -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()

View File

@@ -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)