diff mbox

[Fortran] DEC Compatibility: New I/O Specifiers CARRIAGECONTROL, READONLY, SHARE with -fdec

Message ID CAE4aFAnXgmCcG+qDyiJZoDvNQEyeHL5cizgBwAzZmhgy6dqdUA@mail.gmail.com
State New
Headers show

Commit Message

Fritz Reese Oct. 27, 2016, 11:25 a.m. UTC
On Thu, Oct 27, 2016 at 7:02 AM Andreas Schwab <schwab@suse.de> wrote:
...
> At line 12 of file /usr/local/gcc/gcc-20161027/gcc/testsuite/gfortran.dg/dec_io_6.f90 (unit = 8)
> Fortran runtime error: Cannot open file 'test.txt': No such file or directory
>

Indeed.

From: Fritz Reese <fritzoreese@gmail.com>
Date: Thu, 27 Oct 2016 07:07:43 -0400
Subject: [PATCH] Fix open of nonexistant file in DEC I/O testcase.

        gcc/testsuite/gfortran.dg/
        * dec_io_5.f90: Rename 'test.txt' to 'dec_io_5.txt'
        * dec_io_6.f90: Create 'dec_io_6.txt' before reading it
---
 gcc/testsuite/gfortran.dg/dec_io_5.f90 |    2 +-
 gcc/testsuite/gfortran.dg/dec_io_6.f90 |    8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Jakub Jelinek Oct. 27, 2016, 11:32 a.m. UTC | #1
On Thu, Oct 27, 2016 at 07:25:24AM -0400, Fritz Reese wrote:
> On Thu, Oct 27, 2016 at 7:02 AM Andreas Schwab <schwab@suse.de> wrote:
> ...
> > At line 12 of file /usr/local/gcc/gcc-20161027/gcc/testsuite/gfortran.dg/dec_io_6.f90 (unit = 8)
> > Fortran runtime error: Cannot open file 'test.txt': No such file or directory
> >
> 
> Indeed.

Shouldn't something also remove dec_io_5.txt file if it is created?
Shall the (now xfailed, so not implemented yet?) runtime error terminate
the program, or can it be also just deleted later on?  If not,
we'll need some dg-final cleanup-target-file or something similar that will
remote_file target delete the file (similarly to cleanup-modules etc.).

	Jakub
Fritz Reese Oct. 27, 2016, 11:46 a.m. UTC | #2
On Thu, Oct 27, 2016 at 7:32 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Oct 27, 2016 at 07:25:24AM -0400, Fritz Reese wrote:
>> On Thu, Oct 27, 2016 at 7:02 AM Andreas Schwab <schwab@suse.de> wrote:
>> ...
>> > At line 12 of file /usr/local/gcc/gcc-20161027/gcc/testsuite/gfortran.dg/dec_io_6.f90 (unit = 8)
>> > Fortran runtime error: Cannot open file 'test.txt': No such file or directory
>> >
>>
>> Indeed.
>
> Shouldn't something also remove dec_io_5.txt file if it is created?
> Shall the (now xfailed, so not implemented yet?) runtime error terminate
> the program, or can it be also just deleted later on?  If not,
> we'll need some dg-final cleanup-target-file or something similar that will
> remote_file target delete the file (similarly to cleanup-modules etc.).
>
>         Jakub

For dec_io_5, the program (intentionally) crashes because "ACTION
conflicts with READONLY" so dec_io_5.txt is never created.

For dec_io_6, the "protected by READONLY" message is (intentionally) a
runtime warning and does not terminate the program, so the following
lines safely delete dec_io_6.txt.

I am not familiar enough with DG to know whether there is a better way
to express the intended behavior of the test programs. XFAIL is the
closest thing I could determine.

---
Fritz Reese
Jakub Jelinek Oct. 27, 2016, 12:16 p.m. UTC | #3
On Thu, Oct 27, 2016 at 07:46:16AM -0400, Fritz Reese wrote:
> > Shouldn't something also remove dec_io_5.txt file if it is created?
> > Shall the (now xfailed, so not implemented yet?) runtime error terminate
> > the program, or can it be also just deleted later on?  If not,
> > we'll need some dg-final cleanup-target-file or something similar that will
> > remote_file target delete the file (similarly to cleanup-modules etc.).
> >
> >         Jakub
> 
> For dec_io_5, the program (intentionally) crashes because "ACTION
> conflicts with READONLY" so dec_io_5.txt is never created.

So why dec_io_6.f90 worked at all (if it ever worked)?
And why the xfail when it works as expected?
> 
> For dec_io_6, the "protected by READONLY" message is (intentionally) a
> runtime warning and does not terminate the program, so the following
> lines safely delete dec_io_6.txt.
> 
> I am not familiar enough with DG to know whether there is a better way
> to express the intended behavior of the test programs. XFAIL is the
> closest thing I could determine.

	Jakub
Fritz Reese Oct. 27, 2016, 12:49 p.m. UTC | #4
On Thu, Oct 27, 2016 at 8:16 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Oct 27, 2016 at 07:46:16AM -0400, Fritz Reese wrote:
>> > Shouldn't something also remove dec_io_5.txt file if it is created?
>> > Shall the (now xfailed, so not implemented yet?) runtime error terminate
>> > the program, or can it be also just deleted later on?  If not,
>> > we'll need some dg-final cleanup-target-file or something similar that will
>> > remote_file target delete the file (similarly to cleanup-modules etc.).
>> >
>> >         Jakub
>>
>> For dec_io_5, the program (intentionally) crashes because "ACTION
>> conflicts with READONLY" so dec_io_5.txt is never created.
>
> So why dec_io_6.f90 worked at all (if it ever worked)?
> And why the xfail when it works as expected?
>>
>> For dec_io_6, the "protected by READONLY" message is (intentionally) a
>> runtime warning and does not terminate the program, so the following
>> lines safely delete dec_io_6.txt.

The presence of "test.txt" in dec_io_6.f90 was an artifact of me using
the same "test.txt" file for all dec_io_1 through dec_io_5 in my own
private tests. Thus since "test.txt" already existed from my own tests
I didn't catch when I forgot to switch to "dec_io_6.txt" before
submitting. I had the XFAIL in because I thought the DG failure was
coming from the runtime warning. I guess the fail was actually
happening because "test.txt" didn't exist - now that I correctly
renamed it to "dec_io_6.txt" you are right and the XFAIL is erroneous.
I should actually use INQUIRE to check whether the file was deleted on
close (it should not be for READONLY).

Do you know if there is there any way from DG to verify that a runtime
warning is emitted?

---
Fritz Reese

From: Fritz Reese <fritzoreese@gmail.com>
Date: Thu, 27 Oct 2016 08:46:33 -0400
Subject: [PATCH] Fix some DEC I/O testcases.

        gcc/testsuite/gfortran.dg/
        * dec_io_5.f90: Rename 'test.txt' to 'dec_io_5.txt'.
        * dec_io_6.f90: Use 'dec_io_6.txt' and INQUIRE instead of XFAIL.
---
 gcc/testsuite/gfortran.dg/dec_io_5.f90 |    2 +-
 gcc/testsuite/gfortran.dg/dec_io_6.f90 |   19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)
Jakub Jelinek Oct. 27, 2016, 12:52 p.m. UTC | #5
On Thu, Oct 27, 2016 at 08:49:42AM -0400, Fritz Reese wrote:
> The presence of "test.txt" in dec_io_6.f90 was an artifact of me using
> the same "test.txt" file for all dec_io_1 through dec_io_5 in my own
> private tests. Thus since "test.txt" already existed from my own tests
> I didn't catch when I forgot to switch to "dec_io_6.txt" before
> submitting. I had the XFAIL in because I thought the DG failure was
> coming from the runtime warning. I guess the fail was actually
> happening because "test.txt" didn't exist - now that I correctly
> renamed it to "dec_io_6.txt" you are right and the XFAIL is erroneous.
> I should actually use INQUIRE to check whether the file was deleted on
> close (it should not be for READONLY).
> 
> Do you know if there is there any way from DG to verify that a runtime
> warning is emitted?

Use dg-output for that.  And, if the test is supposed to exit with non-zero
exit status because of the runtime error, then also dg-shouldfail.

	Jakub
diff mbox

Patch

diff --git a/gcc/testsuite/gfortran.dg/dec_io_5.f90 b/gcc/testsuite/gfortran.dg/dec_io_5.f90
index 9d44c6e..a99aa76 100644
--- a/gcc/testsuite/gfortran.dg/dec_io_5.f90
+++ b/gcc/testsuite/gfortran.dg/dec_io_5.f90
@@ -8,7 +8,7 @@ 
 implicit none
 
 integer :: fd = 8
-character(*), parameter :: f = "test.txt"
+character(*), parameter :: f = "dec_io_5.txt"
 character(10), volatile :: c
 c = 'write'
 
diff --git a/gcc/testsuite/gfortran.dg/dec_io_6.f90 b/gcc/testsuite/gfortran.dg/dec_io_6.f90
index a0c0256..3c9ae5d 100644
--- a/gcc/testsuite/gfortran.dg/dec_io_6.f90
+++ b/gcc/testsuite/gfortran.dg/dec_io_6.f90
@@ -7,9 +7,15 @@ 
 implicit none
 
 integer :: fd = 8
-character(*), parameter :: f = "test.txt"
+character(*), parameter :: f = "dec_io_6.txt"
+
+open(unit=fd,file=f,action='write')
+close(unit=fd)
 
 open(unit=fd,file=f,action='read',readonly)
 close(unit=fd,status='delete') ! XFAIL "protected by READONLY"
 
+open(unit=fd,file=f,action='write')
+close(unit=fd,status='delete')
+
 end