From 0005d3ad0aba39600e7dbb70c040c416f34985ac Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Wed, 23 Apr 2014 10:50:25 +0300 Subject: [PATCH] Update documentation --- gruntmaster-compile | 2 +- lib/Gruntmaster/Daemon/Generator.pod | 42 +++++++++++++++++++ lib/Gruntmaster/Daemon/Generator/File.pm | 6 ++- lib/Gruntmaster/Daemon/Generator/Run.pm | 2 +- lib/Gruntmaster/Daemon/Judge.pod | 40 ++++++++++++++++++ lib/Gruntmaster/Daemon/Judge/Absolute.pm | 2 +- lib/Gruntmaster/Daemon/Judge/Points.pm | 2 +- lib/Gruntmaster/Daemon/Runner.pod | 44 ++++++++++++++++++++ lib/Gruntmaster/Daemon/Runner/File.pm | 12 ++++-- lib/Gruntmaster/Daemon/Runner/Interactive.pm | 4 +- lib/Gruntmaster/Daemon/Runner/Verifier.pm | 2 +- 11 files changed, 145 insertions(+), 13 deletions(-) create mode 100644 lib/Gruntmaster/Daemon/Generator.pod create mode 100644 lib/Gruntmaster/Daemon/Judge.pod create mode 100644 lib/Gruntmaster/Daemon/Runner.pod diff --git a/gruntmaster-compile b/gruntmaster-compile index aebbffc..4e60096 100755 --- a/gruntmaster-compile +++ b/gruntmaster-compile @@ -64,7 +64,7 @@ Compile commands for each format: =item PASCAL - fpc -dONLINE_JUDGE -O2 -n $input + fpc -dONLINE_JUDGE -O2 $input =item PERL diff --git a/lib/Gruntmaster/Daemon/Generator.pod b/lib/Gruntmaster/Daemon/Generator.pod new file mode 100644 index 0000000..bec7bc8 --- /dev/null +++ b/lib/Gruntmaster/Daemon/Generator.pod @@ -0,0 +1,42 @@ +=encoding utf-8 + +=head1 NAME + +Gruntmaster::Daemon::Generator - Modules for generating input files + +=head1 SYNOPSIS + + use Gruntmaster::Daemon::Generator::Foo; + Gruntmaster::Daemon::Generator::Foo::generate(5, $meta); + +=head1 DESCRIPTION + +A generator is a module that creates input data. Each generator has a subroutine, B(I<$test>, I<$meta>), which generates the input data for the given test. + +There are three generators in this distribution: + +=over + +=item L - Generate tests from files + +=item L - Generate tests from program output + +=item L - Pretend to generate tests + +=back + +=head1 AUTHOR + +Marius Gavrilescu Emarius@ieval.roE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2014 by Marius Gavrilescu + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + + +=cut diff --git a/lib/Gruntmaster/Daemon/Generator/File.pm b/lib/Gruntmaster/Daemon/Generator/File.pm index 877eb43..847e915 100644 --- a/lib/Gruntmaster/Daemon/Generator/File.pm +++ b/lib/Gruntmaster/Daemon/Generator/File.pm @@ -34,11 +34,13 @@ Gruntmaster::Daemon::Generator::File - Generate tests from files =head1 SYNOPSIS use Gruntmaster::Daemon::Generator::File; - Gruntmaster::Daemon::Generator::File->generate(5, $meta); + Gruntmaster::Daemon::Generator::File::generate(5, $meta); =head1 DESCRIPTION -Gruntmaster::Daemon::Generator::File is a static test generator. Test C<$i> is C<< $meta->{infile}[$i - 1] >>. +Gruntmaster::Daemon::Generator::File is a static test generator. +If C<< $meta->{infile} >> exists, the input for test C<$i> is C<< $meta->{infile}[$i - 1] >>. +Otherwise, the input for test C<$i> is F<< /var/lib/gruntmasterd/pb/$meta->{problem}/$test.in >>. =head1 AUTHOR diff --git a/lib/Gruntmaster/Daemon/Generator/Run.pm b/lib/Gruntmaster/Daemon/Generator/Run.pm index d971e43..195f336 100644 --- a/lib/Gruntmaster/Daemon/Generator/Run.pm +++ b/lib/Gruntmaster/Daemon/Generator/Run.pm @@ -33,7 +33,7 @@ Gruntmaster::Daemon::Generator::Run - Generate tests from program output =head1 DESCRIPTION -Gruntmaster::Daemon::Generator::Run is a dynamic test generator. Test C<$i> is the output of running C<< $meta->{files}{gen} >> with argument C<$i>. +Gruntmaster::Daemon::Generator::Run is a dynamic test generator. The input for test C<$i> is the output of running C<< $meta->{files}{gen} >> with argument C<$i>. =head1 AUTHOR diff --git a/lib/Gruntmaster/Daemon/Judge.pod b/lib/Gruntmaster/Daemon/Judge.pod new file mode 100644 index 0000000..e1f29c5 --- /dev/null +++ b/lib/Gruntmaster/Daemon/Judge.pod @@ -0,0 +1,40 @@ +=encoding utf-8 + +=head1 NAME + +Gruntmaster::Daemon::Judge - Modules for judging jobs + +=head1 SYNOPSIS + + use Gruntmaster::Daemon::Runner::Foo; + my $verdict = Gruntmaster::Daemon::Runner::Foo::judge(@results); + +=head1 DESCRIPTION + +A judge is a module that takes a list of verdicts and returns a single, combined verdict. + +There are two judges in this distribution: + +=over + +=item L - All-or-nothing ACM-style judge + +=item L - 0 to 100 points IOI-style judge + +=back + +=head1 AUTHOR + +Marius Gavrilescu Emarius@ieval.roE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2014 by Marius Gavrilescu + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + + +=cut diff --git a/lib/Gruntmaster/Daemon/Judge/Absolute.pm b/lib/Gruntmaster/Daemon/Judge/Absolute.pm index e0b04e5..d7e2ec0 100644 --- a/lib/Gruntmaster/Daemon/Judge/Absolute.pm +++ b/lib/Gruntmaster/Daemon/Judge/Absolute.pm @@ -27,7 +27,7 @@ Gruntmaster::Daemon::Judge::Absolute - All-or-nothing ACM-style judge =head1 SYNOPSIS use Gruntmaster::Daemon::Judge::Absolute; - Gruntmaster::Daemon::Judge::Absolute->judge($result1, $result2, $result3, ...); + Gruntmaster::Daemon::Judge::Absolute::judge($result1, $result2, $result3, ...); =head1 DESCRIPTION diff --git a/lib/Gruntmaster/Daemon/Judge/Points.pm b/lib/Gruntmaster/Daemon/Judge/Points.pm index b153948..230e56d 100644 --- a/lib/Gruntmaster/Daemon/Judge/Points.pm +++ b/lib/Gruntmaster/Daemon/Judge/Points.pm @@ -31,7 +31,7 @@ Gruntmaster::Daemon::Judge::Points - 0 to 100 points IOI-style judge =head1 SYNOPSIS use Gruntmaster::Daemon::Judge::Points; - Gruntmaster::Daemon::Judge::Points->judge($result1, $result2, $result3, ...); + Gruntmaster::Daemon::Judge::Points::judge($result1, $result2, $result3, ...); =head1 DESCRIPTION diff --git a/lib/Gruntmaster/Daemon/Runner.pod b/lib/Gruntmaster/Daemon/Runner.pod new file mode 100644 index 0000000..44db619 --- /dev/null +++ b/lib/Gruntmaster/Daemon/Runner.pod @@ -0,0 +1,44 @@ +=encoding utf-8 + +=head1 NAME + +Gruntmaster::Daemon::Runner - Modules for running tests + +=head1 SYNOPSIS + + use Gruntmaster::Daemon::Runner::Foo; + Gruntmaster::Daemon::Runner::Foo::run(5, $meta); + +=head1 DESCRIPTION + +A runner is a module that runs a program on some input data, returning a verdict. Each runner has a subroutine, B(I<$test>, I<$meta>), which runs the program on the given test and returns a verdict. + +If the test is successful, the verdict is a string, usually a message (such as C<"Ok">) or a number of points (such as C<"10">). Otherwise, the verdict is an array reference with two elements: an error code (see L for a list) and an error message. + +There are three runners in this distribution: + +=over + +=item L - Compare output with static text files + +=item L - Check the program output with a verifier + +=item L - Make an interactive verifier talk to the program + +=back + +=head1 AUTHOR + +Marius Gavrilescu Emarius@ieval.roE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2014 by Marius Gavrilescu + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + + +=cut diff --git a/lib/Gruntmaster/Daemon/Runner/File.pm b/lib/Gruntmaster/Daemon/Runner/File.pm index 9193861..55afd70 100644 --- a/lib/Gruntmaster/Daemon/Runner/File.pm +++ b/lib/Gruntmaster/Daemon/Runner/File.pm @@ -21,8 +21,7 @@ sub run{ if (exists $meta->{okfile}) { $ok = $meta->{okfile}[$test - 1] } else { - my $ct = defined $Gruntmaster::Data::contest ? "ct/$Gruntmaster::Data::contest" : ''; - $ok = slurp "/var/lib/gruntmasterd/$ct/pb/$meta->{problem}/$test.ok" + $ok = slurp "/var/lib/gruntmasterd/pb/$meta->{problem}/$test.ok" } $out =~ s/^\s+//; @@ -48,11 +47,16 @@ Gruntmaster::Daemon::Runner::File - Compare output with static text files =head1 SYNOPSIS use Gruntmaster::Daemon::Runner::File; - Gruntmaster::Daemon::Runner::File->run(5, $meta); + Gruntmaster::Daemon::Runner::File::run(5, $meta); =head1 DESCRIPTION -Gruntmaster::Daemon::Runner::File is a runner which compares the program output for test C<$test> with C<< $meta->{tests}[$test - 1] >>. Before comparing, leading and trailing whitespace is removed, and sequences of whitespace are converted to a single space. +Gruntmaster::Daemon::Runner::File is a runner which compares the program output for test C<$test> with a static output. Before comparing, leading and trailing whitespace is removed, and sequences of whitespace are converted to a single space. + +If C<< $meta->{okfile} >> exists, the output is compared to C<< $meta->{okfile}[$test - 1] >>. +Otherwise, the output is compared to F<< /var/lib/gruntmasterd/pb/$meta->{problem}/$test.ok >>. + +If the two strings match, the verdict is C<< $meta->{tests}[$test - 1] >>. Otherwise, the verdict is C<[WA, "Wrong answer"]>. =head1 AUTHOR diff --git a/lib/Gruntmaster/Daemon/Runner/Interactive.pm b/lib/Gruntmaster/Daemon/Runner/Interactive.pm index 5a98675..affac18 100644 --- a/lib/Gruntmaster/Daemon/Runner/Interactive.pm +++ b/lib/Gruntmaster/Daemon/Runner/Interactive.pm @@ -58,13 +58,13 @@ Gruntmaster::Daemon::Runner::Interactive - Make an interactive verifier talk to =head1 SYNOPSIS use Gruntmaster::Daemon::Runner::Interactive; - Gruntmaster::Daemon::Runner::Interactive->run(5, $meta); + Gruntmaster::Daemon::Runner::Interactive::run(5, $meta); =head1 DESCRIPTION B -Gruntmaster::Daemon::Runner::Interactive is a runner which runs the program and an interactive verifier in parallel, connecting each program's STDIN to the other's STDOUT. The verifier, C<< $meta->{files}{int} >>, should return nonzero if the program gives an incorrect answer, and print the test score to fd 4 then return 0 if the answer is correct. +Gruntmaster::Daemon::Runner::Interactive is a runner which runs the program and an interactive verifier in parallel, connecting each program's STDIN to the other's STDOUT. The verifier, C<< $meta->{files}{ver} >>, should return nonzero if the program gives an incorrect answer, or print the test score to fd 4 then return 0 if the answer is correct. =head1 AUTHOR diff --git a/lib/Gruntmaster/Daemon/Runner/Verifier.pm b/lib/Gruntmaster/Daemon/Runner/Verifier.pm index 10f0287..f9ee43b 100644 --- a/lib/Gruntmaster/Daemon/Runner/Verifier.pm +++ b/lib/Gruntmaster/Daemon/Runner/Verifier.pm @@ -38,7 +38,7 @@ Gruntmaster::Daemon::Runner::Verifier - Check the program output with a verifier =head1 SYNOPSIS use Gruntmaster::Daemon::Runner::Verifier; - Gruntmaster::Daemon::Runner::Verifier->run(5, $meta); + Gruntmaster::Daemon::Runner::Verifier::run(5, $meta); =head1 DESCRIPTION -- 2.30.2