Skip to content
Browse files

Even more debug output on tests

  • Loading branch information...
1 parent 4a19c69 commit bfede064c8f66b892b44c6ba24be28472e91894a @ruoso committed Jun 4, 2011
Showing with 25 additions and 13 deletions.
  1. +2 −0 Changes
  2. +23 −13 t/02-socket.t
View
2 Changes
@@ -1,5 +1,7 @@
cpan/0.004
+ 4a19c69 2011-06-02 Daniel Ruoso
+ bump version
1462b13 2011-06-02 Daniel Ruoso
change tests so that we get more info from reports
b447605 2011-05-28 Daniel Ruoso
View
36 t/02-socket.t
@@ -19,32 +19,35 @@ END {
unlink $socket_name;
}
+print '#'."[MAIN] will fork server\n";
my $server_pid = fork();
if ($server_pid == 0) {
# this is our server that will keep buffer for a while...
my $sock = IO::Socket::UNIX->new( Local => $socket_name, Listen => 1 ) or die $!;
my $sock_c = $sock->accept() or die $!;
my @buffer;
my $count = 0;
- #warn "[SERVER] before loop.\n";
+ print '#'."[SERVER] before loop.\n";
while (my $input = $sock_c->getline()) {
chomp $input;
- #warn "[SERVER] got $input.\n";
+ print '#'."[SERVER] got $input.\n";
push @buffer, uc($input);
if ($count++ & 1) {
- #warn "[SERVER] print.\n";
+ print '#'."[SERVER] print.\n";
$sock_c->print(shift(@buffer)."\n");
}
last if $input eq 'case';
}
- #warn "[SERVER] after loop.\n";
+ print '#'."[SERVER] after loop.\n";
$sock_c->print($_."\n") for @buffer;
- #warn "[SERVER] after print.\n";
+ print '#'."[SERVER] after print.\n";
+ $sock_c->close;
exit 0;
} elsif (not defined $server_pid) {
die 'Failed to fork server side.';
}
+print '#'."[MAIN] Will setup the pipes\n";
# The STDIN/STDOUT pipes for our client...
my ($cli_stdin_r, $cli_stdin_w, $cli_stdout_r, $cli_stdout_w) = map { IO::Handle->new() } 1..4;
pipe($cli_stdin_r, $cli_stdin_w);
@@ -54,6 +57,7 @@ $cli_stdin_w->autoflush(1);
$cli_stdout_r->autoflush(1);
$cli_stdout_w->autoflush(1);
+print '#'."[MAIN] Will fork the client\n";
my $client_pid = fork();
if ($client_pid == 0) {
require Test::More;
@@ -63,20 +67,21 @@ if ($client_pid == 0) {
# this is our client...
# let's sleep 2 seconds so the proxy starts...
my @text = qw(this is our test set of strings to be sent lower case);
- #warn "[CLIENT] starting loop.\n";
+ print '#'."[CLIENT] starting loop.\n";
foreach my $l (@text) {
- #warn "[CLIENT] wrote line $l.\n";
+ print '#'."[CLIENT] wrote line $l.\n";
$cli_stdin_w->print($l."\n");
}
- #warn "[CLIENT] out of write loop.\n";
- $cli_stdin_w->close();
+ print '#'."[CLIENT] out of write loop.\n";
my @ret;
while (my $l = $cli_stdout_r->getline()) {
chomp $l;
- #warn "[CLIENT] got line $l.\n";
+ print '#'."[CLIENT] got line $l.\n";
push @ret, $l;
}
- #warn "[CLIENT] read it all.\n";
+ $cli_stdin_w->close();
+ $cli_stdout_r->close();
+ print '#'."[CLIENT] read it all.\n";
is($ret[$_], uc($text[$_])) for 0..$#text;
exit;
} elsif (not defined $client_pid) {
@@ -86,9 +91,10 @@ if ($client_pid == 0) {
$cli_stdin_w->close;
$cli_stdout_r->close;
-# we sleep to give time for the server to start...
+print '#'."[MAIN] we sleep to give time for the server to start\n";
sleep 1;
+print '#'."[MAIN] setup the proxy\n";
# we now finally setup our proxy
my $sock = IO::Socket::UNIX->new( Peer => $socket_name ) or die $!;
$sock->autoflush(1);
@@ -99,15 +105,19 @@ my $bh = IO::BindHandles->new
]
);
+print '#'."[MAIN] proxy loop\n";
while ($bh->bound()) {
+ print '#'."[MAIN] rwcycle\n";
$bh->rwcycle();
}
-
+print '#'."[MAIN] out of loop\n";
$cli_stdin_r->close();
$cli_stdout_w->close();
$sock->close();
+print '#'."[MAIN] waiting for processes\n";
waitpid $server_pid, 0;
waitpid $client_pid, 0;
+print '#'."[MAIN] exitting\n";
exit 0;

0 comments on commit bfede06

Please sign in to comment.
Something went wrong with that request. Please try again.