diff mbox

[Fortran,committed] XFAIL read_dir.f90 on FreeBSD

Message ID 20150901181627.GA55465@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl Sept. 1, 2015, 6:16 p.m. UTC
I've committed the patch that follows my .sig.

2015-09-01  Steven G. Kargl  <kargl@gcc.gnu.org>

	* gfortran.dg/read_dir.f90: XFAIL this testcase on FreeBSD.
	Clean-up a created directory if testcase fails.

I suspect that this testcase will fail on all *BSD OS's.

Comments

Steve Kargl Sept. 1, 2015, 6:18 p.m. UTC | #1
On Tue, Sep 01, 2015 at 11:16:27AM -0700, Steve Kargl wrote:
>     open(unit=10, file='junko.dir',iostat=ios,action='read',access='stream')
>     if (ios.ne.0) call abort
>     read(10, iostat=ios) c
> -   if (ios.ne.21) call abort
> +   if (ios.ne.21) then 
> +      close(10)

I forgot to mention that 'close(10, status="delete')' does not
work on a directory.  Should it?

> +      call system('rmdir junko.dir')
> +      call abort
> +   end if
> +   close(10)
>     call system('rmdir junko.dir')
Jerry DeLisle Sept. 1, 2015, 10:28 p.m. UTC | #2
On 09/01/2015 11:18 AM, Steve Kargl wrote:
> On Tue, Sep 01, 2015 at 11:16:27AM -0700, Steve Kargl wrote:
>>     open(unit=10, file='junko.dir',iostat=ios,action='read',access='stream')
>>     if (ios.ne.0) call abort
>>     read(10, iostat=ios) c
>> -   if (ios.ne.21) call abort
>> +   if (ios.ne.21) then 
>> +      close(10)
> 
> I forgot to mention that 'close(10, status="delete')' does not
> work on a directory.  Should it?
> 
>> +      call system('rmdir junko.dir')
>> +      call abort
>> +   end if
>> +   close(10)
>>     call system('rmdir junko.dir')
> 

Thanks for the touch up Steve.  I suspect other OS's will not work either.  I
assumed close with Status="delete" would not work on a directory.

Jerry
Janne Blomqvist Sept. 2, 2015, 8:30 a.m. UTC | #3
On Wed, Sep 2, 2015 at 1:28 AM, Jerry DeLisle <jvdelisle@charter.net> wrote:
> On 09/01/2015 11:18 AM, Steve Kargl wrote:
>> On Tue, Sep 01, 2015 at 11:16:27AM -0700, Steve Kargl wrote:
>>>     open(unit=10, file='junko.dir',iostat=ios,action='read',access='stream')
>>>     if (ios.ne.0) call abort
>>>     read(10, iostat=ios) c
>>> -   if (ios.ne.21) call abort
>>> +   if (ios.ne.21) then
>>> +      close(10)
>>
>> I forgot to mention that 'close(10, status="delete')' does not
>> work on a directory.  Should it?
>>
>>> +      call system('rmdir junko.dir')
>>> +      call abort
>>> +   end if
>>> +   close(10)
>>>     call system('rmdir junko.dir')
>>
>
> Thanks for the touch up Steve.  I suspect other OS's will not work either.  I
> assumed close with Status="delete" would not work on a directory.

That's because libgfortran uses unlink(2), which only works for files,
not directories. One could change that to use remove(3), which works
for both.

Also, I suspect the reason why it fails on freebsd is that errno
EISDIR is not 21 there. Perhaps one should just check for ios /= 0?
Unfortunately the __linux__ define isn't available since the switch to
cpp (IIRC there is a PR for that), so it's not that straightforward to
check which platform one runs on.
Steve Kargl Sept. 2, 2015, 3:03 p.m. UTC | #4
On Wed, Sep 02, 2015 at 11:30:07AM +0300, Janne Blomqvist wrote:
> On Wed, Sep 2, 2015 at 1:28 AM, Jerry DeLisle <jvdelisle@charter.net> wrote:
> > On 09/01/2015 11:18 AM, Steve Kargl wrote:
> >> On Tue, Sep 01, 2015 at 11:16:27AM -0700, Steve Kargl wrote:
> >>>     open(unit=10, file='junko.dir',iostat=ios,action='read',access='stream')
> >>>     if (ios.ne.0) call abort
> >>>     read(10, iostat=ios) c
> >>> -   if (ios.ne.21) call abort
> >>> +   if (ios.ne.21) then
> >>> +      close(10)
> >>
> >> I forgot to mention that 'close(10, status="delete')' does not
> >> work on a directory.  Should it?
> >>
> >>> +      call system('rmdir junko.dir')
> >>> +      call abort
> >>> +   end if
> >>> +   close(10)
> >>>     call system('rmdir junko.dir')
> >>
> >
> > Thanks for the touch up Steve.  I suspect other OS's will not work either.  I
> > assumed close with Status="delete" would not work on a directory.
> 
> That's because libgfortran uses unlink(2), which only works for files,
> not directories. One could change that to use remove(3), which works
> for both.

I suspect people who create directories and then 
want to delete them will use SYSTEM or the 
standard conforming equivalent.

> Also, I suspect the reason why it fails on freebsd is that errno
> EISDIR is not 21 there. Perhaps one should just check for ios /= 0?

I checked.  FreeBSD's EISDIR is 21; howevr, ios == 0 in this
case.  I haven't looked too deep.  FreeBSD is probably
adhering to the unix philosophy of "everything is a file".
diff mbox

Patch

Index: gfortran.dg/read_dir.f90
===================================================================
--- gfortran.dg/read_dir.f90	(revision 227380)
+++ gfortran.dg/read_dir.f90	(working copy)
@@ -1,4 +1,4 @@ 
-! { dg-do run }
+! { dg-do run { xfail *-*-freebsd* } }
 ! PR67367
 program bug
    implicit none
@@ -9,6 +9,11 @@  program bug
    open(unit=10, file='junko.dir',iostat=ios,action='read',access='stream')
    if (ios.ne.0) call abort
    read(10, iostat=ios) c
-   if (ios.ne.21) call abort
+   if (ios.ne.21) then 
+      close(10)
+      call system('rmdir junko.dir')
+      call abort
+   end if
+   close(10)
    call system('rmdir junko.dir')
 end program bug