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