]>
iEval git - gruntmaster-daemon.git/blob - lib/Gruntmaster/Daemon/Runner/Interactive.pm
1 package Gruntmaster
:: Daemon
:: Runner
:: Interactive
;
7 use File
:: Slurp qw
/slurp/ ;
8 use Gruntmaster
:: Daemon
:: Constants qw
/WA/ ;
9 use Gruntmaster
:: Daemon
:: Format qw
/copy_from_vm copy_to_vm/ ;
10 use Log
:: Log4perl qw
/get_logger/ ;
14 our $VERSION = '5999.000_005' ;
16 ##################################################
19 my ( $test , $meta ) = @_ ;
20 get_logger
-> trace ( "Running on test $test ..." );
23 my @fds = $ENV { GRUNTMASTER_VM
} ? qw
, 0 .. /fifo1 1 >../ fifo2
, : qw
/0 fifo1 1 >fifo2/ ;
24 $meta ->{ files
}{ prog
}{ run
}->( $meta ->{ files
}{ prog
}{ name
}, nonblocking
=> 1 , fds
=> \
@fds , map { $_ => $meta ->{ $_ } } qw
/timeout mlimit/ );
27 @fds = $ENV { GRUNTMASTER_VM
} ? qw
, 1 >.. /fifo1 0 ../ fifo2
, : qw
/1 >fifo1 0 fifo2/ ;
29 $meta ->{ files
}{ ver
}{ run
}->( $meta ->{ files
}{ ver
}{ name
}, fds
=> [ @fds , qw
, 3 input
4 > result
,], args
=> [ $test ], map { $_ => $meta ->{ $_ } } qw
/timeout mlimit/ );
31 $fail = [ WA
, 'Wrong Answer' ];
35 Gruntmaster
:: Daemon
:: Format
:: execlist_finish
( prog
=> ! $fail );
40 die $fail if $fail ; ## no critic (RequireCarping)
41 copy_from_vm
'result' ;
42 scalar slurp
'result' or 'Ok'
52 Gruntmaster::Daemon::Runner::Interactive - Make an interactive verifier talk to the program
56 use Gruntmaster::Daemon::Runner::Interactive;
57 Gruntmaster::Daemon::Runner::Interactive::run(5, $meta);
61 B<WARNING: This runner is experimental!>
63 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.
67 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
69 =head1 COPYRIGHT AND LICENSE
71 Copyright (C) 2014 by Marius Gavrilescu
73 This library is free software: you can redistribute it and/or modify
74 it under the terms of the GNU Affero General Public License as published by
75 the Free Software Foundation, either version 3 of the License, or
76 (at your option) any later version.
This page took 0.04897 seconds and 5 git commands to generate.