2011-02-15 Tobias Burnus <burnus@net-b.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / open_errors.f90
blobd6f1e4305260c8ddc26367b0bfa200e4c48ebd1d
1 ! { dg-do run { target { ! { *-*-mingw* *-*-cygwin* spu-*-* } } } }
2 ! PR30005 Enhanced error messages for OPEN
3 ! Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>
4 ! See PR38956. Test fails on cygwin when user has Administrator rights
5 character(60) :: msg
6 character(25) :: n = "temptestfile"
7 logical :: there
8 inquire(file=n, exist=there)
9 if (.not.there) then
10 open(77,file=n,status="new")
11 close(77, status="keep")
12 endif
13 msg=""
14 open(77,file=n,status="new", iomsg=msg, iostat=i)
15 if (i == 0) call abort()
16 if (msg /= "File 'temptestfile' already exists") call abort()
18 open(77,file=n,status="old")
19 close(77, status="delete")
20 open(77,file=n,status="old", iomsg=msg, iostat=i)
21 if (i == 0) call abort()
22 if (msg /= "File 'temptestfile' does not exist") call abort()
24 open(77,file="./", iomsg=msg, iostat=i)
25 if (msg /= "'./' is a directory" .and. msg /= "Invalid argument") call abort()
27 open(77,file=n,status="new")
28 i = chmod(n, "-w")
29 if (i == 0 .and. getuid() /= 0) then
30 close(77, status="keep")
31 open(77,file=n, iomsg=msg, iostat=i, action="write")
32 if (i == 0) call abort()
33 if (msg /= "Permission denied trying to open file 'temptestfile'") call abort()
34 endif
36 i = chmod(n,"+w")
37 open(77,file=n, iomsg=msg, iostat=i, action="read")
38 close(77, status="delete")
39 end