Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test tweaks and followtail fix

  • Loading branch information...
commit faff6ccbec969ff914a22c8c4c6dd9b8f39d023d 1 parent e0749fa
@rcaputo authored
View
9 Changes
@@ -30,9 +30,16 @@ subversions are available from <http://www.newts.org/~troc/poe.html>.
`-----------------
-0.1010 2000.??.?? (!!!)
+0.1010 2000.06.20 (!!!)
-----------------------
+Wheel::FollowTail was working on its filehandles before setting them
+non-blocking. Rearranged a couple lines of code to turn off blocking
+before working with filehandles.
+
+Tweaked the signals tests to wait longer for child processes to
+terminate.
+
(!!!) I have nothing good to say about POE::Kernel's experimental
fork() method, so I will refrain from saying anything more than "It
has been removed." Please use plain fork(2).
View
59 README
@@ -61,25 +61,11 @@ Finally you can install it:
Test Results and Coverage
-------------------------
-Test results for 0.1009 or a 486-50 with not much memory:
-
- t/00_coverage.......ok
- t/01_sessions.......ok
- t/02_alarms.........ok
- t/03_aliases........ok
- t/04_selects........ok
- t/05_macros.........ok
- t/06_tk.............ok
- t/07_event..........ok
- t/08_errors.........ok
- t/09_wheels_unix....ok
- t/10_wheels_tcp.....ok
- t/11_signals_poe....ok
- t/12_signals_ev.....ok
- t/13_wheels_udp.....ok
- t/14_wheels_ft......ok
- All tests successful.
- Files=15, Tests=179, 471 wallclock secs (240.88 cusr + 27.94 csys = 268.82 CPU)
+Test results for 0.1010 running FreeBSD 4.0-STABLE with perl 5.6.0,
+Event 0.79, and Perl/Tk 800.021:
+
+All tests successful.
+Files=17, Tests=212, 479 wallclock secs (238.52 cusr + 23.65 csys = 262.16 CPU)
POE's development after 0.1005 consists of a big push to test
everything. To further this effort, the author wrote a test coverage
@@ -88,23 +74,24 @@ Anyway, here's the test coverage summary for version 0.1009. The numbers
don't match up yet, but this is a general guideline for how well-tested
POE is.
- Source File = Ran / Total = Covered
- POE.pm = 19 / 19 = 100.00%
- POE/Component/Server/TCP.pm = 23 / 23 = 100.00%
- POE/Driver/SysRW.pm = 42 / 54 = 77.78%
- POE/Filter/Block.pm = 21 / 24 = 87.50%
- POE/Filter/HTTPD.pm = 11 / 85 = 12.94%
- POE/Filter/Line.pm = 15 / 20 = 75.00%
- POE/Filter/Reference.pm = 4 / 66 = 6.06%
- POE/Filter/Stream.pm = 2 / 11 = 18.18%
- POE/Kernel.pm = 697 / 926 = 75.27%
- POE/Preprocessor.pm = 119 / 138 = 86.23%
- POE/Session.pm = 81 / 194 = 41.75%
- POE/Wheel/FollowTail.pm = 54 / 69 = 78.26%
- POE/Wheel/ListenAccept.pm = 5 / 43 = 11.63%
- POE/Wheel/ReadWrite.pm = 100 / 183 = 54.64%
- POE/Wheel/SocketFactory.pm = 194 / 275 = 70.55%
- All Told = 1387 / 2151 = 64.48%
+Source File = Ran / Total = Covered
+POE.pm = 19 / 19 = 100.00%
+POE/Component/Server/TCP.pm = 22 / 23 = 95.65%
+POE/Driver/SysRW.pm = 42 / 54 = 77.78%
+POE/Filter/Block.pm = 34 / 37 = 91.89%
+POE/Filter/HTTPD.pm = 11 / 85 = 12.94%
+POE/Filter/Line.pm = 15 / 20 = 75.00%
+POE/Filter/Reference.pm = 4 / 66 = 6.06%
+POE/Filter/Stream.pm = 11 / 11 = 100.00%
+POE/KernePOE/Kernel.pm = 0 / 2 = 0.00%
+POE/Kernel.pm = 712 / 904 = 78.76%
+POE/Preprocessor.pm = 119 / 138 = 86.23%
+POE/Session.pm = 85 / 194 = 43.81%
+POE/Wheel/FollowTail.pm = 54 / 69 = 78.26%
+POE/Wheel/ListenAccept.pm = 5 / 43 = 11.63%
+POE/Wheel/ReadWrite.pm = 100 / 183 = 54.64%
+POE/Wheel/SocketFactory.pm = 194 / 275 = 70.55%
+All Told = 1427 / 2123 = 67.22%
Good luck, and thank you for reading!
View
8 lib/POE/Wheel/FollowTail.pm
@@ -50,6 +50,12 @@ sub new {
$self->_define_states();
+ # Nudge the wheel into action before performing initial operations
+ # on it. Part of the Kernel's select() logic is making things
+ # non-blocking, and the following code will assume that.
+
+ $poe_kernel->select($handle, $self->{state_read});
+
# Try to position the file pointer before the end of the file. This
# is so we can "tail -f" an existing file.
@@ -63,8 +69,6 @@ sub new {
$filter->get($raw_input);
}
}
- # nudge the wheel into action
- $poe_kernel->select($handle, $self->{state_read});
$self;
}
View
12 mylib/Devel/Trace.pm
@@ -9,31 +9,43 @@ package Trace; # satisfies 'use'
package DB;
use vars qw($sub);
+use POSIX;
+
sub CALL_COUNT () { 0 }
sub SUB_NAME () { 1 }
sub SOURCE_CODE () { 2 }
my %statistics;
+my $signal_set;
BEGIN {
unlink "$0.coverage";
open STATS, ">$0.coverage" or die "can't write $0.coverage: $!";
+ $signal_set = POSIX::SigSet->new();
+ $signal_set->fillset();
}
# &DB is called for every breakpoint that's encountered. We use it to
# track which code is instrumented during a given program run.
sub DB {
+ # Try to block signal delivery while this is recording information.
+ sigprocmask( SIG_BLOCK, $signal_set );
+
my ($package, $file, $line) = caller;
# Skip lines that aren't in the POE namespace. Skip lines ending
# with "]", which are evals.
+ return unless $package =~ /^POE/;
return unless $file =~ /POE/ and $file !~ /\]$/;
# Gather a statistic for this line.
$statistics{$file}->{$line} = [ 0, '(uninitialized)', '(uninitialized)' ]
unless exists $statistics{$file}->{$line};
$statistics{$file}->{$line}->[CALL_COUNT]++;
+
+ # Unblock signals now that we're done.
+ sigprocmask( SIG_UNBLOCK, $signal_set );
}
# &sub is a proxy function that's used to trace function calls. We
View
16 mylib/coverage.perl
@@ -12,6 +12,14 @@
sub SUB_NAME () { 1 }
sub SOURCE_CODE () { 2 }
+# Ignore most signals.
+
+foreach (keys %SIG) {
+ next if /^(__.*__|CH?LD|INT)$/;
+ next unless defined $SIG{$_};
+ $SIG{$_} = 'IGNORE';
+}
+
# Find the tests.
my $test_directory =
@@ -33,6 +41,7 @@
# goto SPANG;
foreach my $test_file (@test_files) {
+
unlink "$test_file.coverage";
print "*** Testing $test_file ...\n";
@@ -42,10 +51,7 @@
system( '/usr/bin/perl',
'-Ilib', '-I../lib', '-I.', '-I..', '-d:Trace', $test_file
);
- if ($result) {
- warn "can't profile $test_file: ($result) $!";
- next;
- }
+ warn "error running $test_file: ($result) $!" if $result;
}
SPANG:
@@ -99,6 +105,8 @@
my $ueber_total = 0;
my $ueber_called = 0;
foreach my $file (sort keys %statistics) {
+ next unless $file =~ /^POE.*\.pm$/;
+
my $file_total = 0;
my $file_called = 0;
my $lines = $statistics{$file};
View
34 tests/01_sessions.t
@@ -6,7 +6,7 @@
use strict;
use lib qw(./lib ../lib);
use TestSetup;
-&test_setup(15);
+&test_setup(17);
# Turn on all asserts.
sub POE::Kernel::ASSERT_DEFAULT () { 1 }
@@ -71,21 +71,18 @@ POE::Session->create
sub {
$_[HEAP]->{kills_to_go} = $event_count;
$_[KERNEL]->sig( USR1 => 'sigusr1_target' );
- $_[KERNEL]->delay( fire_sigusr1 => 0.5 );
- },
- _stop =>
- sub {
+ $_[KERNEL]->delay( fire_sigusr1 => 1 );
},
fire_sigusr1 =>
sub {
if ($_[HEAP]->{kills_to_go}--) {
- $_[KERNEL]->delay( fire_sigusr1 => 0.5 );
- kill 'USR1', $$;
+ $_[KERNEL]->delay( fire_sigusr1 => 1 );
+ kill USR1 => $$;
}
# One last timer so the session lingers long enough to catch
# the final signal.
else {
- $_[KERNEL]->delay( nonexistent_state => 0.5 );
+ $_[KERNEL]->delay( nonexistent_state => 1 );
}
},
sigusr1_target =>
@@ -141,6 +138,8 @@ POE::Session->create
},
);
+print "ok 3\n";
+
# A simple client session. It requests five counts and then stops.
# Its magic is that it passes a postback for the response.
@@ -165,28 +164,37 @@ POE::Session->create
response =>
sub {
$postback_test = 0 if $_[ARG0]->[0] != $_[ARG1]->[0];
- $_[KERNEL]->yield( 'query' ) if $_[HEAP]->{cookie} < 5;
+ if ($_[HEAP]->{cookie} < 5) {
+ $_[KERNEL]->yield( 'query' );
+ }
},
}
);
+print "ok 4\n";
+
+# The coverage testing runtime tracker hangs this test. We override
+# POE's SIGINT handler so that it can be killed manually and will
+# exit gracefully.
+$SIG{INT} = sub { exit; };
+
# Now run them 'til they complete.
$poe_kernel->run();
# Now make sure they've run.
for (my $i=0; $i<$machine_count; $i++) {
print 'not ' unless $completions[$i] == $event_count;
- print 'ok ', $i+3, "\n";
+ print 'ok ', $i+5, "\n";
}
# Were all the signals caught?
print 'not ' unless $signals_caught == $event_count;
-print "ok 13\n";
+print "ok 15\n";
# Did the postbacks work?
print 'not ' unless $postback_test;
-print "ok 14\n";
+print "ok 16\n";
-print "ok 15\n";
+print "ok 17\n";
exit;
View
13 tests/11_signals_poe.t
@@ -13,7 +13,7 @@ use TestSetup;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }
use POE;
-my $fork_count = 16;
+my $fork_count = 8;
# Use Time::HiRes, if it's available. This will get us super accurate
# sleep times so all the child processes wake up close together. The
@@ -27,6 +27,10 @@ eval {
# Set up a signal catching session. This test uses plain fork(2) and
# POE's $SIG{CHLD} handler.
+my $delay_per_child = time() - $^T;
+$delay_per_child = 5 if $delay_per_child < 5;
+warn "delaying $delay_per_child per child";
+
POE::Session->create
( inline_states =>
{ _start =>
@@ -34,9 +38,9 @@ POE::Session->create
$_[HEAP]->{forked} = $_[HEAP]->{reaped} = 0;
$_[KERNEL]->sig( CHLD => 'catch_sigchld' );
- my $wake_time = time() + 30;
+ my $wake_time = time() + ($delay_per_child * $fork_count);
- # Fork 16 child processes, all to exit at the same time.
+ # Fork some child processes, all to exit at the same time.
for (my $child = 0; $child < $fork_count; $child++) {
my $child_pid = fork;
@@ -61,7 +65,7 @@ POE::Session->create
print "not ok 1 # forked $_[HEAP]->{forked} out of $fork_count\n";
}
- $_[KERNEL]->delay( time_is_up => 120 );
+ $_[KERNEL]->delay( time_is_up => ($delay_per_child * $fork_count * 2) );
},
_stop =>
@@ -78,7 +82,6 @@ POE::Session->create
catch_sigchld =>
sub {
$_[HEAP]->{reaped}++;
- $_[KERNEL]->delay( time_is_up => 15 );
},
time_is_up =>
View
8 tests/12_signals_ev.t
@@ -22,7 +22,7 @@ use POE;
&test_setup(2);
-my $fork_count = 16;
+my $fork_count = 8;
# Everything past here should be identical to 11_signals_poe.t
@@ -45,9 +45,9 @@ POE::Session->create
$_[HEAP]->{forked} = $_[HEAP]->{reaped} = 0;
$_[KERNEL]->sig( CHLD => 'catch_sigchld' );
- my $wake_time = time() + 30;
+ my $wake_time = time() + 60;
- # Fork 16 child processes, all to exit at the same time.
+ # Fork some child processes, all to exit at the same time.
for (my $child = 0; $child < $fork_count; $child++) {
my $child_pid = fork;
@@ -89,7 +89,7 @@ POE::Session->create
catch_sigchld =>
sub {
$_[HEAP]->{reaped}++;
- $_[KERNEL]->delay( time_is_up => 15 );
+ $_[KERNEL]->delay( time_is_up => 60 );
},
time_is_up =>
Please sign in to comment.
Something went wrong with that request. Please try again.