3 use Test::More tests => 7 * 5;
5 use POSIX qw/SIGINT SIGTERM SIGKILL EXIT_SUCCESS/;
7 use IPC::MorseSignals qw/msend mrecv/;
10 my ($msg, $desc) = @_;
14 while (($speed > 1) && !$ok) {
16 pipe my $rdr, my $wtr or die "$desc: pipe() failed : $!";
19 die "$desc: fork() failed : $!";
22 local @SIG{qw/USR1 USR2/} = mrecv sub {
23 print $wtr $_[0], "\n";
29 close $wtr or die "$desc: close() failed : $!";
31 local $SIG{ALRM} = sub { die 'timeout' };
32 my $a = (int(100 * (3 * length $msg) / $speed) || 1);
35 msend $msg => $pid, $speed;
43 close $rdr or die "$desc: close() failed : $!";
46 my $recv = do { local $/; <$rdr> };
47 close $rdr or die "$desc: close() failed : $!";
48 next SPEED unless $recv;
50 next SPEED unless $msg eq $recv;
53 ok($speed >= 1, $desc);
57 trysend 'hello', 'ascii';
58 trysend 'éàùçà', 'extended';
59 trysend '€€€', 'unicode';
60 trysend 'a€bécàd€e', 'mixed';
61 trysend "\0" x 10, 'few bits';
62 trysend "\x{FF}" x 10, 'lots of bits';
63 trysend "a\0b", 'null character';