From: Steve Hay Date: Wed, 5 Apr 2006 10:35:58 +0000 (+0000) Subject: Simplify tests for fork() capabilities X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ec64f737c146f80372e587adab709f821d4d25f9;p=p5sagit%2Fp5-mst-13.2.git Simplify tests for fork() capabilities Jarkko pointed out that change #27710 was causing some black smoke so makes the tests for fork() simpler, as per lib\Test\Simple\t\fork.t for now. (Ideally we want a $Config{d_pseudofork}, as suggested by Andy Dougherty, but that'll have to wait until I get some more tuits.) p4raw-link: @27710 on //depot/perl: 2f78ce11bc4a9355ade5d20a0825b10fbb177169 p4raw-id: //depot/perl@27718 --- diff --git a/ext/IO/t/io_multihomed.t b/ext/IO/t/io_multihomed.t index d9355cf..3560d7b 100644 --- a/ext/IO/t/io_multihomed.t +++ b/ext/IO/t/io_multihomed.t @@ -10,6 +10,11 @@ BEGIN { use Config; BEGIN { + my $can_fork = $Config{d_fork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config{useithreads} and + $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/ + ); my $reason; if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bSocket\b/) { $reason = 'Socket extension unavailable'; @@ -17,15 +22,8 @@ BEGIN { elsif ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) { $reason = 'IO extension unavailable'; } - elsif ( - ! eval { - my $pid= fork(); - ! defined($pid) and die "Fork failed!"; - ! $pid and exit; - defined waitpid($pid, 0); - } - ) { - $reason = "no fork: $@"; + elsif (!$can_fork) { + $reason = 'no fork'; } if ($reason) { print "1..0 # Skip: $reason\n"; diff --git a/ext/IO/t/io_pipe.t b/ext/IO/t/io_pipe.t index 857d3d0..f4519a2 100755 --- a/ext/IO/t/io_pipe.t +++ b/ext/IO/t/io_pipe.t @@ -16,19 +16,17 @@ BEGIN { use Config; BEGIN { + my $can_fork = $Config{d_fork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config{useithreads} and + $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/ + ); my $reason; if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) { $reason = 'IO extension unavailable'; } - elsif ( - ! eval { - my $pid= fork(); - ! defined($pid) and die "Fork failed!"; - ! $pid and exit; - defined waitpid($pid, 0); - } - ) { - $reason = "no fork: $@"; + elsif (!$can_fork) { + $reason = 'no fork'; } elsif ($^O eq 'MSWin32' && !$ENV{TEST_IO_PIPE}) { $reason = 'Win32 testing environment not set'; diff --git a/ext/IO/t/io_sock.t b/ext/IO/t/io_sock.t index b743bf0..24d6818 100755 --- a/ext/IO/t/io_sock.t +++ b/ext/IO/t/io_sock.t @@ -10,6 +10,11 @@ BEGIN { use Config; BEGIN { + my $can_fork = $Config{d_fork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config{useithreads} and + $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/ + ); my $reason; if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bSocket\b/) { $reason = 'Socket extension unavailable'; @@ -17,15 +22,8 @@ BEGIN { elsif ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) { $reason = 'IO extension unavailable'; } - elsif ( - ! eval { - my $pid= fork(); - ! defined($pid) and die "Fork failed!"; - ! $pid and exit; - defined waitpid($pid, 0); - } - ) { - $reason = "no fork: $@"; + elsif (!$can_fork) { + $reason = 'no fork'; } if ($reason) { print "1..0 # Skip: $reason\n";