X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Frun-report.py;h=acee18181adbac9267939d61d9efd6119fa7130c;hp=2e897475a15b854dd9dde8b31228565869f47cf0;hb=785d2d0dc3aec3a4e44fcf677155dd07e8e4cc1f;hpb=4ed5c01eca0a952825962abfc405ba01bba9b52c diff --git a/tests/run-report.py b/tests/run-report.py index 2e897475a..acee18181 100755 --- a/tests/run-report.py +++ b/tests/run-report.py @@ -46,10 +46,12 @@ def cpu_create_usage_dict(top_line): top_line = top_line.replace(",","") words = top_line.split()[1:] - for word in words: - index = word.find('%') + + for key in top_dict: + index = words.index(key) # Add the value to the dictionnary - top_dict[word[index + 1:]] = float(word[:index]) + val = words[index-1] + top_dict[key] = float(val) return top_dict @@ -87,7 +89,7 @@ def cpu_sample_usage(pid=None): # Spawn top process top = subprocess.Popen(args, stdout = subprocess.PIPE) - grep = subprocess.Popen(["grep", "^Cpu"], stdin = top.stdout, + grep = subprocess.Popen(["grep", "Cpu"], stdin = top.stdout, stdout = subprocess.PIPE) top.stdout.close() @@ -171,18 +173,16 @@ class SamplingWorker(threading.Thread): mem_ret_q.put((count, mem_stat)) class TestWorker(threading.Thread): - def __init__(self, path, name): + def __init__(self, path, name, env): threading.Thread.__init__(self) self.path = path self.name = name + self.env = env def run(self): bin_path_name = os.path.join(self.path, self.name) - env = os.environ - env['TEST_NO_SESSIOND'] = '1' - - test = subprocess.Popen([bin_path_name], env=env, preexec_fn = lambda: signal(SIGPIPE, SIG_DFL)) + test = subprocess.Popen([bin_path_name], env=self.env, preexec_fn = lambda: signal(SIGPIPE, SIG_DFL)) test.wait() # Send ret value to main thread @@ -301,10 +301,23 @@ def run_test(test): print "Unable to find test file '%s'. Skipping" % (test['bin']) return 0 - # No session daemon needed - if not test['daemon']: + # Session daemon is controlled by the test + if test['daemon'] == "test": + print PRINT_ARROW + " Session daemon is controlled by the test" + env = os.environ + env['TEST_NO_SESSIOND'] = '0' + tw = TestWorker(".", test['bin'], env) + tw.start() + ret = test_ret_q.get(True) + print_test_success(ret, test['success']) + return 0 + elif test['daemon'] == False: print PRINT_ARROW + " No session daemon needed" - ret = start_test(test['bin']) + env = os.environ + env['TEST_NO_SESSIOND'] = '1' + tw = TestWorker(".", test['bin'], env) + tw.start() + ret = test_ret_q.get(True) print_test_success(ret, test['success']) return 0 else: @@ -325,7 +338,12 @@ def run_test(test): cpu_count, cpu_stats = get_cpu_usage(pid = dem_pid) print_cpu_stats(cpu_stats, cpu_count) - tw = TestWorker(".", test['bin']) + # Sessiond was already spawned, do not let the test spawn + # an additional sessiond + env = os.environ + env['TEST_NO_SESSIOND'] = '1' + + tw = TestWorker(".", test['bin'], env) tw.start() if not no_stats: