use strict;
use warnings;
-our $VERSION = '0.001';
+our $VERSION = '5999-TRIAL';
use Gruntmaster::Daemon::Constants qw/ERR/;
use Gruntmaster::Daemon::Format qw/prepare_files/;
1;
__END__
-# Below is stub documentation for your module. You'd better edit it!
=head1 NAME
-Gruntmaster::Daemon - Perl extension for blah blah blah
+Gruntmaster::Daemon - Gruntmaster 6000 Online Judge -- daemon
=head1 SYNOPSIS
use Gruntmaster::Daemon;
- blah blah blah
+ Gruntmaster::Daemon->run;
=head1 DESCRIPTION
-Stub documentation for Gruntmaster::Daemon, created by h2xs. It looks like the
-author of the extension was negligent enough to leave the stub
-unedited.
-
-Blah blah blah.
-
-
-=head1 SEE ALSO
-
-Mention other useful documentation such as the documentation of
-related modules or operating system documentation (such as man pages
-in UNIX), or any relevant external documentation such as RFCs or
-standards.
-
-If you have a mailing list set up for your module, mention it here.
-
-If you have a web site set up for your module, mention it here.
+Gruntmaster::Daemon is the daemon component of the Gruntmaster 6000 online judge.
=head1 AUTHOR
-Marius Gavrilescu, E<lt>marius@E<gt>
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2013 by Marius Gavrilescu
+Copyright (C) 2014 by Marius Gavrilescu
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself, either Perl version 5.18.1 or,
-at your option, any later version of Perl 5 you may have available.
+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
use warnings;
use parent qw/Exporter/;
-our $VERSION = '0.001';
+our $VERSION = "5999-TRIAL";
use constant +{
# Accepted
};
our @EXPORT_OK = qw/AC ERR WA NZX TLE OLE DIED REJ/;
+
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Gruntmaster::Daemon::Constants - Constants for the Gruntmaster daemon
+
+=head1 SYNOPSIS
+
+ use Gruntmaster::Daemon::Constants qw/WA NZX/;
+ ...
+ return [NZX, 'Non-zero exit status'] if $status;
+ return [WA, 'Wrong answer'] unless is_correct($answer);
+
+=head1 DESCRIPTION
+
+Gruntmaster::Daemon::Constants provides constants which are used in more than one module.
+
+The constants are:
+
+=over
+
+=item B<AC> The 'Accepted' job result.
+
+=item B<ERR> The 'Internal server error' job result.
+
+=item B<WA> The 'Wrong answer' job result.
+
+=item B<NZX> The 'Non-zero exit status' job result.
+
+=item B<TLE> The 'Time limit exceeded' job result.
+
+=item B<OLE> The 'Output limit exceeded' job result.
+
+=item B<DIED> The 'Crash' job result. Used when a program is killed by a signal.
+
+=item B<REJ> The 'Rejected' job result. Used when none of the above is appropriate.
+
+=back
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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
use List::MoreUtils qw/natatime/;
use IPC::Signal qw/sig_name sig_num/;
-our $VERSION = '0.001';
+our $VERSION = "5999-TRIAL";
our @EXPORT_OK = qw/prepare_files/;
##################################################
}
}
-1
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Gruntmaster::Daemon::Format - Utility functions for handling source files
+
+=head1 SYNOPSIS
+
+ use Gruntmaster::Daemon::Format qw/prepare_files/;
+ prepare_files { files => {
+ prog => {
+ name => 'prog.pl',
+ format => 'PERL',
+ content => 'print "Hello, world!"'
+ },
+ ver => {
+ name => 'ver.cpp',
+ format => 'CPP',
+ content => ...
+ },
+ }};
+
+=head1 DESCRIPTION
+
+Gruntmaster::Daemon::Format exports utility functions for handling source files.
+
+=over
+
+=item B<prepare_files> I<$meta>
+
+Compiles all the source files in C<< $meta->{files} >>.
+
+=back
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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
use File::Slurp qw/write_file/;
use Log::Log4perl qw/get_logger/;
-our $VERSION = '0.001';
+our $VERSION = "5999-TRIAL";
##################################################
write_file 'input', $meta->{infile}[$test - 1]
}
-1
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Gruntmaster::Daemon::Generator::File - Generate tests from files
+
+=head1 SYNOPSIS
+
+ use Gruntmaster::Daemon::Generator::File;
+ 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] >>.
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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
$gen->{run}->($gen->{name}, args => [ $test ], fds => [qw/1 >input/]);
}
-1
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Gruntmaster::Daemon::Generator::Run - Generate tests from program output
+
+=head1 SYNOPSIS
+
+ use Gruntmaster::Daemon::Generator::Run;
+ Gruntmaster::Daemon::Generator::Run->generate(5, $meta);
+
+=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>.
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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
use Log::Log4perl qw/get_logger/;
-our $VERSION = '0.001';
+our $VERSION = "5999-TRIAL";
##################################################
get_logger->trace("Pretending to generate test $_[0]...");
}
-1
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Gruntmaster::Daemon::Generator::Undef - Pretend to generate tests
+
+=head1 SYNOPSIS
+
+ use Gruntmaster::Daemon::Generator::Undef;
+ Gruntmaster::Daemon::Generator::Undef->generate(5, $meta);
+
+=head1 DESCRIPTION
+
+Gruntmaster::Daemon::Generator::Undef is a noop test generator. It is useful for L<interactive|Gruntmaster::Daemon::Runner::Interactive> problems, where there is no input.
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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
use Gruntmaster::Daemon::Constants qw/AC/;
-our $VERSION = '0.001';
+our $VERSION = '5999-TRIAL';
##################################################
use Gruntmaster::Daemon::Constants qw/AC REJ/;
use List::Util qw/sum/;
use Log::Log4perl qw/get_logger/;
-our $VERSION = '0.001';
+
+our $VERSION = '5999-TRIAL';
##################################################
use File::Slurp qw/slurp/;
use Log::Log4perl qw/get_logger/;
+our $VERSION = "5999-TRIAL";
+
##################################################
sub run{
$meta->{tests}[$test - 1] // 0
}
-1
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Gruntmaster::Daemon::Runner::File - Compare output with static text files
+
+=head1 SYNOPSIS
+
+ use Gruntmaster::Daemon::Runner::File;
+ 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.
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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
use POSIX qw/mkfifo/;
use Try::Tiny;
+our $VERSION = '5999-TRIAL';
+
##################################################
sub run{
scalar slurp 'result'
}
-1;
-__END__
+1
use Log::Log4perl qw/get_logger/;
use Try::Tiny;
+our $VERSION = '5999-TRIAL';
+
##################################################
sub run{
scalar slurp 'result';
}
-1
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+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);
+
+=head1 DESCRIPTION
+
+Gruntmaster::Daemon::Runner::Verifier is a runner which uses a verifier program to check the correctness of the output.
+
+The verifier program, C<< $meta->{files}{ver} >>, reads the test input from stdin and the output from fd 3. If the output is incorrect, it should return a nonzero value. Otherwise, it should print the score on this test and then return 0.
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=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