Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
projet
VPLPP
Commits
77ffe3bf
Commit
77ffe3bf
authored
May 17, 2020
by
Guillaume Huard
Browse files
Cleaned up limits
parent
486f8178
Changes
2
Hide whitespace changes
Inline
Side-by-side
Basic_System.org
View file @
77ffe3bf
...
...
@@ -178,11 +178,11 @@ notre programme
}
}
#+END_SRC
En outre, l'exécution elle même
est controllée par deux réglages évitant une trop grande utilisation des
ressources disponibles :
En outre, l'exécution elle même
, lorsqu'il s'agit du code soumis par l'étudiant, est controllée par
deux réglages évitant une trop grande utilisation des
ressources disponibles :
- =timeout= : valeur en secondes déterminant le temps alloué au test pour son exécution (10 par
défaut) ;
- =IOlimit= : taille maximale en blocs d'un fichier créé par le test (100
0
blocs par défaut). La taille du
- =IOlimit= : taille maximale en blocs d'un fichier créé par le test (100 blocs par défaut). La taille du
bloc dépend du système mais est souvent de 512 octets.
L'exemple suivant comprend une petite série de tests qui ne passe que si le programme s'exécute dans
les limites imposées :
...
...
Basic_System/ef/vpl_evaluate.pl
View file @
77ffe3bf
...
...
@@ -118,18 +118,23 @@ sub run_command($$$$) {
my
$input
=
get_value
(
$test
,
'
input
',
"");
write_file
("
.internal_input.txt
",
$input
)
||
error
("
Cannot write input file
");
my
$command_line
=
"
$command$arguments
>.internal_output.txt 2>.internal_error.txt <.internal_input.txt
";
debug
("
Executing
$command
");
if
(
$has_limits
)
{
my
$IOlimit
.=
get_value
(
$test
,
'
IOlimit
',
100
);
my
$timeout
.=
get_value
(
$test
,
'
timeout
',
10
);
debug
("
with IOlimit
$IOlimit
and timeout
$timeout
");
# We build an execution wrapper to ensure the use of bash instead of /bin/sh (system's default)
# This avoids issues with ulimit
my
$command_script
=
"
#!/bin/bash
\n
";
$command_script
.=
"
ulimit -f
"
.
get_value
(
$test
,
'
IOlimit
',
100
)
.
"
\n
";
$command_script
.=
"
exec timeout -s9
"
.
get_value
(
$test
,
'
timeout
',
10
)
.
"
";
$command_script
.=
"
ulimit -f
$IOlimit
\n
";
$command_script
.=
"
exec timeout -s9
$timeout
";
$command_script
.=
$command_line
;
# debug("Command script :\n$command_script\n");
ensure_write
("
.execution_wrapper
",
$command_script
);
chmod
(
0755
,
"
.execution_wrapper
")
||
error
("
Cannot make execution_wrapper executable
");
$command_line
=
"
./.execution_wrapper
";
}
debug
("
\n
");
# debug("Executing: $command_line\n");
# One should use the POSIX macros WIFEXITED, WEXITSTATUS, and so on, but it's too cumbersome
$data
->
{
failure
}
=
system
(
$command_line
);
...
...
@@ -222,6 +227,10 @@ sub run_special($$$$$) {
}
$special
->
{
compiled
}
=
1
;
}
# Adds limits if any
if
(
exists
(
$special
->
{
IOlimit
})
||
exists
(
$special
->
{
timeout
}))
{
$has_limits
=
1
;
}
my
$result
;
if
(
exists
(
$special
->
{
execute
}))
{
if
(
$special
->
{
execute
})
{
...
...
@@ -229,7 +238,6 @@ sub run_special($$$$$) {
$result
=
run_special
(
$test_name
,
'
.execute
',
$special
->
{
execute
},
$test
,
$has_limits
);
}
}
else
{
debug
("
Executing
$name
\n
");
$result
=
run_command
(
$test_name
,
"
./
$name
",
$test
,
$has_limits
);
}
if
(
exists
(
$special
->
{
content
}))
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment