3 use Test::More tests => 7 * 5;
5 use POSIX qw/SIGINT SIGTERM SIGKILL EXIT_SUCCESS/;
7 use IPC::MorseSignals qw/msend mrecv/;
12 my ($msg, $desc) = @_;
13 pipe my $rdr, my $wtr or die "$desc: pipe() failed : $!";
16 die "$desc: fork() failed : $!";
19 local @SIG{qw/USR1 USR2/} = mrecv sub {
20 print $wtr $_[0], "\n";
26 close $wtr or die "$desc: close() failed : $!";
28 local $SIG{ALRM} = sub { die 'timeout' };
29 my $a = (int(100 * (3 * length $msg) / $speed) || 1);
32 msend $msg => $pid, $speed;
40 die "$desc: died ($@)";
42 my $recv = do { local $/; <$rdr> };
45 ok($msg eq $recv, $desc);
49 trysend 'hello', 'ascii';
50 trysend 'éàùçà', 'extended';
51 trysend '€€€', 'unicode';
52 trysend 'a€bécàd€e', 'mixed';
53 trysend "\0" x 10, 'few bits';
54 trysend "\x{FF}" x 10, 'lots of bits';
55 trysend "a\0b", 'null character';