3 use Test::More tests => 4 * 5;
5 use POSIX qw/SIGINT SIGTERM SIGKILL EXIT_SUCCESS EXIT_FAILURE WIFEXITED WEXITSTATUS/;
7 use IPC::MorseSignals qw/msend mrecv/;
10 my ($msg, $desc) = @_;
14 while (($speed > 1) && !$ok) {
18 die "$desc: fork() failed : $!";
20 local @SIG{qw/USR1 USR2/} = mrecv sub {
21 exit(($msg eq $_[0]) ? EXIT_SUCCESS : EXIT_FAILURE);
27 local $SIG{ALRM} = sub { die 'timeout' };
28 my $a = (int(100 * (3 * length $msg) / $speed) || 1);
31 msend $msg => $pid, speed => $speed;
33 $ok = (WIFEXITED($?) && (WEXITSTATUS($?) == EXIT_SUCCESS));
42 ok($speed >= 1, $desc);
46 trysend 'hello', 'ascii';
47 trysend "\0" x 10, 'few bits';
48 trysend "\x{FF}" x 10, 'lots of bits';
49 trysend "a\0b", 'null character';