152bd00bfSmillert#!perl 252bd00bfSmillert 352bd00bfSmillertBEGIN { 452bd00bfSmillert chdir 't' if -d 't'; 552bd00bfSmillert @INC = ('../lib'); 6b39c5158Smillert require './test.pl'; 7898184e3Ssthen skip_all('cygwin specific test') unless $^O eq 'cygwin'; 852bd00bfSmillert} 952bd00bfSmillert 10b39c5158Smillertplan(tests => 16); 1152bd00bfSmillert 1252bd00bfSmillertis(Cygwin::winpid_to_pid(Cygwin::pid_to_winpid($$)), $$, 1352bd00bfSmillert "perl pid translates to itself"); 1452bd00bfSmillert 1552bd00bfSmillertmy $parent = getppid; 1652bd00bfSmillertSKIP: { 1752bd00bfSmillert skip "test not run from cygwin process", 1 if $parent <= 1; 1852bd00bfSmillert is(Cygwin::winpid_to_pid(Cygwin::pid_to_winpid($parent)), $parent, 1952bd00bfSmillert "parent pid translates to itself"); 2052bd00bfSmillert} 2152bd00bfSmillert 2252bd00bfSmillertmy $catpid = open my $cat, "|cat" or die "Couldn't cat: $!"; 2352bd00bfSmillertopen my $ps, "ps|" or die "Couldn't do ps: $!"; 2452bd00bfSmillertmy ($catwinpid) = map /^.\s+$catpid\s+\d+\s+\d+\s+(\d+)/, <$ps>; 2552bd00bfSmillertclose($ps); 2652bd00bfSmillert 2752bd00bfSmillertis(Cygwin::winpid_to_pid($catwinpid), $catpid, "winpid to pid"); 2852bd00bfSmillertis(Cygwin::pid_to_winpid($catpid), $catwinpid, "pid to winpid"); 2952bd00bfSmillertclose($cat); 30850e2753Smillert 31850e2753Smillertis(Cygwin::win_to_posix_path("t\\lib"), "t/lib", "win to posix path: t/lib"); 32850e2753Smillertis(Cygwin::posix_to_win_path("t/lib"), "t\\lib", "posix to win path: t\\lib"); 33850e2753Smillert 34850e2753Smillertuse Win32; 35850e2753Smillertuse Cwd; 36850e2753Smillertmy $pwd = getcwd(); 37850e2753Smillertchdir("/"); 38850e2753Smillertmy $winpath = Win32::GetCwd(); 39850e2753Smillertis(Cygwin::posix_to_win_path("/", 1), $winpath, "posix to absolute win path"); 40850e2753Smillertchdir($pwd); 41850e2753Smillertis(Cygwin::win_to_posix_path($winpath, 1), "/", "win to absolute posix path"); 42850e2753Smillert 43850e2753Smillertmy $mount = join '', `/usr/bin/mount`; 44b39c5158Smillert$mount =~ m|on /usr/bin type .+ \((\w+)[,\)]|m; 45b39c5158Smillertmy $binmode = $1 =~ /binmode|binary/; 46850e2753Smillertis(Cygwin::is_binmount("/"), $binmode ? 1 : '', "check / for binmount"); 47850e2753Smillert 48850e2753Smillertmy $rootmnt = Cygwin::mount_flags("/"); 49b39c5158Smillertok($binmode ? ($rootmnt =~ /,(binmode|binary)/) : ($rootmnt =~ /,textmode/), "check / mount_flags"); 50850e2753Smillertis(Cygwin::mount_flags("/cygdrive") =~ /,cygdrive/, 1, "check cygdrive mount_flags"); 51850e2753Smillert 52850e2753Smillert# Cygdrive mount prefix 53850e2753Smillertmy @flags = split(/,/, Cygwin::mount_flags('/cygdrive')); 54850e2753Smillertmy $prefix = pop(@flags); 55850e2753Smillertok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>')); 56*b8851fccSafresh1my $prefix2 = readlink "/proc/cygdrive"; 57*b8851fccSafresh1unless ($prefix2) { 58*b8851fccSafresh1 # fallback to old Cygwin, the drive need not actually exist, so 59*b8851fccSafresh1 # this will always work (but might return the wrong prefix if the 60*b8851fccSafresh1 # user re-mounted C:\ 61*b8851fccSafresh1 chomp($prefix2 = `cygpath C:`); 62*b8851fccSafresh1 $prefix2 = substr($prefix2, 0, -1-(length($prefix2)>2)); 63850e2753Smillert} 64*b8851fccSafresh1is($prefix, $prefix2, 'cygdrive mount prefix2 = ' . $prefix2); 65850e2753Smillert 66850e2753Smillertmy @mnttbl = Cygwin::mount_table(); 67850e2753Smillertok(@mnttbl > 0, "non empty mount_table"); 68850e2753Smillertfor $i (@mnttbl) { 69850e2753Smillert if ($i->[0] eq '/') { 70850e2753Smillert is($i->[2].",".$i->[3], $rootmnt, "same root mount flags"); 71850e2753Smillert last; 72850e2753Smillert } 73850e2753Smillert} 74850e2753Smillert 75850e2753Smillertok(Cwd->cwd(), "bug#38628 legacy"); 76