Skip to content

Commit

Permalink
Allow passing memfd to bridged checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum5 committed Dec 28, 2024
1 parent ef53b7c commit c1a2a79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions dmoj/checkers/bridged.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess

from dmoj.contrib import contrib_modules
from dmoj.cptbox.filesystem_policies import ExactFile
from dmoj.error import InternalError
from dmoj.judgeenv import env, get_problem_root
from dmoj.result import CheckerResult
Expand All @@ -25,10 +26,10 @@ def get_executor(problem_id, files, flags, lang, compiler_time_limit):
def check(
process_output,
judge_output,
judge_input,
problem_id,
files,
lang,
case,
time_limit=env['generator_time_limit'],
memory_limit=env['generator_memory_limit'],
compiler_time_limit=env['generator_compiler_limit'],
Expand All @@ -46,16 +47,23 @@ def check(

args_format_string = args_format_string or contrib_modules[type].ContribModule.get_checker_args_format_string()

with mktemp(judge_input) as input_file, mktemp(process_output) as output_file, mktemp(judge_output) as answer_file:
with mktemp(process_output) as output_file, mktemp(judge_output) as answer_file:
input_path = case.input_data_fd().to_path()

checker_args = shlex.split(
args_format_string.format(
input_file=shlex.quote(input_file.name),
input_file=shlex.quote(input_path),
output_file=shlex.quote(output_file.name),
answer_file=shlex.quote(answer_file.name),
)
)
process = executor.launch(
*checker_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, memory=memory_limit, time=time_limit
*checker_args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
memory=memory_limit,
time=time_limit,
extra_fs=[ExactFile(input_path)],
)

proc_output, error = process.communicate()
Expand Down
1 change: 1 addition & 0 deletions dmoj/graders/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def check_result(self, case: TestCase, result: Result) -> CheckerOutput:
binary_data=case.has_binary_data,
execution_time=result.execution_time,
problem_id=self.problem.id,
case=case,
result=result,
)
except UnicodeDecodeError:
Expand Down

0 comments on commit c1a2a79

Please sign in to comment.