This is an archive of the discontinued LLVM Phabricator instance.

[Fortran/gfortran] Enable "compile" tests from the gfortran torture test suite
ClosedPublic

Authored by tarunprabhu on Apr 24 2023, 8:07 PM.

Details

Summary

The gfortran testsuite consists of "compile" and "execute" tests. The former test the behavior of the compiler while the latter test the executable produced by the compiler. Most of the "compile" tests don't produce an executable that can be run at test-time.

This patch enables them by working around some of the expected behavior of this test suite.

The tests are compiled along with the rest of the tests at build-time. Some of the "compile" tests are expected to raise an error. To work around this, at build-time, the compiler is invoked through a wrapper script which saves any diagnostics emitted by the compiler and always returns success. If the compilation succeeded, any object files produced are deleted immediately.

At test-time, the diagnostics saved at build-time are compared against the expected output. .

In addition, since the test suite expects to be able to run an executable at test-time, a dummy executable that does nothing is generated at build-time which is invoked for all tests at run-time.

Diff Detail

Repository
rT test-suite

Event Timeline

tarunprabhu created this revision.Apr 24 2023, 8:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2023, 8:07 PM
tarunprabhu requested review of this revision.Apr 24 2023, 8:07 PM

Thanks @tarunprabhu for this patch. Is this only enabling the compile tests in the torture directory? Would we have to do something similar for compile tests in the regression/gomp directory for example.

tblah added a subscriber: tblah.Apr 26 2023, 6:05 AM

Thanks @tarunprabhu for this patch. Is this only enabling the compile tests in the torture directory? Would we have to do something similar for compile tests in the regression/gomp directory for example.

Yes. Enabling all the tests in the regression is what I intend to do next.

A major reason for just doing the "compile" torture tests first was to get feedback on the approach i.e. building the tests along with the "execute" tests, saving the compiler diagnostics (if any) and verifying those diagnostics at testing-time.

tarunprabhu added a project: Restricted Project.
tarunprabhu retitled this revision from Enable "compile" tests from the gfortran torture test suite to [Fortran/gfortran] Enable "compile" tests from the gfortran torture test suite.May 8 2023, 1:07 PM
tarunprabhu added reviewers: clementval, jeanPerier.
luporl added a subscriber: luporl.May 15 2023, 11:59 AM

Thanks @tarunprabhu for this patch and for your work on porting gfortran
test-suite to LLVM.

It would really be better if llvm-test-suite could be improved to support
compile tests in a clean way, to avoid the need of workarounds that make
compile tests look like execute tests.
But I am not familiar with llvm-test-suite. Do you have an idea of
how much effort would be required?

With that said and assuming the required effort would be high, your
patch LGTM and IMHO we can use it while llvm-test-suite support isn't
ready, as it enables us to run several more tests.

It would also be nice to update Fortran/gfortran/README.md, unless you
are planning to do it later, when more compile tests are supported.

Fortran/gfortran/compile-save-diags.cmake
13

s/wells/well/

40

The if and elseif can be merged. Something like:
if (ALWAYS_SAVE_DIAGS OR NOT "${RETVAR}" EQUAL "0")

Fortran/gfortran/torture/compile/CMakeLists.txt
13

s/compier/compiler/

97

Do you mean "only saved on failure"?

159–162

Is it expected that UnsupportedTests/UnimplementedTests/SkippedTests will receive entries when more compile tests are enabled?

Added a note in Fortran/gfortran README.md indicating that the compile tests have been enabled for the torture suite.

tarunprabhu marked 2 inline comments as done.May 18 2023, 7:20 AM

Thanks for the review, @luporl

But I am not familiar with llvm-test-suite. Do you have an idea of
how much effort would be required?

Yes, I agree that modifying the test suite would be a better idea in the long run. However, I, too, am not very familiar with the llvm-test-suite so I am not sure just how much work it would be. I wanted to just get something working for now so we have a larger suite of tests that the community can use.

I could look into the modifying the test-suite itself, but I would like to prioritize getting most of the gfortran test-suite working first.

It would also be nice to update Fortran/gfortran/README.md, unless you are planning to do it later, when more compile tests are supported.

Done.

Fortran/gfortran/torture/compile/CMakeLists.txt
159–162

Yes, it is possible if gfortran adds more tests to this list and if they exercise features that we don't support, for instance. The idea is for these tests to be periodically synced with gfortran so we can take advantage of any more tests that they add.

But I am not familiar with llvm-test-suite. Do you have an idea of
how much effort would be required?

Yes, I agree that modifying the test suite would be a better idea in the long run. However, I, too, am not very familiar with the llvm-test-suite so I am not sure just how much work it would be. I wanted to just get something working for now so we have a larger suite of tests that the community can use.

I could look into the modifying the test-suite itself, but I would like to prioritize getting most of the gfortran test-suite working first.

I'm ok with getting most of the gfortran test-suite working first.

What happened to Fortran/gfortran/compile-save-diags.cmake file? It seems it was deleted in the last diff.

Fortran/gfortran/torture/compile/CMakeLists.txt
159–162

Ok, it makes sense.

Ugh! Sorry, was in a hurry and didn't notice that one of the files was missing in the last update. This is the correct diff.

tblah added inline comments.May 23 2023, 8:00 AM
Fortran/gfortran/README.md
45–50

After this patch, compile tests are supported in torture.

Fixed README to indicate that the compile tests are enabled in torture.

tarunprabhu marked an inline comment as done.May 23 2023, 2:37 PM

LGTM, but it's better to wait for someone with more experience in this area to approve.

LG.

Just want to repeat the following I saw in the other patch.
I see two modules M1 and TEST that are repeated in torture/execute. One of the tests defining TEST is disabled so we might not be hitting the issue for this one but for M1 we might end up hitting the issue. Should we do something about the M1 tests?

$ grep -i 'module m1' llvm-test-suite/Fortran/gfortran/torture/execute/*
llvm-test-suite/Fortran/gfortran/torture/execute/function_module_1.f90:module M1
llvm-test-suite/Fortran/gfortran/torture/execute/module_init_1.f90:module m1

$ grep -i 'module test' llvm-test-suite/Fortran/gfortran/torture/execute/*
llvm-test-suite/Fortran/gfortran/torture/execute/pr32140.f90:MODULE TEST
llvm-test-suite/Fortran/gfortran/torture/execute/pr32604.f90:MODULE TEST
This revision is now accepted and ready to land.May 24 2023, 9:44 AM

LG.

Just want to repeat the following I saw in the other patch.
I see two modules M1 and TEST that are repeated in torture/execute. One of the tests defining TEST is disabled so we might not be hitting the issue for this one but for M1 we might end up hitting the issue. Should we do something about the M1 tests?

$ grep -i 'module m1' llvm-test-suite/Fortran/gfortran/torture/execute/*
llvm-test-suite/Fortran/gfortran/torture/execute/function_module_1.f90:module M1
llvm-test-suite/Fortran/gfortran/torture/execute/module_init_1.f90:module m1

$ grep -i 'module test' llvm-test-suite/Fortran/gfortran/torture/execute/*
llvm-test-suite/Fortran/gfortran/torture/execute/pr32140.f90:MODULE TEST
llvm-test-suite/Fortran/gfortran/torture/execute/pr32604.f90:MODULE TEST

Disabling one of the module M1 tests is a reasonable workaround for now.