6 use POSIX qw/SIGINT SIGTERM SIGKILL EXIT_SUCCESS EXIT_FAILURE WIFEXITED WEXITSTATUS/;
10 use IPC::MorseSignals qw/msend mrecv/;
20 while (($speed > 1) && ($ok < $n)) {
22 $desc = "$n sends of $l bytes at $speed bits/s";
24 print STDERR "try $desc";
27 my @alpha = ('a' .. 'z');
28 my $msg = join '', map { $alpha[rand @alpha] } 1 .. $l;
31 die "$desc: fork() failed : $!";
33 local @SIG{qw/USR1 USR2/} = mrecv sub {
34 exit(($msg eq $_[0]) ? EXIT_SUCCESS : EXIT_FAILURE);
41 local $SIG{ALRM} = sub { die 'timeout' };
42 my $a = (int(100 * (3 * $l) / $speed) || 1);
45 msend $msg => $pid, speed => $speed;
47 if (WIFEXITED($?) && (WEXITSTATUS($?) == EXIT_SUCCESS)) {
50 print STDERR " transfer error\n";
59 print STDERR " timeout\n";
65 $desc = "$l bytes sent $n times";
67 print STDERR " OK\n\n";
68 push @res, "$desc at $speed bits/s";
70 print STDERR " FAILED\n\n";
71 push @res, "$desc FAILED";
91 print STDERR "=== Summary ===\n";
92 print STDERR "$_\n" for @res;