Commit a7d267a1 authored by ufebl's avatar ufebl

Add error log if binary could not be run during benchmark

parent 7ba134b2
......@@ -63,16 +63,27 @@ class BenchExecTest(BasicSyntaxTest):
self._should_succeed = True
def _bench_command(self, cmd: str, *args: Tuple[str], timeout: int, input_bytes: str) -> _RunResult:
def _bench_command(self, cmd: str, *args: Tuple[str], compiler_flag: str, timeout: int, input_bytes: str) -> _RunResult:
runs = [] # type: List[float]
for i in range(0, self.env.bench_runs):
try:
start = time.time()
self.env.run_command(cmd, *args, timeout=timeout, input_bytes=input_bytes)
runs.append((time.time() - start) * 1000)
except subprocess.CalledProcessError:
out, err, rtcode = self.env.run_command(cmd, *args, timeout=timeout, input_bytes=input_bytes)
if rtcode == 0:
runs.append((time.time() - start) * 1000)
else:
_LOG.error("File \"{}\" can't be run with flags \"{}\" error code: {}".format(self.preprocessed_file, compiler_flag, rtcode))
_LOG.error("Error: " + err.decode());
return _RunResult([-1,0], False);
except SigKill as sig:
_LOG.error("File \"{}\" can't be run with flags \"{}\"".format(self.preprocessed_file, compiler_flag))
_LOG.error("Error: " + sig.name.strip() +" " + sig.retcode)
return _RunResult([-1,0], False);
except:
raise
# except subprocess.CalledProcessError:
# return _RunResult([-1,0], False);
return _RunResult(runs, True)
......@@ -124,7 +135,7 @@ class BenchExecTest(BasicSyntaxTest):
_LOG.debug("Can't find a main class, using the file name instead")
main_class = base_filename
results.append(self._bench_command("java", main_class, timeout=timeout, input_bytes=input_bytes))
results.append(self._bench_command("java", main_class, compiler_flag="javac", timeout=timeout, input_bytes=input_bytes))
else:
try:
compiler_flag = compiler_flag.replace("\\-", "-")
......@@ -142,10 +153,10 @@ class BenchExecTest(BasicSyntaxTest):
#return test_result
results.append(_RunResult([-1,0], False));
else:
results.append(self._bench_command("./a.out", timeout=timeout, input_bytes=input_bytes))
results.append(self._bench_command("./a.out", compiler_flag = compiler_flag, timeout=timeout, input_bytes=input_bytes))
except SigKill as sig:
_LOG.error("File \"{}\" can't be compiled with flags \"{}\"".format(self.preprocessed_file, compiler_flag))
_LOG.error("Errorcide: " + śig.retcode);
_LOG.error("Errorcide: " + sig.retcode);
#test_result.incorrect_msg = "file can't be compiled: " + sig.name
#test_result.set_error_code(sig.retcode)
#test_result.add_file("Source file", self.preprocessed_file)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment