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