Skip to content

Commit 934ece4

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 35d97bd commit 934ece4

File tree

2 files changed

+95
-26
lines changed

2 files changed

+95
-26
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 & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,77 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
20822082
write_check.f90
20832083
zero_sized_1.f90
20842084

2085+
# ---------------------------------------------------------------------------
2086+
#
2087+
# These tests are expected to fail at runtime, but pass instead.
2088+
#
2089+
allocate_error_1.f90
2090+
bounds_check_7.f90
2091+
bounds_check_10.f90
2092+
all_bounds_1.f90
2093+
bounds_check_12.f90
2094+
bounds_check_array_ctor_1.f90
2095+
bounds_check_array_ctor_2.f90
2096+
bounds_check_array_ctor_4.f90
2097+
bounds_check_array_ctor_6.f90
2098+
bounds_check_array_ctor_7.f90
2099+
bounds_check_array_ctor_8.f90
2100+
bounds_check_fail_3.f90
2101+
bounds_check_fail_4.f90
2102+
bounds_check_strlen_1.f90
2103+
bounds_check_strlen_2.f90
2104+
bounds_check_strlen_3.f90
2105+
bounds_check_strlen_4.f90
2106+
bounds_check_strlen_5.f90
2107+
bounds_check_strlen_7.f90
2108+
char_bounds_check_fail_1.f90
2109+
char_pointer_assign_4.f90
2110+
char_pointer_assign_5.f90
2111+
cshift_bounds_2.f90
2112+
deallocate_error_1.f90
2113+
deallocate_error_2.f90
2114+
do_check_2.f90
2115+
do_check_3.f90
2116+
do_check_4.f90
2117+
do_check_11.f90
2118+
do_check_12.f90
2119+
endfile_4.f90
2120+
fmt_g0_2.f08
2121+
inline_sum_bounds_check_1.f90
2122+
inline_sum_bounds_check_2.f90
2123+
io_real_boz2.f90
2124+
io_real_boz_4.f90
2125+
io_real_boz_5.f90
2126+
matmul_bounds_2.f90
2127+
matmul_bounds_3.f90
2128+
matmul_bounds_4.f90
2129+
matmul_bounds_5.f90
2130+
matmul_bounds_8.f90
2131+
matmul_bounds_10.f90
2132+
maxloc_bounds_1.f90
2133+
maxloc_bounds_2.f90
2134+
maxloc_bounds_3.f90
2135+
maxloc_bounds_4.f90
2136+
maxloc_bounds_5.f90
2137+
maxloc_bounds_7.f90
2138+
maxloc_bounds_8.f90
2139+
merge_char_3.f90
2140+
no_unit_error_1.f90
2141+
pack_bounds_1.f90
2142+
pointer_check_10.f90
2143+
pointer_remapping_6.f08
2144+
pr96436_6.f90
2145+
pr96436_7.f90
2146+
pr96436_8.f90
2147+
pr96436_9.f90
2148+
pr96436_10.f90
2149+
recursive_check_9.f90
2150+
recursive_check_11.f90
2151+
recursive_check_13.f90
2152+
spread_bounds_1.f90
2153+
transpose_2.f90
2154+
unpack_bounds_1.f90
2155+
20852156
# ---------------------------------------------------------------------------
20862157
#
20872158
# This test fails with optimizations enabled, but succeeds when compiled
@@ -2689,28 +2760,6 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
26892760
openacc-define-3.f90
26902761
openmp-define-3.f90
26912762

2692-
# Tests looking for runtime errors (e.g., bound checks). Correctly
2693-
# caught by flang runtime when it is used for array assignments.
2694-
allocate_error_6.f90
2695-
allocate_with_source_22.f03
2696-
allocate_with_source_23.f03
2697-
all_bounds_1.f90
2698-
associate_32.f03
2699-
bounds_check_12.f90
2700-
bounds_check_array_ctor_4.f90
2701-
bounds_check_fail_3.f90
2702-
inline_matmul_1.f90
2703-
maxloc_bounds_1.f90
2704-
maxloc_bounds_2.f90
2705-
maxloc_bounds_3.f90
2706-
maxloc_bounds_4.f90
2707-
maxloc_bounds_5.f90
2708-
maxloc_bounds_7.f90
2709-
maxloc_bounds_8.f90
2710-
pack_bounds_1.f90
2711-
ptr_func_assign_1.f08
2712-
spread_bounds_1.f90
2713-
27142763
# Bad test, assigning an 11 elements array to a 12 elements array.
27152764
transfer_array_intrinsic_4.f90
27162765

0 commit comments

Comments
 (0)