misc: valgrind: fix cd behavior

The cd needs to happen at the beginning of the command, not at the end, or
else the funky wrapper scripts don't work right.

This also cleans up the command line construction a bit so that it is more
flexible, explicit, and hopefully less fragile.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-09-06 15:56:39 -07:00
parent 19324c63d2
commit 9e03c73775
4 changed files with 33 additions and 25 deletions

View File

@ -862,7 +862,15 @@ def deep_merge(a, b):
return a
return b
def get_valgrind_args(testdir, name, v):
def get_valgrind_args(testdir, name, preamble, v):
"""
Build a command line for running valgrind.
testdir - test results directory
name - name of daemon (for naming hte log file)
preamble - stuff we should run before valgrind
v - valgrind arguments
"""
if v is None:
return []
if not isinstance(v, list):
@ -870,8 +878,7 @@ def get_valgrind_args(testdir, name, v):
val_path = '/var/log/ceph/valgrind'.format(tdir=testdir)
if '--tool=memcheck' in v or '--tool=helgrind' in v:
extra_args = [
'cd', testdir,
run.Raw('&&'),
'valgrind',
'--num-callers=50',
'--suppressions={tdir}/valgrind.supp'.format(tdir=testdir),
@ -880,15 +887,16 @@ def get_valgrind_args(testdir, name, v):
]
else:
extra_args = [
'cd', testdir,
run.Raw('&&'),
'valgrind',
'--suppressions={tdir}/valgrind.supp'.format(tdir=testdir),
'--log-file={vdir}/{n}.log'.format(vdir=val_path, n=name)
]
extra_args.extend(v)
log.debug('running %s under valgrind with args %s', name, extra_args)
return extra_args
args = [
'cd', testdir,
run.Raw('&&'),
] + preamble + extra_args + v
log.debug('running %s under valgrind with args %s', name, args)
return args
def stop_daemons_of_type(ctx, type_):
log.info('Shutting down %s daemons...' % type_)

View File

@ -97,12 +97,11 @@ def task(ctx, config):
]
if client_config.get('valgrind') is not None:
run_cmd.extend(
teuthology.get_valgrind_args(
testdir,
'client.{id}'.format(id=id_),
client_config.get('valgrind'),
)
run_cmd = teuthology.get_valgrind_args(
testdir,
'client.{id}'.format(id=id_),
run_cmd,
client_config.get('valgrind'),
)
run_cmd.extend(run_cmd_tail)

View File

@ -901,17 +901,19 @@ def run_daemon(ctx, config, type_):
'-f',
'-i', id_]
if type_ in config.get('cpu_profile', []):
profile_path = '/var/log/ceph/profiling-logger/%s.%s.prof' % (type_, id_)
run_cmd.extend([ 'env', 'CPUPROFILE=%s' % profile_path ])
if config.get('valgrind') is not None:
valgrind_args = None
if type_ in config['valgrind']:
valgrind_args = config['valgrind'][type_]
if name in config['valgrind']:
valgrind_args = config['valgrind'][name]
run_cmd.extend(teuthology.get_valgrind_args(testdir, name, valgrind_args))
if type_ in config.get('cpu_profile', []):
profile_path = '/var/log/ceph/profiling-logger/%s.%s.prof' % (type_, id_)
run_cmd.extend([ 'env', 'CPUPROFILE=%s' % profile_path ])
run_cmd = teuthology.get_valgrind_args(testdir, name,
run_cmd,
valgrind_args)
run_cmd.extend(run_cmd_tail)

View File

@ -177,12 +177,11 @@ def start_rgw(ctx, config):
run.Raw('2>&1'),
]
run_cmd.extend(
teuthology.get_valgrind_args(
testdir,
client,
client_config.get('valgrind')
)
run_cmd = teuthology.get_valgrind_args(
testdir,
client,
run_cmd,
client_config.get('valgrind')
)
run_cmd.extend(run_cmd_tail)