Message ID | CAE4aFA=TVTDg-dAMo-rF5Rzt8LA3wUh=aBqw1OS7-HRs10N=JQ@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Thu, Oct 27, 2016 at 09:12:42AM -0400, Fritz Reese wrote: > On Thu, Oct 27, 2016 at 8:52 AM, Jakub Jelinek <jakub@redhat.com> wrote: > > On Thu, Oct 27, 2016 at 08:49:42AM -0400, Fritz Reese wrote: > >> > >> 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 > > Thanks. I could never find good documentation on the various dg-* > testing options. I was browsing other test files to figure out how to > express dec_io_5 and dec_io_6. I first saw "XFAIL", I assumed it meant > "eXpected FAIL", and used it since I "expected" dec_io_5 to "fail" at > runtime. I was only half-right... > > The attached should be correct now > > --- > 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, dec_io_6.f90: Don't use "test.txt", and use > dg-shouldfail/dg-output instead of XFAIL. LGTM. Jakub
diff --git a/gcc/testsuite/gfortran.dg/dec_io_5.f90 b/gcc/testsuite/gfortran.dg/dec_io_5.f90 index 9d44c6e..c6633a5 100644 --- a/gcc/testsuite/gfortran.dg/dec_io_5.f90 +++ b/gcc/testsuite/gfortran.dg/dec_io_5.f90 @@ -1,5 +1,6 @@ -! { dg-do run "xfail *-*-*" } +! { dg-do run } ! { dg-options "-fdec" } +! { dg-shouldfail "ACTION conflicts with READONLY" } ! ! Test that we get a run-time error for opening a READONLY file with ! ACTION='WRITE'. @@ -8,10 +9,11 @@ implicit none integer :: fd = 8 -character(*), parameter :: f = "test.txt" +character(*), parameter :: f = "dec_io_5.txt" character(10), volatile :: c c = 'write' -open(unit=fd,file=f,action=c,readonly) ! XFAIL "ACTION conflicts with READONLY" +open(unit=fd,file=f,action=c,readonly) end +! { dg-output "ACTION conflicts with READONLY" } diff --git a/gcc/testsuite/gfortran.dg/dec_io_6.f90 b/gcc/testsuite/gfortran.dg/dec_io_6.f90 index a0c0256..2dfaf9d 100644 --- a/gcc/testsuite/gfortran.dg/dec_io_6.f90 +++ b/gcc/testsuite/gfortran.dg/dec_io_6.f90 @@ -1,15 +1,29 @@ -! { dg-do run "xfail *-*-*" } +! { dg-do run } ! { dg-options "-fdec" } ! -! Test that we get a run-time error for close-on-delete with READONLY. +! Test that we get a run-time warning for close-on-delete with READONLY, +! and that the file is protected from deletion. ! implicit none integer :: fd = 8 -character(*), parameter :: f = "test.txt" +character(*), parameter :: f = "dec_io_6.txt" +logical :: exists + +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" +close(unit=fd,status='delete') ! { dg-output "file protected by READONLY" } + +inquire(file=f, EXIST=exists) +if (.not. exists) then + print *, 'file was not protected by READONLY!' + call abort() +endif + +open(unit=fd,file=f,action='write') +close(unit=fd,status='delete') ! cleanup end