Skip to content

Commit 85df23b

Browse files
Communicate wall clock timeouts to contestants
Situations where the solution does not use cpu time can be confused, as the contestant previously would have seen "Timeout - 0.0s". Now it is a little bit better: "Timeout (wall clock) - 0.0s".
1 parent 03ecbf4 commit 85df23b

4 files changed

Lines changed: 27 additions & 5 deletions

File tree

cms/grading/Sandbox.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class SandboxBase(object):
190190
EXIT_OK = 'ok'
191191
EXIT_SIGNAL = 'signal'
192192
EXIT_TIMEOUT = 'timeout'
193+
EXIT_TIMEOUT_WALL = 'wall timeout'
193194
EXIT_FILE_ACCESS = 'file access'
194195
EXIT_SYSCALL = 'syscall'
195196
EXIT_NONZERO_RETURN = 'nonzero return'
@@ -1118,7 +1119,10 @@ def get_exit_status(self):
11181119
elif 'FA' in status_list:
11191120
return self.EXIT_FILE_ACCESS
11201121
elif 'TO' in status_list:
1121-
return self.EXIT_TIMEOUT
1122+
if 'message' in self.log and 'wall' in self.log['message'][0]:
1123+
return self.EXIT_TIMEOUT_WALL
1124+
else:
1125+
return self.EXIT_TIMEOUT
11221126
elif 'SG' in status_list:
11231127
return self.EXIT_SIGNAL
11241128
elif 'RE' in status_list:
@@ -1147,6 +1151,8 @@ def get_human_exit_description(self):
11471151
% self.get_forbidden_file_error()
11481152
elif status == self.EXIT_TIMEOUT:
11491153
return "Execution timed out"
1154+
elif status == self.EXIT_TIMEOUT_WALL:
1155+
return "Execution timed out (wall clock limit exceeded)"
11501156
elif status == self.EXIT_SIGNAL:
11511157
return "Execution killed with signal %d" % \
11521158
self.get_killing_signal()

cms/grading/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Contest Management System - http://cms-dev.github.io/
55
# Copyright © 2010-2015 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
6-
# Copyright © 2010-2014 Stefano Maggiolo <s.maggiolo@gmail.com>
6+
# Copyright © 2010-2015 Stefano Maggiolo <s.maggiolo@gmail.com>
77
# Copyright © 2010-2012 Matteo Boscariol <boscarim@hotmail.com>
88
# Copyright © 2013 Bernard Blackham <bernard@largestprime.net>
99
# Copyright © 2013-2014 Luca Wehrstedt <luca.wehrstedt@gmail.com>
@@ -284,7 +284,8 @@ def compilation_step(sandbox, commands):
284284
text = [N_("Compilation failed")]
285285

286286
# Timeout: returning the error to the user
287-
elif exit_status == Sandbox.EXIT_TIMEOUT:
287+
elif exit_status == Sandbox.EXIT_TIMEOUT or \
288+
exit_status == Sandbox.EXIT_TIMEOUT_WALL:
288289
logger.debug("Compilation timed out.")
289290
success = True
290291
compilation_success = False
@@ -438,6 +439,11 @@ def evaluation_step_after_run(sandbox):
438439
logger.debug("Execution timed out.")
439440
success = True
440441

442+
# Wall clock timeout: returning the error to the user.
443+
elif exit_status == Sandbox.EXIT_TIMEOUT_WALL:
444+
logger.debug("Execution timed out (wall clock limit exceeded).")
445+
success = True
446+
441447
# Suicide with signal (memory limit, segfault, abort): returning
442448
# the error to the user.
443449
elif exit_status == Sandbox.EXIT_SIGNAL:
@@ -501,6 +507,8 @@ def human_evaluation_message(plus):
501507
exit_status = plus['exit_status']
502508
if exit_status == Sandbox.EXIT_TIMEOUT:
503509
return [N_("Execution timed out")]
510+
elif exit_status == Sandbox.EXIT_TIMEOUT_WALL:
511+
return [N_("Execution timed out (wall clock limit exceeded)")]
504512
elif exit_status == Sandbox.EXIT_SIGNAL:
505513
return [N_("Execution killed with signal %d (could be triggered by "
506514
"violating memory limits)"), plus['signal']]

cmstestsuite/Test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# Contest Management System - http://cms-dev.github.io/
55
# Copyright © 2012 Bernard Blackham <bernard@largestprime.net>
6+
# Copyright © 2014-2015 Stefano Maggiolo <s.maggiolo@gmail.com>
67
#
78
# This program is free software: you can redistribute it and/or modify
89
# it under the terms of the GNU Affero General Public License as
@@ -103,6 +104,13 @@ def __init__(self):
103104
self, "timed out", "Execution timed out")
104105

105106

107+
class CheckTimeoutWall(CheckAbstractEvaluationFailure):
108+
def __init__(self):
109+
CheckAbstractEvaluationFailure.__init__(
110+
self, "wall timed out",
111+
"Execution timed out (wall clock limit exceeded)")
112+
113+
106114
class CheckForbiddenSyscall(CheckAbstractEvaluationFailure):
107115
def __init__(self, syscall_name=''):
108116
CheckAbstractEvaluationFailure.__init__(

cmstestsuite/Tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from cms import LANGUAGES, LANG_C, LANG_CPP, LANG_PASCAL, LANG_JAVA, \
3232
LANG_PYTHON
3333
from cmstestsuite.Test import Test, CheckOverallScore, CheckCompilationFail, \
34-
CheckTimeout, CheckNonzeroReturn
34+
CheckTimeout, CheckTimeoutWall, CheckNonzeroReturn
3535

3636

3737
ALL_LANGUAGES = tuple(LANGUAGES)
@@ -111,7 +111,7 @@
111111
Test('timeout-pause',
112112
task=batch_stdio, filename='timeout-pause.%l',
113113
languages=(LANG_CPP,),
114-
checks=[CheckOverallScore(0, 100), CheckTimeout()]),
114+
checks=[CheckOverallScore(0, 100), CheckTimeoutWall()]),
115115

116116
Test('timeout-sleep',
117117
task=batch_stdio, filename='timeout-sleep.%l',

0 commit comments

Comments
 (0)