3 use Test::More tests => 7 * 5;
5 use POSIX qw/SIGINT SIGTERM SIGKILL EXIT_SUCCESS EXIT_FAILURE WIFEXITED WEXITSTATUS/;
7 use IPC::MorseSignals qw/msend mrecv/;
12 my ($msg, $desc) = @_;
15 $desc .= ' (unicode)';
17 while (($speed > 1) && !$ok) {
21 die "$desc: fork() failed : $!";
23 local @SIG{qw/USR1 USR2/} = mrecv sub {
24 exit(($msg eq $_[0]) ? EXIT_SUCCESS : EXIT_FAILURE);
29 my $ret = EXIT_FAILURE;
31 local $SIG{ALRM} = sub { die 'timeout' };
32 my $a = (int(100 * (3 * length $msg) / $speed) || 1);
35 msend $msg => $pid, speed => $speed, utf8 => 1;
37 $ok = (WIFEXITED($?) && (WEXITSTATUS($?) == EXIT_SUCCESS));
46 ok($speed >= 1, $desc);
50 trysend8 'hello', 'ascii';
51 trysend8 "\0" x 10, 'few bits';
52 trysend8 "\x{FF}" x 10, 'lots of bits';
53 trysend8 "a\0b", 'null character';
54 trysend8 'éàùçà', 'extended';
55 trysend8 '€€€', 'unicode';
56 trysend8 'a€bécàd€e', 'mixed';