summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorYitzchak Scott-Thoennes <sthoenna@efn.org>2005-02-10 12:04:35 -0800
committerH.Merijn Brand <h.m.brand@xs4all.nl>2005-02-11 09:32:50 +0000
commit49fd6edc755e0fc505e10cdb1d5025c747291b4c (patch)
tree7a54e500da1a04559186a4beb5c2d7f80027a01e /t
parenta758b0b5fd9985d853637e2aa988519329533771 (diff)
downloadperl-49fd6edc755e0fc505e10cdb1d5025c747291b4c.tar.gz
Re: [PATCH] Re: perl winpid?
Message-ID: <20050211040434.GA3824@efn.org> p4raw-id: //depot/perl@23961
Diffstat (limited to 't')
-rw-r--r--t/lib/cygwin.t31
1 files changed, 31 insertions, 0 deletions
diff --git a/t/lib/cygwin.t b/t/lib/cygwin.t
new file mode 100644
index 0000000000..0148546143
--- /dev/null
+++ b/t/lib/cygwin.t
@@ -0,0 +1,31 @@
+#!perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = ('../lib');
+ unless ($^O eq "cygwin") {
+ print "1..0 # skipped: cygwin specific test\n";
+ exit 0;
+ }
+}
+
+use Test::More tests => 4;
+
+is(Cygwin::winpid_to_pid(Cygwin::pid_to_winpid($$)), $$,
+ "perl pid translates to itself");
+
+my $parent = getppid;
+SKIP: {
+ skip "test not run from cygwin process", 1 if $parent <= 1;
+ is(Cygwin::winpid_to_pid(Cygwin::pid_to_winpid($parent)), $parent,
+ "parent pid translates to itself");
+}
+
+my $catpid = open my $cat, "|cat" or die "Couldn't cat: $!";
+open my $ps, "ps|" or die "Couldn't do ps: $!";
+my ($catwinpid) = map /^.\s+$catpid\s+\d+\s+\d+\s+(\d+)/, <$ps>;
+close($ps);
+
+is(Cygwin::winpid_to_pid($catwinpid), $catpid, "winpid to pid");
+is(Cygwin::pid_to_winpid($catpid), $catwinpid, "pid to winpid");
+close($cat);