From: Sage Weil Date: Fri, 6 Sep 2013 22:56:39 +0000 (-0700) Subject: misc: valgrind: fix cd behavior X-Git-Tag: 1.1.0~1890^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9e03c737753a96e6ebda778c28712407e2849b4e;p=teuthology.git 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 --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 0ff1c55e..dc677374 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -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_) diff --git a/teuthology/task/ceph-fuse.py b/teuthology/task/ceph-fuse.py index 66eb4286..eeff1c0e 100644 --- a/teuthology/task/ceph-fuse.py +++ b/teuthology/task/ceph-fuse.py @@ -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) diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index a6757f5e..6ed67116 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -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) diff --git a/teuthology/task/rgw.py b/teuthology/task/rgw.py index 54848b27..b4f1725d 100644 --- a/teuthology/task/rgw.py +++ b/teuthology/task/rgw.py @@ -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)