[Rt-commit] r9043 - rt/branches/3.7-EXPERIMENTAL/lib/RT

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Sep 13 15:22:12 EDT 2007


Author: sunnavy
Date: Thu Sep 13 15:22:11 2007
New Revision: 9043

Modified:
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm

Log:
repair previous commitment which is incomplete

Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm	Thu Sep 13 15:22:11 2007
@@ -592,4 +592,29 @@
     return %res;
 }
 
+sub generate_port {
+    my $self = shift;
+    my $port = 1024 + int rand(10000) + $$ % 1024;
+
+    my $paddr = sockaddr_in( $port, inet_aton('localhost') );
+    socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') )
+      or die "socket: $!";
+    if ( connect( SOCK, $paddr ) ) {
+        close(SOCK);
+        return generate_port();
+    }
+    close(SOCK);
+
+    return $port;
+}
+
+END {
+    if ( $ENV{RT_TEST_PARALLEL} && $created_new_db ) {
+        my $dbh =
+          _get_dbh( RT::Handle->DSN, $ENV{RT_DBA_USER}, $ENV{RT_DBA_PASSWORD} );
+        RT::Handle->DropDatabase( $dbh, Force => 1 );
+        $dbh->disconnect;
+    }
+}
+
 1;


More information about the Rt-commit mailing list