def _show_tests_detail(self): """show the tests detail after scheduling them. """ sort_buf = [] for key in self.tests_run_map.keys(): costtime = self.tests_run_map.get(key, {}).get('costtime', 0) sort_buf.append((key, costtime)) sort_buf.sort(key=lambda x : x[1]) if self.tests_run_map.keys(): info("%s Testing detail %s" %(self.title_str, self.title_str)) for key, costtime in sort_buf: reason = self.tests_run_map.get(key, {}).get('reason', 'UNKNOWN') result = self.tests_run_map.get(key, {}).get('result', 'INTERRUPTED') if 'SIG' in result: result = "with %s" % result print info_str("%s triggered by %s, exit(%s), cost %.2f s" % ( key, reason, result, costtime))
def _run_job_redirect(self, job): """run job, redirect the output. """ (target, run_dir, test_env, cmd) = job test_name = "%s/%s" % (target['path'], target['name']) info("Running %s" % test_name) start_time = time.time() p = subprocess.Popen(cmd, env=test_env, cwd=run_dir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) (stdoutdata, stderrdata) = p.communicate() cost_time = time.time() - start_time result = self.__get_result(p.returncode) print "%s\n%s%s\n" % (info_str("Output of %s" % test_name), stdoutdata, info_str("%s finished: %s" % (test_name, result))) return (target, p.returncode, cost_time)