3 use Test::More tests => 12;
5 use POSIX qw/SIGINT SIGTERM SIGKILL EXIT_SUCCESS EXIT_FAILURE WIFEXITED WEXITSTATUS/;
7 use IPC::MorseSignals qw/msend mrecv/;
15 my @alpha = ('a' .. 'z');
16 my $msg = join '', map { $alpha[rand @alpha] } 1 .. $l;
18 while (($speed > 1) && ($ok < $n)) {
20 $desc = "$n sends of $l bytes at $speed bits/s";
27 die "$desc: fork() failed : $!";
29 local @SIG{qw/USR1 USR2/} = mrecv sub {
30 exit(($msg eq $_[0]) ? EXIT_SUCCESS : EXIT_FAILURE);
36 local $SIG{ALRM} = sub { die 'timeout' };
37 my $a = (int(100 * (3 * $l) / $speed) || 1);
40 msend $msg => $pid, speed => $speed;
42 $ok += (WIFEXITED($?) && (WEXITSTATUS($?) == EXIT_SUCCESS));
53 $desc = "$l bytes sent $n times";
54 ok($speed >= 1, $desc);
55 push @res, $desc . (($speed) ? ' at ' . $speed . ' bits/s' : ' failed');
71 diag '=== Summary ===';