Skip to content

Commit c1a2a79

Browse files
committed
Allow passing memfd to bridged checkers
1 parent ef53b7c commit c1a2a79

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

dmoj/checkers/bridged.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44

55
from dmoj.contrib import contrib_modules
6+
from dmoj.cptbox.filesystem_policies import ExactFile
67
from dmoj.error import InternalError
78
from dmoj.judgeenv import env, get_problem_root
89
from dmoj.result import CheckerResult
@@ -25,10 +26,10 @@ def get_executor(problem_id, files, flags, lang, compiler_time_limit):
2526
def check(
2627
process_output,
2728
judge_output,
28-
judge_input,
2929
problem_id,
3030
files,
3131
lang,
32+
case,
3233
time_limit=env['generator_time_limit'],
3334
memory_limit=env['generator_memory_limit'],
3435
compiler_time_limit=env['generator_compiler_limit'],
@@ -46,16 +47,23 @@ def check(
4647

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

49-
with mktemp(judge_input) as input_file, mktemp(process_output) as output_file, mktemp(judge_output) as answer_file:
50+
with mktemp(process_output) as output_file, mktemp(judge_output) as answer_file:
51+
input_path = case.input_data_fd().to_path()
52+
5053
checker_args = shlex.split(
5154
args_format_string.format(
52-
input_file=shlex.quote(input_file.name),
55+
input_file=shlex.quote(input_path),
5356
output_file=shlex.quote(output_file.name),
5457
answer_file=shlex.quote(answer_file.name),
5558
)
5659
)
5760
process = executor.launch(
58-
*checker_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, memory=memory_limit, time=time_limit
61+
*checker_args,
62+
stdout=subprocess.PIPE,
63+
stderr=subprocess.PIPE,
64+
memory=memory_limit,
65+
time=time_limit,
66+
extra_fs=[ExactFile(input_path)],
5967
)
6068

6169
proc_output, error = process.communicate()

dmoj/graders/standard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def check_result(self, case: TestCase, result: Result) -> CheckerOutput:
6969
binary_data=case.has_binary_data,
7070
execution_time=result.execution_time,
7171
problem_id=self.problem.id,
72+
case=case,
7273
result=result,
7374
)
7475
except UnicodeDecodeError:

0 commit comments

Comments
 (0)