summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/chmod_1.f90
blob: 452b333dc35f6bd13686758e8fc91aba66822309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
! { dg-do run { target { ! { *-*-mingw* *-*-cygwin* spu-*-* } } } }
! { dg-options "-std=gnu" }
! See PR38956.  Test fails on cygwin when user has Administrator rights
  implicit none
  character(len=*), parameter :: n = "foobar_file_chmod_1"
  integer :: i

  open (10,file=n)
  close (10,status="delete")

  open (10,file=n)
  close (10,status="keep")

  if (access(n,"") /= 0 .or. access(n," ") /= 0 .or. access(n,"r") /= 0 .or. &
      access(n,"R") /= 0 .or. access(n,"w") /= 0 .or. access(n,"W") /= 0) &
    call abort

  call chmod (n, "a+x", i)
  if (i == 0) then
    if (access(n,"x") /= 0 .or. access(n,"X") /= 0) call abort
  end if

  call chmod (n, "a-w", i)
  if (i == 0 .and. getuid() /= 0) then
    if (access(n,"w") == 0 .or. access(n,"W") == 0) call abort
  end if

  open (10,file=n)
  close (10,status="delete")

  if (access(n,"") == 0 .or. access(n," ") == 0 .or. access(n,"r") == 0 .or. &
      access(n,"R") == 0 .or. access(n,"w") == 0 .or. access(n,"W") == 0) &
    call abort

  end