Skip to content
Open
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

# output
TIMEOUT_MSSG = 'Timeout during test execution, check for an infinite loop\n'
CRASH_MSSG = '\nTest execution ended with abnormal return code, check for crashes\n'
OCTOTHORPE_LINE = '#'*27
OCTOTHORPE_WALL = '#'+' '*25+'#'
INFO_UNSUPPORTED_TEST = '[INFO] Unsupported Test'
Expand Down
12 changes: 8 additions & 4 deletions support/c++/test_running.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Tuple
from attributes import Attributes

from config import TIMEOUT_MSSG
from config import TIMEOUT_MSSG, CRASH_MSSG
from results import PartialTestResult
from test_types import UnsupportedTestException

Expand All @@ -14,26 +14,30 @@ def run_unit_test(timeout: float) -> Tuple[bool,str]:
run_cmd = ["./unit_test", "2>&1"]
p = subprocess.Popen(run_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
output_en, err_en = p.communicate(timeout=timeout) #p.stdout.decode('utf-8')
output_en, _ = p.communicate(timeout=timeout) #p.stdout.decode('utf-8')
output = output_en.decode('utf-8')
except subprocess.TimeoutExpired as e:
output = TIMEOUT_MSSG
except Exception as e:
output = str(e)
ret = p.returncode
if ret != 0:
output += CRASH_MSSG
return ret == 0, output

def run_performance_test(timeout: float) -> Tuple[bool,str]:
run_cmd = ["./performance_test", "2>&1"]
p = subprocess.Popen(run_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
output_en, err_en = p.communicate(timeout=timeout) #p.stdout.decode('utf-8')
output_en, _ = p.communicate(timeout=timeout) #p.stdout.decode('utf-8')
output = output_en.decode('utf-8')
except subprocess.TimeoutExpired as e:
output = "Timeout during test execution, check for an infinite loop\n"
output = TIMEOUT_MSSG
except Exception as e:
output = str(e)
ret = p.returncode
if ret != 0:
output += CRASH_MSSG
return ret == 0, output

def remove_end_of_line_whitespace(s: str) -> str:
Expand Down
4 changes: 3 additions & 1 deletion support/java/test_running.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Tuple
from attributes import Attributes

from config import JAVA_CLASSPATH, TIMEOUT_MSSG
from config import JAVA_CLASSPATH, TIMEOUT_MSSG, CRASH_MSSG
from results import PartialTestResult
from test_types import UnsupportedTestException

Expand All @@ -30,6 +30,8 @@ def run_code(class_name: str, timeout: float) -> Tuple[bool,str]:
except Exception as e:
output = str(e)
ret = p.returncode
if ret != 0:
output += CRASH_MSSG
return ret == 0, output

def run_unit_test(timeout: float) -> Tuple[bool,str]:
Expand Down
4 changes: 3 additions & 1 deletion support/python/test_running.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Tuple
from attributes import Attributes

from config import JAVA_CLASSPATH, TIMEOUT_MSSG
from config import TIMEOUT_MSSG, CRASH_MSSG
from results import PartialTestResult
from test_types import UnsupportedTestException

Expand All @@ -30,6 +30,8 @@ def run_code(class_name: str, timeout: float) -> Tuple[bool,str]:
except Exception as e:
output = str(e)
ret = p.returncode
if ret != 0:
output += CRASH_MSSG
return ret == 0, output

def run_unit_test(timeout: float) -> Tuple[bool,str]:
Expand Down