On Thu, Jul 06, 2006 at 10:48:50PM +0200, FX Coudert wrote:
> I'd like to include cases in the gfortran testsuite to check that we 
> correctly issue a run-time error, and exit with non-zero code.
> 
> I have the following example:
> 
> $ cat runtime_error.f90
> ! { dg-do run }
> ! { dg-options "-fbounds-check" }
>   integer :: x(5), y(5)
>   x = y((/0,2,3,4,6/))
>   end
> $ gfortran runtime_error.f90 -fbounds-check
> $ ./a.out ; echo $?
> Fortran runtime error: Array reference out of bounds for array 'y', 
> lower bound of dimension 1 exceeded (in file 'runtime_error.f90', at line 4)
> 2
> 
> 
> I'd like to be able to check that this code indeed issue the error 
> message on stderr and indicate to dejagnu that non-zero exit codes does 
> not mean that the test FAILed). How can I do that?

I've got a patch that adds a new test directive, dg-shouldfail, to
expect the executable to exit with a nonzero exit status.  I was
waiting for input from the Fortran developers who requested that
facility, and will check it in later this week.  There are other
test directives that let you look for runtime messages in the test
output.

Janis

Reply via email to