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 /= 2) >= 1) && !$ok) {
17 die "$desc: fork() failed : $!";
19 local @SIG{qw/USR1 USR2/} = mrecv sub {
20 exit(($msg eq $_[0]) ? EXIT_SUCCESS : EXIT_FAILURE);
26 local $SIG{ALRM} = sub { die 'timeout' };
27 my $a = (int(100 * (3 * length $msg) / $speed) || 1);
30 msend $msg => $pid, speed => $speed;
32 $ok = (WIFEXITED($?) && (WEXITSTATUS($?) == EXIT_SUCCESS));
41 ok($speed >= 1, $desc);
45 trysend 'hello', 'ascii';
46 trysend "\0" x 10, 'few bits';
47 trysend "\x{FF}" x 10, 'lots of bits';
48 trysend "a\0b", 'null character';