Skip to content

Commit 9f929c1

Browse files
committed
Pass separate CPU/wall time limits through testcase_run.sh
The script doesn't do anything with these, so this way, we have more flexibility in setting them separately and we can increase only the wall clock hard time limit for interactive problems. Disable shellcheck warning about misspelling globally in `testcase_run.sh` since it started warning at other places. This is supported since shellcheck >= 0.4.6 which exists in Debian oldoldstable at least.
1 parent 518f541 commit 9f929c1

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

judge/judgedaemon.main.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,12 +1421,16 @@ function judge(array $judgeTask): bool
14211421
$hardtimelimit = $run_config['time_limit']
14221422
+ overshoot_time($run_config['time_limit'], $overshoot)
14231423
+ $run_config['overshoot'];
1424+
$timelimit = [
1425+
'cpu' => [ $run_config['time_limit'], $hardtimelimit ],
1426+
'wall' => [ $run_config['time_limit'], $hardtimelimit ],
1427+
];
14241428
if ($combined_run_compare) {
14251429
// This accounts for wall time spent in the validator. We may likely
14261430
// want to make this configurable in the future. The current factor is
14271431
// under the assumption that the validator has to do approximately the
14281432
// same amount of work wall-time wise as the submission.
1429-
$hardtimelimit *= 2;
1433+
$timelimit['wall'][1] *= 2;
14301434
}
14311435

14321436
// While we already set those above to likely the same values from the
@@ -1462,11 +1466,12 @@ function judge(array $judgeTask): bool
14621466
}
14631467
}
14641468

1469+
$timelimit_str = implode(':', $timelimit['cpu']) . ',' . implode(':', $timelimit['wall']);
14651470
$test_run_cmd = LIBJUDGEDIR . "/testcase_run.sh $cpuset_opt " .
14661471
implode(' ', array_map('dj_escapeshellarg', [
14671472
$input,
14681473
$output,
1469-
"$run_config[time_limit]:$hardtimelimit",
1474+
$timelimit_str,
14701475
$passdir,
14711476
$run_runpath,
14721477
$compare_runpath,

judge/testcase_run.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/sh
2+
# To suppress false positive of FILELIMIT misspelling of TIMELIMIT:
3+
# shellcheck disable=SC2153
24

35
# Script to test (run and compare) submissions with a single testcase
46
#
@@ -7,8 +9,8 @@
79
#
810
# <testdata.in> File containing test-input with absolute pathname.
911
# <testdata.out> File containing test-output with absolute pathname.
10-
# <timelimit> Timelimit in seconds, optionally followed by ':' and
11-
# the hard limit to kill still running submissions.
12+
# <timelimit> Timelimit in seconds in the format
13+
# "<cpu_soft>:<cpu_hard>,<wall_soft>:<wall_hard>".
1214
# <workdir> Directory where to execute submission in a chroot-ed
1315
# environment. For best security leave it as empty as possible.
1416
# Certainly do not place output-files there!
@@ -200,15 +202,15 @@ if [ $COMBINED_RUN_COMPARE -eq 1 ]; then
200202
fi
201203

202204
exitcode=0
203-
# To suppress false positive of FILELIMIT misspelling of TIMELIMIT:
204-
# shellcheck disable=SC2153
205+
TIMELIMIT_CPU="${TIMELIMIT%%,*}"
206+
TIMELIMIT_WALL="${TIMELIMIT#*,}"
205207
runcheck "$RUN_SCRIPT" $RUNARGS \
206208
$GAINROOT "$RUNGUARD" ${DEBUG:+-v -V "DEBUG=$DEBUG"} ${TMPDIR:+ -V "TMPDIR=$TMPDIR"} $CPUSET_OPT \
207209
-r "$PWD/../.." \
208210
--nproc=$PROCLIMIT \
209211
--no-core --streamsize=$FILELIMIT \
210212
--user="$RUNUSER" --group="$RUNGROUP" \
211-
--walltime=$TIMELIMIT --cputime=$TIMELIMIT \
213+
--walltime="$TIMELIMIT_WALL" --cputime="$TIMELIMIT_CPU" \
212214
--memsize=$MEMLIMIT --filesize=$FILELIMIT \
213215
--stderr=program.err --outmeta=program.meta -- \
214216
"$PREFIX/$PROGRAM" 2>runguard.err

0 commit comments

Comments
 (0)