Skip to content

Commit

Permalink
apply time and memory limit to output validators for standard problem…
Browse files Browse the repository at this point in the history
…s (for interactive problems, time and memory limits are not applied correctly)
  • Loading branch information
austrin committed Feb 6, 2017
1 parent 6cffcbc commit b10cd30
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions problemtools/verifyproblem.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,9 @@ def validate_interactive(self, testcase, submission, timelim, errorhandler):
initargs = ['1', str(2 * timelim)]
validator_args = [testcase.infile, testcase.ansfile, '<feedbackdir>']
submission_args = submission.get_runcmd(memlim=self._problem.config.get('limits')['memory'])

val_timelim = self._problem.config.get('limits')['validation_time']
val_memlim = self._problem.config.get('limits')['validation_memory']
for val in self._actual_validators():
if val is not None and val.compile():
feedbackdir = tempfile.mkdtemp(prefix='feedback', dir=self._problem.tmpdir)
Expand All @@ -920,7 +923,7 @@ def validate_interactive(self, testcase, submission, timelim, errorhandler):
interactive_out = f.name
f.close()
i_status, _ = interactive.run(outfile=interactive_out,
args=initargs + val.get_runcmd() + validator_args + [';'] + submission_args)
args=initargs + val.get_runcmd(memlim=val_memlim) + validator_args + [';'] + submission_args)
if is_RTE(i_status):
errorhandler.error('Interactive crashed, status %d' % i_status)
else:
Expand Down Expand Up @@ -953,12 +956,15 @@ def validate_interactive(self, testcase, submission, timelim, errorhandler):

def validate(self, testcase, submission_output):
res = SubmissionResult('JE')
val_timelim = self._problem.config.get('limits')['validation_time']
val_memlim = self._problem.config.get('limits')['validation_memory']
flags = self._problem.config.get('validator_flags').split() + testcase.testcasegroup.config['output_validator_flags'].split()
for val in self._actual_validators():
if val is not None and val.compile():
feedbackdir = tempfile.mkdtemp(prefix='feedback', dir=self._problem.tmpdir)
status, runtime = val.run(submission_output,
args=[testcase.infile, testcase.ansfile, feedbackdir] + self._problem.config.get('validator_flags').split() + testcase.testcasegroup.config['output_validator_flags'].split())

args=[testcase.infile, testcase.ansfile, feedbackdir] + flags,
timelim=val_timelim, memlim=val_memlim)
res = self._parse_validator_results(val, status, feedbackdir)
shutil.rmtree(feedbackdir)
if res.verdict != 'AC':
Expand Down

0 comments on commit b10cd30

Please sign in to comment.