Skip to content

Commit 75a8e07

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 fd7aca4 commit 75a8e07

File tree

2 files changed

+95
-20
lines changed

2 files changed

+95
-20
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 & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,77 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
23322332
write_check.f90
23332333
zero_sized_1.f90
23342334

2335+
# ---------------------------------------------------------------------------
2336+
#
2337+
# These tests are expected to fail at runtime, but pass instead.
2338+
#
2339+
allocate_error_1.f90
2340+
bounds_check_7.f90
2341+
bounds_check_10.f90
2342+
all_bounds_1.f90
2343+
bounds_check_12.f90
2344+
bounds_check_array_ctor_1.f90
2345+
bounds_check_array_ctor_2.f90
2346+
bounds_check_array_ctor_4.f90
2347+
bounds_check_array_ctor_6.f90
2348+
bounds_check_array_ctor_7.f90
2349+
bounds_check_array_ctor_8.f90
2350+
bounds_check_fail_3.f90
2351+
bounds_check_fail_4.f90
2352+
bounds_check_strlen_1.f90
2353+
bounds_check_strlen_2.f90
2354+
bounds_check_strlen_3.f90
2355+
bounds_check_strlen_4.f90
2356+
bounds_check_strlen_5.f90
2357+
bounds_check_strlen_7.f90
2358+
char_bounds_check_fail_1.f90
2359+
char_pointer_assign_4.f90
2360+
char_pointer_assign_5.f90
2361+
cshift_bounds_2.f90
2362+
deallocate_error_1.f90
2363+
deallocate_error_2.f90
2364+
do_check_2.f90
2365+
do_check_3.f90
2366+
do_check_4.f90
2367+
do_check_11.f90
2368+
do_check_12.f90
2369+
endfile_4.f90
2370+
fmt_g0_2.f08
2371+
inline_sum_bounds_check_1.f90
2372+
inline_sum_bounds_check_2.f90
2373+
io_real_boz2.f90
2374+
io_real_boz_4.f90
2375+
io_real_boz_5.f90
2376+
matmul_bounds_2.f90
2377+
matmul_bounds_3.f90
2378+
matmul_bounds_4.f90
2379+
matmul_bounds_5.f90
2380+
matmul_bounds_8.f90
2381+
matmul_bounds_10.f90
2382+
maxloc_bounds_1.f90
2383+
maxloc_bounds_2.f90
2384+
maxloc_bounds_3.f90
2385+
maxloc_bounds_4.f90
2386+
maxloc_bounds_5.f90
2387+
maxloc_bounds_7.f90
2388+
maxloc_bounds_8.f90
2389+
merge_char_3.f90
2390+
no_unit_error_1.f90
2391+
pack_bounds_1.f90
2392+
pointer_check_10.f90
2393+
pointer_remapping_6.f08
2394+
pr96436_6.f90
2395+
pr96436_7.f90
2396+
pr96436_8.f90
2397+
pr96436_9.f90
2398+
pr96436_10.f90
2399+
recursive_check_9.f90
2400+
recursive_check_11.f90
2401+
recursive_check_13.f90
2402+
spread_bounds_1.f90
2403+
transpose_2.f90
2404+
unpack_bounds_1.f90
2405+
23352406
# ---------------------------------------------------------------------------
23362407
#
23372408
# This test fails with optimizations enabled, but succeeds when compiled
@@ -2941,22 +3012,6 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
29413012
openacc-define-3.f90
29423013
openmp-define-3.f90
29433014

2944-
# Tests looking for runtime errors (e.g., bound checks). Correctly
2945-
# caught by flang runtime when it is used for array assignments.
2946-
all_bounds_1.f90
2947-
bounds_check_12.f90
2948-
bounds_check_array_ctor_4.f90
2949-
bounds_check_fail_3.f90
2950-
maxloc_bounds_1.f90
2951-
maxloc_bounds_2.f90
2952-
maxloc_bounds_3.f90
2953-
maxloc_bounds_4.f90
2954-
maxloc_bounds_5.f90
2955-
maxloc_bounds_7.f90
2956-
maxloc_bounds_8.f90
2957-
pack_bounds_1.f90
2958-
spread_bounds_1.f90
2959-
29603015
# Bad test, assigning an 11 elements array to a 12 elements array.
29613016
transfer_array_intrinsic_4.f90
29623017

0 commit comments

Comments
 (0)