Update IPC::Cmd to cpan version 0.54
[p5sagit/p5-mst-13.2.git] / cpan / Win32 / t / GetCurrentThreadId.t
1 use strict;\r
2 use Config qw(%Config);\r
3 use Test;\r
4 use Win32;\r
5 \r
6 my $fork_emulation = $Config{ccflags} =~ /PERL_IMPLICIT_SYS/;\r
7 \r
8 my $tests = $fork_emulation ? 4 : 2;\r
9 plan tests => $tests;\r
10 \r
11 my $pid = $$+0; # make sure we don't copy any magic to $pid\r
12 \r
13 if ($^O eq "cygwin") {\r
14     skip(!defined &Cygwin::pid_to_winpid,\r
15          Cygwin::pid_to_winpid($pid),\r
16          Win32::GetCurrentProcessId());\r
17 }\r
18 else {\r
19     ok($pid, Win32::GetCurrentProcessId());\r
20 }\r
21 \r
22 if ($fork_emulation) {\r
23     # This test relies on the implementation detail that the fork() emulation\r
24     # uses the negative value of the thread id as a pseudo process id.\r
25     if (my $child = fork) {\r
26         waitpid($child, 0);\r
27         exit 0;\r
28     }\r
29     ok(-$$, Win32::GetCurrentThreadId());\r
30 \r
31     # GetCurrentProcessId() should still return the real PID\r
32     ok($pid, Win32::GetCurrentProcessId());\r
33     ok($$ != Win32::GetCurrentProcessId());\r
34 }\r
35 else {\r
36     # here we just want to see something.\r
37     ok(Win32::GetCurrentThreadId() > 0);\r
38 }\r