From 99db6ab4e8af822f8de58900ef2ccb6c5fd00977 Mon Sep 17 00:00:00 2001 From: Maarten Sijm <9739541+mpsijm@users.noreply.github.com> Date: Fri, 15 Nov 2024 11:59:19 +0100 Subject: [PATCH] #2307 Multi-pass: copy feedback dir between passes (but remove nextpass.in) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit has been used in NWERC 2024 (d7cc716216ec0261864e02d844cfd0207264616f), as well as GCPC 2025 and BAPC 2025. It follows the latest release-candidate specification of multi-pass validation: https://www.kattis.com/problem-package-format/spec/2025-09.html#multi-pass-validation (the mirror at https://icpc.io/problem-package-format/spec/2025-09.html should be deployed "soon™"). Copying the feedback directory to the next pass is an implementation of "All other files inside the feedback directory are guaranteed to persist between passes." Additionally, "Note that the `nextpass.in` will be removed before the next pass." See also https://github.com/Kattis/problem-package-format/issues/446#issuecomment-3246509869 --- judge/judgedaemon.main.php | 10 ++++++++++ judge/testcase_run.sh | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php index 9b282c5ec6..64d782a329 100644 --- a/judge/judgedaemon.main.php +++ b/judge/judgedaemon.main.php @@ -1451,6 +1451,16 @@ function judge(array $judgeTask): bool $passdir = $testcasedir . '/' . $passCnt; mkdir($passdir, 0755, true); + // In multi-pass problems, all files in the feedback directory + // are guaranteed to persist between passes, except `nextpass.in`. + // So, we recursively copy the feedback directory for every pass + // after the first (note that $passCnt starts at 1). + if ($passCnt > 1) { + $prevPassdir = $testcasedir . '/' . ($passCnt - 1) . '/feedback'; + system('cp -R ' . dj_escapeshellarg($prevPassdir) . ' ' . dj_escapeshellarg($passdir . '/')); + system('rm ' . dj_escapeshellarg($passdir . '/feedback/nextpass.in')); + } + // Copy program with all possible additional files to testcase // dir. Use hardlinks to preserve space with big executables. $programdir = $passdir . '/execdir'; diff --git a/judge/testcase_run.sh b/judge/testcase_run.sh index bc8606f64b..83c049a025 100755 --- a/judge/testcase_run.sh +++ b/judge/testcase_run.sh @@ -197,7 +197,7 @@ if [ $COMBINED_RUN_COMPARE -eq 1 ]; then # A combined run and compare script may now already need the # feedback directory, and perhaps access to the test answers (but # only the original that lives outside the chroot). - mkdir feedback + mkdir -p feedback RUNARGS="$RUNARGS $TESTOUT compare.meta feedback" fi @@ -234,8 +234,8 @@ if [ $COMBINED_RUN_COMPARE -eq 0 ]; then exitcode=0 # Create dir for feedback files and make it writable for $RUNUSER - mkdir feedback - chmod a+w feedback + mkdir -p feedback + chmod -R a+w feedback runcheck $GAINROOT "$RUNGUARD" ${DEBUG:+-v} $CPUSET_OPT -u "$RUNUSER" -g "$RUNGROUP" \ -m $SCRIPTMEMLIMIT -t $SCRIPTTIMELIMIT --no-core \