| 1 |
! { dg-do run { target { ! { *-*-mingw* *-*-cygwin* } } } } |
| 2 |
! PR30005 Enhanced error messages for OPEN |
| 3 |
! Submitted by Jerry DeLisle <[email protected]> |
| 4 |
! See PR38956. Test fails on cygwin when user has Administrator rights |
| 5 |
! As of the fix for PR 65200, the error message is partly generated by |
| 6 |
! strerror*(), so can depend on the target and the locale, so check |
| 7 |
! only the beginning of the error string, which should be constant. |
| 8 |
character(60) :: msg |
| 9 |
character(25) :: n = "temptestfile" |
| 10 |
logical :: there |
| 11 |
inquire(file=n, exist=there) |
| 12 |
if (.not.there) then |
| 13 |
open(77,file=n,status="new") |
| 14 |
close(77, status="keep") |
| 15 |
endif |
| 16 |
msg="" |
| 17 |
open(77,file=n,status="new", iomsg=msg, iostat=i) |
| 18 |
if (i == 0) STOP 1 |
| 19 |
if (msg(1:33) /= "Cannot open file 'temptestfile': ") STOP 2 |
| 20 |
|
| 21 |
open(77,file=n,status="old") |
| 22 |
close(77, status="delete") |
| 23 |
open(77,file=n,status="old", iomsg=msg, iostat=i) |
| 24 |
if (i == 0) STOP 3 |
| 25 |
if (msg(1:33) /= "Cannot open file 'temptestfile': ") STOP 4 |
| 26 |
|
| 27 |
open(77,file="./", iomsg=msg, iostat=i) |
| 28 |
if (msg(1:23) /= "Cannot open file './': " & |
| 29 |
.and. msg /= "Invalid argument") STOP 5 |
| 30 |
|
| 31 |
open(77,file=n,status="new") |
| 32 |
i = chmod(n, "-w") |
| 33 |
if (i == 0 .and. getuid() /= 0) then |
| 34 |
close(77, status="keep") |
| 35 |
open(77,file=n, iomsg=msg, iostat=i, action="write") |
| 36 |
if (i == 0) STOP 6 |
| 37 |
if (msg(1:33) /= "Cannot open file 'temptestfile': ") STOP 7 |
| 38 |
endif |
| 39 |
|
| 40 |
i = chmod(n,"+w") |
| 41 |
open(77,file=n, iomsg=msg, iostat=i, action="read") |
| 42 |
close(77, status="delete") |
| 43 |
end |