|
From: <jgr...@us...> - 2003-07-17 20:14:20
|
Update of /cvsroot/popfile/engine/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv16819/tests
Modified Files:
TestProxy.tst
Log Message:
More tests for Proxy
Index: TestProxy.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestProxy.tst,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TestProxy.tst 13 Jul 2003 05:21:21 -0000 1.4
--- TestProxy.tst 17 Jul 2003 20:14:17 -0000 1.5
***************
*** 81,85 ****
# Start a generic proxy on port 9999
! $p->config_( 'port', 9999 );
test_assert_equal( $p->start(), 1 );
$p->stop();
--- 81,86 ----
# Start a generic proxy on port 9999
! my $port = 9000 + int(rand(1000));
! $p->config_( 'port', $port );
test_assert_equal( $p->start(), 1 );
$p->stop();
***************
*** 101,105 ****
$sp->initialize();
! $sp->config_( 'port', 9999 );
test_assert_equal( $sp->start(), 1 );
test_assert( $sp->start_server() );
--- 102,106 ----
$sp->initialize();
! $sp->config_( 'port', $port );
test_assert_equal( $sp->start(), 1 );
test_assert( $sp->start_server() );
***************
*** 110,114 ****
Proto => "tcp",
PeerAddr => 'localhost',
! PeerPort => 9999 );
$sp->service();
--- 111,115 ----
Proto => "tcp",
PeerAddr => 'localhost',
! PeerPort => $port );
$sp->service();
***************
*** 135,138 ****
--- 136,198 ----
test_assert_regexp( $sp->received(), 'toserver' );
+ # Test the tee function, that send a line to the server
+ # or client and to the logger
+
+ $sp->tee_( $client, "teed\n" );
+ select( undef, undef, undef, 0.25 );
+ $sp->service_server();
+ test_assert_regexp( $sp->received(), 'teed' );
+ my @lastten = $l->last_ten();
+ test_assert_regexp( $lastten[$#lastten], 'teed' );
+
+ # Test the echo_to_regexp_ function
+
+ $sp->send( 'before1' );
+ $sp->send( 'before2' );
+ $sp->send( 'matchTHis' );
+ $sp->send( 'after' );
+ $sp->service_server();
+ open TEMP, ">temp.tmp";
+ $sp->echo_to_regexp_( $sp->{remote_client__}, \*TEMP, qr/TH/ );
+ close TEMP;
+ open TEMP, "<temp.tmp";
+ my $line = <TEMP>;
+ test_assert_regexp( $line, 'before1' );
+ $line = <TEMP>;
+ test_assert_regexp( $line, 'before2' );
+ $line = <TEMP>;
+ test_assert_regexp( $line, 'matchTHis' );
+ $line = <TEMP>;
+ test_assert( !defined( $line ) );
+ close TEMP;
+
+ my $handle = $sp->{remote_client__};
+ $line = <$handle>;
+ test_assert_regexp( $line, 'after' );
+
+ # Test echo_to_dot_
+
+ $sp->send( 'before1' );
+ $sp->send( 'before2' );
+ $sp->send( '.' );
+ $sp->send( 'after' );
+ $sp->service_server();
+ open TEMP, ">temp.tmp";
+ $sp->echo_to_dot_( $sp->{remote_client__}, \*TEMP );
+ close TEMP;
+ open TEMP, "<temp.tmp";
+ my $line = <TEMP>;
+ test_assert_regexp( $line, 'before1' );
+ $line = <TEMP>;
+ test_assert_regexp( $line, 'before2' );
+ $line = <TEMP>;
+ test_assert_regexp( $line, '\.' );
+ $line = <TEMP>;
+ test_assert( !defined( $line ) );
+ close TEMP;
+
+ $line = <$handle>;
+ test_assert_regexp( $line, 'after' );
+
# Close down the child process
***************
*** 140,141 ****
--- 200,205 ----
$sp->stop_server();
select( undef, undef, undef, 0.25 );
+
+ # Reap the children
+
+ $sp->reaper();
|