Commit | Line | Data |
---|---|---|
49fd6edc YST |
1 | #!perl |
2 | ||
3 | BEGIN { | |
4 | chdir 't' if -d 't'; | |
5 | @INC = ('../lib'); | |
eaa79d3d | 6 | require './test.pl'; |
028bf728 | 7 | skip_all('cygwin specific test') unless $^O eq 'cygwin'; |
49fd6edc YST |
8 | } |
9 | ||
eaa79d3d | 10 | plan(tests => 16); |
49fd6edc YST |
11 | |
12 | is(Cygwin::winpid_to_pid(Cygwin::pid_to_winpid($$)), $$, | |
13 | "perl pid translates to itself"); | |
14 | ||
15 | my $parent = getppid; | |
16 | SKIP: { | |
17 | skip "test not run from cygwin process", 1 if $parent <= 1; | |
18 | is(Cygwin::winpid_to_pid(Cygwin::pid_to_winpid($parent)), $parent, | |
19 | "parent pid translates to itself"); | |
20 | } | |
21 | ||
22 | my $catpid = open my $cat, "|cat" or die "Couldn't cat: $!"; | |
23 | open my $ps, "ps|" or die "Couldn't do ps: $!"; | |
24 | my ($catwinpid) = map /^.\s+$catpid\s+\d+\s+\d+\s+(\d+)/, <$ps>; | |
25 | close($ps); | |
26 | ||
27 | is(Cygwin::winpid_to_pid($catwinpid), $catpid, "winpid to pid"); | |
28 | is(Cygwin::pid_to_winpid($catpid), $catwinpid, "pid to winpid"); | |
29 | close($cat); | |
15414d2b RU |
30 | |
31 | is(Cygwin::win_to_posix_path("t\\lib"), "t/lib", "win to posix path: t/lib"); | |
32 | is(Cygwin::posix_to_win_path("t/lib"), "t\\lib", "posix to win path: t\\lib"); | |
33 | ||
34 | use Win32; | |
35 | use Cwd; | |
a25ce5f3 | 36 | my $pwd = getcwd(); |
15414d2b | 37 | chdir("/"); |
a25ce5f3 | 38 | my $winpath = Win32::GetCwd(); |
15414d2b RU |
39 | is(Cygwin::posix_to_win_path("/", 1), $winpath, "posix to absolute win path"); |
40 | chdir($pwd); | |
41 | is(Cygwin::win_to_posix_path($winpath, 1), "/", "win to absolute posix path"); | |
a25ce5f3 RU |
42 | |
43 | my $mount = join '', `/usr/bin/mount`; | |
5564a169 RU |
44 | $mount =~ m|on /usr/bin type .+ \((\w+)[,\)]|m; |
45 | my $binmode = $1 =~ /binmode|binary/; | |
a25ce5f3 | 46 | is(Cygwin::is_binmount("/"), $binmode ? 1 : '', "check / for binmount"); |
a25ce5f3 RU |
47 | |
48 | my $rootmnt = Cygwin::mount_flags("/"); | |
5564a169 | 49 | ok($binmode ? ($rootmnt =~ /,(binmode|binary)/) : ($rootmnt =~ /,textmode/), "check / mount_flags"); |
a25ce5f3 RU |
50 | is(Cygwin::mount_flags("/cygdrive") =~ /,cygdrive/, 1, "check cygdrive mount_flags"); |
51 | ||
74dc058d JH |
52 | # Cygdrive mount prefix |
53 | my @flags = split(/,/, Cygwin::mount_flags('/cygdrive')); | |
54 | my $prefix = pop(@flags); | |
03e4d232 AG |
55 | ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>')); |
56 | my $prefix2 = readlink "/proc/cygdrive"; | |
57 | unless ($prefix2) { | |
58 | # fallback to old Cygwin, the drive need not actually exist, so | |
59 | # this will always work (but might return the wrong prefix if the | |
60 | # user re-mounted C:\ | |
61 | chomp($prefix2 = `cygpath C:`); | |
62 | $prefix2 = substr($prefix2, 0, -1-(length($prefix2)>2)); | |
74dc058d | 63 | } |
03e4d232 | 64 | is($prefix, $prefix2, 'cygdrive mount prefix2 = ' . $prefix2); |
74dc058d | 65 | |
a25ce5f3 RU |
66 | my @mnttbl = Cygwin::mount_table(); |
67 | ok(@mnttbl > 0, "non empty mount_table"); | |
68 | for $i (@mnttbl) { | |
69 | if ($i->[0] eq '/') { | |
70 | is($i->[2].",".$i->[3], $rootmnt, "same root mount flags"); | |
fa5b08bc | 71 | last; |
a25ce5f3 RU |
72 | } |
73 | } | |
482150a7 JH |
74 | |
75 | ok(Cwd->cwd(), "bug#38628 legacy"); |