diff options
author | Steve Hay <SteveHay@planit.com> | 2008-06-30 07:37:29 +0000 |
---|---|---|
committer | Steve Hay <SteveHay@planit.com> | 2008-06-30 07:37:29 +0000 |
commit | a7aed57248a1b7f3990887d947f738c29c496209 (patch) | |
tree | 954ed0f25931ff78c7e7f9dc5f5643aaa32f79fe /ext/Win32/t/GetCurrentThreadId.t | |
parent | b11304a19556c47855448c1edd428f188c030a65 (diff) | |
download | perl-a7aed57248a1b7f3990887d947f738c29c496209.tar.gz |
Upgrade to Win32-0.38
(including changes to GetCurrentThreadId.t which should have gone into
the 0.37 upgrade, but which I missed then)
p4raw-id: //depot/perl@34094
Diffstat (limited to 'ext/Win32/t/GetCurrentThreadId.t')
-rw-r--r-- | ext/Win32/t/GetCurrentThreadId.t | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/ext/Win32/t/GetCurrentThreadId.t b/ext/Win32/t/GetCurrentThreadId.t index 4db2c1417a..ce98f3e562 100644 --- a/ext/Win32/t/GetCurrentThreadId.t +++ b/ext/Win32/t/GetCurrentThreadId.t @@ -3,16 +3,34 @@ use Config qw(%Config); use Test; use Win32; -plan tests => 1; +my $fork_emulation = $Config{ccflags} =~ /PERL_IMPLICIT_SYS/; -# This test relies on the implementation detail that the fork() emulation -# uses the negative value of the thread id as a pseudo process id. -if ($Config{ccflags} =~ /PERL_IMPLICIT_SYS/) { - if (my $pid = fork) { - waitpid($pid, 0); +my $tests = $fork_emulation ? 4 : 2; +plan tests => $tests; + +my $pid = $$+0; # make sure we don't copy any magic to $pid + +if ($^O eq "cygwin") { + skip(!defined &Cygwin::pid_to_winpid, + Cygwin::pid_to_winpid($pid), + Win32::GetCurrentProcessId()); +} +else { + ok($pid, Win32::GetCurrentProcessId()); +} + +if ($fork_emulation) { + # This test relies on the implementation detail that the fork() emulation + # uses the negative value of the thread id as a pseudo process id. + if (my $child = fork) { + waitpid($child, 0); exit 0; } ok(-$$, Win32::GetCurrentThreadId()); + + # GetCurrentProcessId() should still return the real PID + ok($pid, Win32::GetCurrentProcessId()); + ok($$ != Win32::GetCurrentProcessId()); } else { # here we just want to see something. |