Commit 362c59a0 authored by Guillaume Huard's avatar Guillaume Huard
Browse files

outputs_limits -> output/error_limit

parent af8f95f3
......@@ -122,14 +122,18 @@ sub run_command($$$$) {
my $data = {};
my $input = get_value($test, 'input', "");
write_file(".internal_input.txt", $input) || error("Cannot write input file");
my $outputs_limit = -1;
my $output_limit = -1;
my $error_limit = -1;
my $command_line = "$command$arguments >.internal_output.txt 2>.internal_error.txt <.internal_input.txt";
debug("Executing $command");
if ($has_limits) {
$outputs_limit = get_value($test, 'outputs_limit', 100);
$output_limit = get_value($test, 'output_limit', 100*1024);
$error_limit = get_value($test, 'error_limit', 100*1024);
my $timeout = get_value($test, 'timeout', 10);
debug(" with outputs_limit ${outputs_limit}Kb and timeout ${timeout}s");
$outputs_limit *= 1024 if $outputs_limit != -1;
debug(" with output limited to ${output_limit} bytes, error limited to ${error_limit} bytes ".
"and timeout at ${timeout}s");
# $output_limit *= 1024 if $output_limit != -1;
# $error_limit *= 1024 if $error_limit != -1;
$command_line = "exec timeout -s9 $timeout $command_line";
}
debug("\n");
......@@ -138,8 +142,8 @@ sub run_command($$$$) {
$data->{failure} = system($command_line);
$data->{signal} = $data->{failure} & 0xFF;
$data->{code} = $data->{failure} >> 8;
($data->{output}, $data->{output_bounded}) = bounded_read_file(".internal_output.txt", $outputs_limit);
($data->{error}, $data->{error_bounded}) = bounded_read_file(".internal_error.txt", $outputs_limit);
($data->{output}, $data->{output_bounded}) = bounded_read_file(".internal_output.txt", $output_limit);
($data->{error}, $data->{error_bounded}) = bounded_read_file(".internal_error.txt", $error_limit);
# debug("Result : ".Dumper($data));
remove(".internal_input.txt", ".internal_output.txt", ".internal_error.txt");
return $data;
......@@ -225,7 +229,7 @@ sub run_special($$$$$) {
$special->{compiled} = 1;
}
# Adds limits if any
if (exists($special->{outputs_limit}) || exists($special->{timeout})) {
if (exists($special->{output_limit}) || exists($special->{error_limit}) || exists($special->{timeout})) {
$has_limits = 1;
}
my $result;
......@@ -422,11 +426,12 @@ sub perform_tests($$) {
if (defined($test->{$part}) || ($data->{$part})) {
if ($data->{${part}.'_bounded'}) {
$details .= "Your program standard $part has reached the upper limit";
$details .= ", still testing it" if defined($test->{$part});
} else {
$details .= "Your program $description->{$part}:\n".preformat($data->{$part});
}
if (defined($test->{$part})) {
my $local_result = ($data->{$part} eq $test->{$part}) && !$data->{${part}.'_bounded'};
my $local_result = ($data->{$part} eq $test->{$part});
if (!$local_result) {
$details .= "\nBut the expectation was:\n".preformat($test->{$part})."\n";
} else {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment