Integrate with Sarathy.
[p5sagit/p5-mst-13.2.git] / t / lib / io_sock.t
index 0e002be..056d131 100755 (executable)
@@ -11,11 +11,19 @@ use Config;
 
 BEGIN {
     if (-d "lib" && -f "TEST") {
-        if (!$Config{'d_fork'} ||
-           (($Config{'extensions'} !~ /\bSocket\b/ ||
-             $Config{'extensions'} !~ /\bIO\b/) &&
-            !(($^O eq 'VMS') && $Config{d_socket}))) {
-           print "1..0\n";
+       my $reason;
+       if (! $Config{'d_fork'}) {
+           $reason = 'no fork';
+       }
+       elsif ($Config{'extensions'} !~ /\bSocket\b/) {
+           $reason = 'Socket extension unavailable';
+       }
+       elsif ($Config{'extensions'} !~ /\bIO\b/) {
+           $reason = 'IO extension unavailable';
+       }
+       undef $reason if $^O eq 'VMS' and $Config{d_socket};
+       if ($reason) {
+           print "1..0 # Skip: $reason\n";
            exit 0;
         }
     }
@@ -126,7 +134,7 @@ if($pid = fork()) {
     }
 
     # some machines seem to suffer from a race condition here
-    sleep(1);
+    sleep(2);
 
     $sock = IO::Socket::INET->new("127.0.0.1:$port");
     if ($sock) {
@@ -140,7 +148,7 @@ if($pid = fork()) {
     }
 
     # some machines seem to suffer from a race condition here
-#    sleep(1);
+    sleep(1);
 
     $sock = IO::Socket->new(Domain => AF_INET,
                             PeerAddr => "localhost:$port");
@@ -161,20 +169,24 @@ $server = IO::Socket->new(Domain => AF_INET,
                           LocalAddr => 'localhost');
 $port = $server->sockport;
 
-if ($pid = fork()) {
-    my $buf;
-    $server->recv($buf, 100);
-    print $buf;
-} elsif (defined($pid)) {
-    #child
-    $sock = IO::Socket::INET->new(Proto => 'udp',
-                                  PeerAddr => "localhost:$port");
-    $sock->send("ok 12\n");
-    sleep(1);
-    $sock->send("ok 12\n");  # send another one to be sure
-    exit;
+if ($^O eq 'mpeix') {
+    print("ok 12 # skipped\n")
 } else {
-    die;
+    if ($pid = fork()) {
+        my $buf;
+        $server->recv($buf, 100);
+        print $buf;
+    } elsif (defined($pid)) {
+        #child
+        $sock = IO::Socket::INET->new(Proto => 'udp',
+                                      PeerAddr => "localhost:$port");
+        $sock->send("ok 12\n");
+        sleep(1);
+        $sock->send("ok 12\n");  # send another one to be sure
+        exit;
+    } else {
+        die;
+    }
 }
 
 print "not " unless $server->blocking;