def run_test(self, cfg_name): # Prepare test environment and generate command for it test = self.read_test_config(cfg_name) test_bin = os.path.basename(test.bins[0]) if test.is_dist: # Distribution-wide tests should work with default environment test_env = os.environ else: test_env = self.generate_env() self.prepare_test_dir(test) command = test_bin if not test.is_dist: command = os.path.join(self.bin_dir, test_bin) if test.args is not None: command = '%s %s' % (command, test.args) # Start a test along with a timer that would check # If test wouldn't timeout start = time.time() proc = Popen(command, stdout = PIPE, stderr = PIPE, cwd = self.test_dir, env = test_env, shell = test.is_dist or test.args) proc.timed_out = False timer = Timer(test.maxtime, self.stop_test, args = [proc]) timer.start() (stdout, stderr) = proc.communicate() timer.cancel() end = time.time() # Check test result: core, return value core = self.check_core(cfg_name, test.group) result = self.analyze_result(test, proc) # Generate test report output = self.generate_output(command, start, end, proc, core, stdout, stderr) # Done self.suite.report_test('%s/%s' % (test.group, test.name), result, proc.returncode, output)
def run_test(self, cfg_name): # Prepare test environment and generate command for it test = self.read_test_config(cfg_name) test_bin = os.path.basename(test.bins[0]) if test.is_dist: # Distribution-wide tests should work with default environment test_env = os.environ else: test_env = self.generate_env() self.prepare_test_dir(test) command = test_bin if not test.is_dist: command = os.path.join(self.bin_dir, test_bin) if test.args is not None: command = '%s %s' % (command, test.args) # Start a test along with a timer that would check # If test wouldn't timeout start = time.time() proc = Popen(command, stdout=PIPE, stderr=PIPE, cwd=self.test_dir, env=test_env, shell=test.is_dist or test.args) proc.timed_out = False timer = Timer(test.maxtime, self.stop_test, args=[proc]) timer.start() (stdout, stderr) = proc.communicate() timer.cancel() end = time.time() # Check test result: core, return value core = self.check_core(cfg_name, test.group) result = self.analyze_result(test, proc) # Generate test report output = self.generate_output(command, start, end, proc, core, stdout, stderr) # Done self.suite.report_test('%s/%s' % (test.group, test.name), result, proc.returncode, output)