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 \