Skip to content

Commit 2b39789

Browse files
committed
tests: check for ps(1) existence.
Before: Traceback (most recent call last): ... File ".../python-afl/tests/test_fuzz.py", line 143, in stray_process_cleanup ps = ipc.Popen(['ps', 'ax'], stdout=ipc.PIPE) File "/usr/lib/python2.7/subprocess.py", line 394, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory After: Traceback (most recent call last): ... File ".../python-afl/tests/test_fuzz.py", line 140, in stray_process_cleanup require_commands('ps') File ".../python-afl/tests/tools.py", line 151, in require_commands raise RuntimeError('{cmd} not found; is {reason}?'.format(cmd=cmd, reason=reason)) RuntimeError: ps(1) not found; is procps installed?
1 parent 599a6f6 commit 2b39789

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: tests/test_fuzz.py

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def _test_fuzz(workdir, target, dumb=False):
137137
def stray_process_cleanup():
138138
# afl-fuzz doesn't always kill the target process:
139139
# https://groups.google.com/d/topic/afl-users/E37s4YDti7o
140+
require_commands('ps')
140141
try:
141142
yield
142143
finally:

Diff for: tests/tools.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ def require_commands(*cmds):
143143
if os.access(path, os.X_OK):
144144
break
145145
else:
146-
raise RuntimeError('{cmd} not found; is PATH set correctly?'.format(cmd=cmd))
146+
if cmd == 'ps':
147+
cmd = 'ps(1)'
148+
reason = 'procps installed'
149+
else:
150+
reason = 'PATH set correctly'
151+
raise RuntimeError('{cmd} not found; is {reason}?'.format(cmd=cmd, reason=reason))
147152

148153
def run(cmd, stdin='', xstatus=0):
149154
child = ipc.Popen(

0 commit comments

Comments
 (0)