]>
Commit | Line | Data |
---|---|---|
5c5cd38a MG |
1 | package Gruntmaster::Daemon::Runner::Verifier; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
6 | ||
7 | use Gruntmaster::Daemon::Constants qw/WA/; | |
8 | use File::Slurp qw/slurp/; | |
9 | use Log::Log4perl qw/get_logger/; | |
10 | use Try::Tiny; | |
11 | ||
d6a1ae0d | 12 | our $VERSION = '5999.000_002'; |
bc372959 | 13 | |
5c5cd38a MG |
14 | ################################################## |
15 | ||
16 | sub run{ | |
17 | my ($test, $meta) = @_; | |
18 | get_logger->trace("Running on test $test..."); | |
19 | $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, fds => [qw/0 input 1 >output/], map {defined $meta->{$_} ? ($_ => $meta->{$_}) : () } qw/timeout olimit mlimit/); | |
20 | ||
21 | try { | |
03007d04 | 22 | $meta->{files}{ver}{run}->($meta->{files}{ver}{name}, fds => [qw/0 input 3 output 1 >result/], args => [$test]); |
5c5cd38a MG |
23 | } catch { |
24 | die [WA, "Wrong answer"] | |
25 | }; | |
26 | scalar slurp 'result'; | |
27 | } | |
28 | ||
bc372959 MG |
29 | 1; |
30 | __END__ | |
31 | ||
32 | =encoding utf-8 | |
33 | ||
34 | =head1 NAME | |
35 | ||
36 | Gruntmaster::Daemon::Runner::Verifier - Check the program output with a verifier | |
37 | ||
38 | =head1 SYNOPSIS | |
39 | ||
40 | use Gruntmaster::Daemon::Runner::Verifier; | |
41 | Gruntmaster::Daemon::Runner::Verifier->run(5, $meta); | |
42 | ||
43 | =head1 DESCRIPTION | |
44 | ||
45 | Gruntmaster::Daemon::Runner::Verifier is a runner which uses a verifier program to check the correctness of the output. | |
46 | ||
47 | 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. | |
48 | ||
49 | =head1 AUTHOR | |
50 | ||
51 | Marius Gavrilescu E<lt>marius@ieval.roE<gt> | |
52 | ||
53 | =head1 COPYRIGHT AND LICENSE | |
54 | ||
55 | Copyright (C) 2014 by Marius Gavrilescu | |
56 | ||
57 | This library is free software: you can redistribute it and/or modify | |
58 | it under the terms of the GNU Affero General Public License as published by | |
59 | the Free Software Foundation, either version 3 of the License, or | |
60 | (at your option) any later version. | |
61 | ||
62 | ||
63 | =cut |