Give helpful error in tests if strace is missing

The functional reload test depends on the strace executable. If it is
not found then a very unclear backtrace is given and the test fails.

Change-Id: I736a7f554953916036b2e002fd88917e01388e42
This commit is contained in:
Gregory Haynes 2016-04-14 20:49:40 +00:00
parent bf56e4e40c
commit 1109f826b2

View File

@ -23,6 +23,7 @@ and spinning down the servers.
import atexit
import datetime
import errno
import logging
import os
import platform
@ -857,7 +858,14 @@ class FunctionalTest(test_utils.BaseTestCase):
trace = f.pid_file.replace('.pid', '.trace')
if self.tracecmd:
cmd = '%s -p %d -o %s' % (self.tracecmd, pid, trace)
execute(cmd, raise_error=False, expect_exit=False)
try:
execute(cmd, raise_error=False, expect_exit=False)
except OSError as e:
if e.errno == errno.ENOENT:
raise RuntimeError('No executable found for "%s" '
'command.' % self.tracecmd)
else:
raise
time.sleep(0.5)
if os.path.exists(trace):
msg += ('\n%s:\n%s\n' % (self.tracecmd,