1! { dg-do run { target { ! { *-*-mingw* *-*-cygwin* } } } }
2! { dg-options "-std=gnu" }
3! See PR38956.  Test fails on cygwin when user has Administrator rights
4  implicit none
5  character(len=*), parameter :: n = "foobar_file_chmod_1"
6  integer :: i
7
8  open (10,file=n)
9  close (10,status="delete")
10
11  open (10,file=n)
12  close (10,status="keep")
13
14  if (access(n,"") /= 0 .or. access(n," ") /= 0 .or. access(n,"r") /= 0 .or. &
15      access(n,"R") /= 0 .or. access(n,"w") /= 0 .or. access(n,"W") /= 0) &
16    STOP 1
17
18  call chmod (n, "a+x", i)
19  if (i == 0) then
20    if (access(n,"x") /= 0 .or. access(n,"X") /= 0) STOP 2
21  end if
22
23  call chmod (n, "a-w", i)
24  if (i == 0 .and. getuid() /= 0) then
25    if (access(n,"w") == 0 .or. access(n,"W") == 0) STOP 3
26  end if
27
28  open (10,file=n)
29  close (10,status="delete")
30
31  if (access(n,"") == 0 .or. access(n," ") == 0 .or. access(n,"r") == 0 .or. &
32      access(n,"R") == 0 .or. access(n,"w") == 0 .or. access(n,"W") == 0) &
33    STOP 4
34
35  end
36