diff --git a/Fortran/README.md b/Fortran/README.md new file mode 100644 index 000000000000..4f868cfc778c --- /dev/null +++ b/Fortran/README.md @@ -0,0 +1,58 @@ +# Fortran Tests + +This directory contains test suites such as those of +[gfortran](https://github.com/llvm/llvm-test-suite/tree/main/Fortran/gfortran) +and [NIST](https://github.com/llvm/llvm-test-suite/tree/main/Fortran/UnitTests/fcvs21_f95), +end-to-end tests of functions with runtime support as well as some proxy +applications such as +[SNAP](https://github.com/llvm/llvm-test-suite/tree/main/Fortran/SNAP). +When the test suite is configured with `-DTEST_SUITE_SUBDIRS=Fortran`, in most +cases, all tests in this directory will be run. The exception is where certain +tests/test-suites are disabled on certain platforms. For instance, the gfortran +tests are not run on RISC-V. + +## Setting NO_STOP_MESSAGE in the environment + +By default, flang prints a stop message in certain circumstances, typically +when the `STOP` statement is executed. This breaks the NIST tests. Setting +`NO_STOP_MESSAGE=1` in the environment disables this behavior. If +`NO_STOP_MESSAGE` is not set in the environment when running the tests, it will +be set automatically. See +[Fortran/lit.local.cfg](https://github.com/llvm/llvm-test-suite/tree/main/Fortran/lit.local.cfg) +for details. + +If adding a subdirectory with tests that need to check the `STOP` message, +add a `lit.local.cfg` file in that subdirectory with code to unset the +variable. For instance, something like this + +```python +config["NO_STOP_MESSAGE"] = "" +``` + +## Building and running a specific test suite + +It is possible to configure the llvm-test-suite to run only a subset of the +tests here. This can be done by specifying an appropriate subdirectory of +`Fortran/`. For instance, to build and run only the gfortran tests, the add +the following when running cmake: + +``` +-DTEST_SUITE_SUBDIRS=Fortran/gfortran +``` + +Keep in mind that when doing so the `lit.local.cfg` files from any parent +directories will not be processed. This may result in test failures if the tests +expect certain configuration options to have been set, and those are only set +in the `lit.local.cfg` file in a parent directory. + +This case can be seen when one attempts to run only the NIST tests by setting +`-DTEST_SUITE_SUBDIRS=Fortran/UnitTests/fcvs21_f95`. Since +[Fortran/lit.local.cfg](https://github.com/llvm/llvm-test-suite/tree/main/Fortran/lit.local.cfg) +will not be processed in this case, `NO_STOP_MESSAGE=1` will not be added to +the environment automatically and several tests will fail. In this case, +`NO_STOP_MESSAGE=1` must be set explicitly when running the tests. One way of +doing this is shown below. + +```shell +NO_STOP_MESSAGE=1 /path/to/llvm-lit -s . +``` diff --git a/Fortran/Readme.txt b/Fortran/Readme.txt deleted file mode 100644 index 33488b29e4f1..000000000000 --- a/Fortran/Readme.txt +++ /dev/null @@ -1,5 +0,0 @@ -By default LLVM flang prints a stop message in certain circumstances that -breaks some of the tests in this directory. As such we add the environment -variable NO_STOP_MESSAGE=1 to disable this behaviour. If we wish to add tests -in future that need to check the stop message, those can be added in a -subdirectory with a lit.local.cfg that unsets this environment variable. diff --git a/Fortran/lit.local.cfg b/Fortran/lit.local.cfg index d5b11eccd07d..d6494e6c7ae5 100644 --- a/Fortran/lit.local.cfg +++ b/Fortran/lit.local.cfg @@ -1,4 +1,7 @@ # Flang uses NO_STOP_MESSAGE to control the output of the STOP statement. # We should set it for running the tests, otherwise they might choke on warnings -# about signaling INEXACT exceptions. -config.environment["NO_STOP_MESSAGE"] = "1" +# about signaling INEXACT exceptions. If NO_STOP_MESSAGE was set in the +# environment, that value will have been added to the config in +# llvm-test-suite/lit.cfg and should not be overridden. +if "NO_STOP_MESSAGE" not in config.environment: + config.environment["NO_STOP_MESSAGE"] = "1" diff --git a/lit.cfg b/lit.cfg index c8a8adffc464..c732981a2dcd 100644 --- a/lit.cfg +++ b/lit.cfg @@ -25,6 +25,8 @@ config.traditional_output = False config.single_source = False if "SSH_AUTH_SOCK" in os.environ: config.environment["SSH_AUTH_SOCK"] = os.environ["SSH_AUTH_SOCK"] +if "NO_STOP_MESSAGE" in os.environ: + config.environment["NO_STOP_MESSAGE"] = os.environ["NO_STOP_MESSAGE"] # Load previous test results so we can skip tests that did not change. previous_results_file = lit_config.params.get("previous", None)