Skip to content

Commit feac944

Browse files
committed
[Fortran/gfortran] Correctly handle "shouldfail" tests
Correctly handle the DejaGNU shouldfail annotation which asserts that the test is expected to fail at runtime. Disable tests that now fail. These may be actual bugs in the runtime or a case of flang behaving differently from gfortran and will need to be investigated.
1 parent 9ca97f5 commit feac944

File tree

2 files changed

+95
-31
lines changed

2 files changed

+95
-31
lines changed

Fortran/gfortran/CMakeLists.txt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,9 @@ endfunction()
530530
# Setup an "execute" test. In the case of multi-file tests, MAIN will be the
531531
# main file. For multi-file tests, OTHERS will be the remaining files needed by
532532
# the test. FFLAGS are additional compiler flags needed by the test. LDFLAGS
533-
# are the other linker flags needed by the test.
534-
function(gfortran_add_execute_test main others fflags ldflags)
533+
# are the other linker flags needed by the test. If EXPECT_ERROR evaluates to
534+
# true, the test is expected to fail.
535+
function(gfortran_add_execute_test expect_error main others fflags ldflags)
535536
# PREFIX_EXECUTE will have been defined in the subdirectory from which this
536537
# function is called.
537538
gfortran_unique_target_name("${PREFIX_EXECUTE}" "${main}" target)
@@ -540,6 +541,20 @@ function(gfortran_add_execute_test main others fflags ldflags)
540541

541542
llvm_test_executable_no_test(${target} ${main} ${others})
542543
llvm_test_run(WORKDIR "%S/${working_dir_name}")
544+
# FIXME: All we need is to negate the exit code. LLVM's not utility can do
545+
# this, but if it is not already installed on the system, it will have to be
546+
# obtained from LLVM's build directory. It is not clear that we can rely on
547+
# this when running the test suite.
548+
if (WIN32)
549+
# Probably need to check %errorlevel% here.
550+
message(FATAL_ERROR "Verification not implemented on Windows.")
551+
else ()
552+
if (expect_error)
553+
llvm_test_verify(${TESTCMD} $? -ne 0)
554+
else ()
555+
llvm_test_verify(${TESTCMD} $? -eq 0)
556+
endif ()
557+
endif ()
543558
llvm_add_test_for_target(${target})
544559

545560
target_include_directories(${target}
@@ -576,6 +591,9 @@ function(gfortran_add_execute_tests_from tests)
576591
cmake_parse_arguments(GFORTRAN "" "" "FFLAGS;LDFLAGS" ${ARGN})
577592

578593
foreach(file ${tests})
594+
# Whether this test is expected to pass or fail.
595+
set(expect_error OFF)
596+
579597
# The file containing the "run" directive will be the main file.
580598
set(main "")
581599

@@ -611,13 +629,15 @@ function(gfortran_add_execute_tests_from tests)
611629
separate_arguments(file_fflags UNIX_COMMAND ${CMAKE_MATCH_2})
612630
list(REMOVE_ITEM file_fflags ${FLANG_ERRORING_FFLAGS})
613631
list(APPEND fflags ${file_fflags})
632+
elseif (line MATCHES "[{][ ]*dg-shouldfail[ ]+(.*)[}]")
633+
set(expect_error ON)
614634
endif()
615635
endforeach()
616636

617637
# Since any dependent files could also be processed by this function, there
618638
# is no guarantee that main will have been set.
619639
if (main)
620-
gfortran_add_execute_test(${main} "${others}" "${fflags}" "${ldflags}")
640+
gfortran_add_execute_test(${expect_error} ${main} "${others}" "${fflags}" "${ldflags}")
621641
endif()
622642
endforeach()
623643
endfunction()
@@ -632,7 +652,7 @@ function(gfortran_add_execute_tests tests)
632652
list(APPEND ldflags ${GFORTRAN_LDFLAGS})
633653

634654
foreach(file ${tests})
635-
gfortran_add_execute_test(${file} "" "${fflags}" "${ldflags}")
655+
gfortran_add_execute_test(OFF ${file} "" "${fflags}" "${ldflags}")
636656
endforeach()
637657
endfunction()
638658

Fortran/gfortran/regression/DisabledFiles.cmake

Lines changed: 71 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,77 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
19911991
write_check.f90
19921992
zero_sized_1.f90
19931993

1994+
# ---------------------------------------------------------------------------
1995+
#
1996+
# These tests are expected to fail at runtime, but pass instead.
1997+
#
1998+
allocate_error_1.f90
1999+
bounds_check_7.f90
2000+
bounds_check_10.f90
2001+
all_bounds_1.f90
2002+
bounds_check_12.f90
2003+
bounds_check_array_ctor_1.f90
2004+
bounds_check_array_ctor_2.f90
2005+
bounds_check_array_ctor_4.f90
2006+
bounds_check_array_ctor_6.f90
2007+
bounds_check_array_ctor_7.f90
2008+
bounds_check_array_ctor_8.f90
2009+
bounds_check_fail_3.f90
2010+
bounds_check_fail_4.f90
2011+
bounds_check_strlen_1.f90
2012+
bounds_check_strlen_2.f90
2013+
bounds_check_strlen_3.f90
2014+
bounds_check_strlen_4.f90
2015+
bounds_check_strlen_5.f90
2016+
bounds_check_strlen_7.f90
2017+
char_bounds_check_fail_1.f90
2018+
char_pointer_assign_4.f90
2019+
char_pointer_assign_5.f90
2020+
cshift_bounds_2.f90
2021+
deallocate_error_1.f90
2022+
deallocate_error_2.f90
2023+
do_check_2.f90
2024+
do_check_3.f90
2025+
do_check_4.f90
2026+
do_check_11.f90
2027+
do_check_12.f90
2028+
endfile_4.f90
2029+
fmt_g0_2.f08
2030+
inline_sum_bounds_check_1.f90
2031+
inline_sum_bounds_check_2.f90
2032+
io_real_boz2.f90
2033+
io_real_boz_4.f90
2034+
io_real_boz_5.f90
2035+
matmul_bounds_2.f90
2036+
matmul_bounds_3.f90
2037+
matmul_bounds_4.f90
2038+
matmul_bounds_5.f90
2039+
matmul_bounds_8.f90
2040+
matmul_bounds_10.f90
2041+
maxloc_bounds_1.f90
2042+
maxloc_bounds_2.f90
2043+
maxloc_bounds_3.f90
2044+
maxloc_bounds_4.f90
2045+
maxloc_bounds_5.f90
2046+
maxloc_bounds_7.f90
2047+
maxloc_bounds_8.f90
2048+
merge_char_3.f90
2049+
no_unit_error_1.f90
2050+
pack_bounds_1.f90
2051+
pointer_check_10.f90
2052+
pointer_remapping_6.f08
2053+
pr96436_6.f90
2054+
pr96436_7.f90
2055+
pr96436_8.f90
2056+
pr96436_9.f90
2057+
pr96436_10.f90
2058+
recursive_check_9.f90
2059+
recursive_check_11.f90
2060+
recursive_check_13.f90
2061+
spread_bounds_1.f90
2062+
transpose_2.f90
2063+
unpack_bounds_1.f90
2064+
19942065
# ---------------------------------------------------------------------------
19952066
#
19962067
# This test fails with optimizations enabled, but succeeds when compiled
@@ -2601,33 +2672,6 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
26012672
openacc-define-3.f90
26022673
openmp-define-3.f90
26032674

2604-
# Tests looking for runtime errors (e.g., bound checks). Correctly
2605-
# caught by flang runtime.
2606-
allocate_error_6.f90
2607-
allocate_with_source_22.f03
2608-
allocate_with_source_23.f03
2609-
all_bounds_1.f90
2610-
associate_32.f03
2611-
bounds_check_12.f90
2612-
bounds_check_array_ctor_4.f90
2613-
bounds_check_fail_3.f90
2614-
cshift_bounds_3.f90
2615-
cshift_bounds_4.f90
2616-
dim_sum_1.f90
2617-
dim_sum_2.f90
2618-
dim_sum_3.f90
2619-
inline_matmul_1.f90
2620-
maxloc_bounds_1.f90
2621-
maxloc_bounds_2.f90
2622-
maxloc_bounds_3.f90
2623-
maxloc_bounds_4.f90
2624-
maxloc_bounds_5.f90
2625-
maxloc_bounds_7.f90
2626-
maxloc_bounds_8.f90
2627-
pack_bounds_1.f90
2628-
ptr_func_assign_1.f08
2629-
spread_bounds_1.f90
2630-
26312675
# Bad test, assigning an 11 elements array to a 12 elements array.
26322676
transfer_array_intrinsic_4.f90
26332677

0 commit comments

Comments
 (0)