Commit Graph

1059 Commits

Author SHA1 Message Date
David Tenty 2edc54eded [lit][AIX] Add LIBPATH to pass through env vars
AIX uses LIBPATH to specify the library search path in addition to
LD_LIBRARY_PATH, and a lot of users / tooling will use it
preferentially. In lit we currently pass through LD_LIBRARY_PATH but not
LIBPATH in the env on AIX, this patch corrects this inconsistency.

Differential Revision: https://reviews.llvm.org/D138510
2022-11-22 17:22:52 -05:00
Paul Robinson 56470b72f1 [lit] Add `target=<triple>` as a feature keyword
As proposed first in D107162 and later in discourse at
https://discourse.llvm.org/t/rfc-lits-requires-and-triples/66041

Modified a couple of lit's own tests to use this; left others as-is,
because for now triple substrings still work in UNSUPPORTED/XFAIL.

Differential Revision: https://reviews.llvm.org/D137434
2022-11-16 05:50:45 -08:00
Martin Storsjö b95f54350c [lit] [Windows] Print exit codes > 255 as hex too
891bb4872c made negative exit codes
be printed as hex, which makes it easier to recognize e.g.
0xC0000005 instead of -1073741819. However, current Python versions
(at least the ones I'm using) seem to end up with positive unsigned
return codes, so that again ends up printed as 3221225477.

Print any return code over 255 as a hexadecimal number instead.

Differential Revision: https://reviews.llvm.org/D137771
2022-11-15 12:09:32 +02:00
Michał Górny 7b4b15042d [lit] Add pyproject.toml and fix build w/ modern setuptools backend
Add a `pyproject.toml` file that provides build system information
for PEP 517-compliant builders.  While all the commonly used builders
provide fallback to running `setup.py` for backwards compatibility, this
ensures the best forward compatibility.  It also provides a reliable way
of specifying the minimum required setuptools version.  Effectively, it
will make it possible to remove `setup.py` in favor of purely
declarative configuration in the future, or even switch to a different
build system.

Update `setup.py` to explicitly add the current directory to `sys.path`
for importing `lit`.  This is necessary, as the modern setuptools
backend does not guarantee that the current directory is present there.

Differential Revision: https://reviews.llvm.org/D136976
2022-11-01 07:30:14 +01:00
Yuanfang Chen 500876226c [lit][NFC] not check stdout in googletest-timeout.py
This is flicky for buildbots (for example, https://lab.llvm.org/buildbot/#/builders/188/builds/21560)
because of the short timeout. The test coverage is not reduced because
the stdout check is performed in other googtest-* unit tests.
2022-10-30 23:17:50 -07:00
Michał Górny b1a6c6cfaf [lit] Deduplicate README and longdescription, and update it
Since long_description is effectively the README that's displayed
on pypi project page, combine it with the existing README file and read
the file in `setup.py`.  This is a common practice among Python
projects, to the point of declarative-style setuptools configurations
providing a shorthand for it.

While at it, update the outdated information about LLVM Bugzilla for use
of GitHub issues.

Differential Revision: https://reviews.llvm.org/D137006
2022-10-29 13:27:00 +02:00
gbreynoo 33601f4255 [llvm-lit][test] Fix regex to capture scientific notation
We were seeing an intermittent local test failure of
utils\lit\tests\test-output.py in which the elapsed time output was
being given in scientific notation. Python automatically represents
small floating-point values in scientific notation so I have altered
these tests regex to capture output in that format.

Differential Revision: https://reviews.llvm.org/D136469
2022-10-25 16:05:35 +01:00
Yuanfang Chen 63512592e9 [lit] fix a error when using --show-used-features
The error is
```
NotADirectoryError: [Errno 20] Not a directory: '<build-dir>/unittests/Analysis/./AnalysisTests/0/40'
```

Exclude unittests when collecting features because
unittests don't make use of feature keywords.
2022-10-19 10:57:01 -07:00
Aaron Ballman 19e984ef8f Properly print unnamed TagDecl objects in diagnostics
The diagnostics engine is very smart about being passed a NamedDecl to
print as part of a diagnostic; it gets the "right" form of the name,
quotes it properly, etc. However, the result of using an unnamed tag
declaration was to print '' instead of anything useful.

This patch causes us to print the same information we'd have gotten if
we had printed the type of the declaration rather than the name of it,
as that's the most relevant information we can display.

Differential Revision: https://reviews.llvm.org/D134813
2022-10-14 08:18:28 -04:00
Nikita Popov bc839b4b4e [Bindings] Remove go bindings
Remove the unmaintained Go bindings per
https://discourse.llvm.org/t/rfc-remove-the-go-bindings/65725.

The tinygo project provides maintained Go bindings at
https://github.com/tinygo-org/go-llvm.

Differential Revision: https://reviews.llvm.org/D135436
2022-10-10 10:14:17 +02:00
Michał Górny a64ea173d7 [llvm] [lit] Fix use_lld() to respect llvm_shlib_dir
Fix the use_lld() to use llvm_shlib_dir similarly to how use_clang()
does it.  This fixes use_lld() wrongly prepending llvm_libs_dir,
i.e. the directory with system-installed LLVM libraries before
the build directory of standalone build.  As a result, the shared
libraries from an earlier version of clang end up being used instead of
the newly built version when running the test suite prior to installing.

To reproduce the problem, build and install LLVM with dylibs first,
e.g.:

    cmake ../llvm -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel \
      -DCMAKE_INSTALL_PREFIX="${HOME}"/llvm-test \
      -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON \
      -DLLVM_INSTALL_UTILS=ON
    ninja install

Then build clang against that installation and run tests:

    export LD_LIBRARY_PATH=~/llvm-test/lib
    export PATh=~/llvm-test/bin:"${PATH}"
    cmake ../clang -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel \
      -DCMAKE_INSTALL_PREFIX="${HOME}"/llvm-test \
      -DCLANG_LINK_CLANG_DYLIB=ON -DLLVM_BUILD_TESTS=ON \
      -DLLVM_EXTERNAL_LIT="${PWD}"/bin/llvm-lit
    ninja check-clang

The tests will be run with LD_LIBRARY_PATH of:

    /home/${USER}/llvm-test/lib:/home/${USER}/llvm-project/build-clang/lib

As a result, installed libclang-cpp will take precedence over the one
from build dir.  With the patch, the correct path is used, i.e.:

    /home/${USER}/llvm-project/build-clang/lib:/home/${USER}/llvm-test/lib

Differential Revision: https://reviews.llvm.org/D135368
2022-10-07 07:14:48 +02:00
Michał Górny 74085ebfb6 [llvm] [lit] Move %clang_dxc substitution from clang/test
Move the `%clang_dxc` substitution from local definition in clang/test
to lit's `llvm/config.py` module where all other driver definitions
are found.  This improves consistency and makes it easier to control
global clang options.

Differential Revision: https://reviews.llvm.org/D134871
2022-09-29 20:59:00 +02:00
Yuanfang Chen 5850b995ef [lit] follow-up 2380c1b609, check stdout and stderr separately
The error output is cached so it could be out of order with stdout in
some bots.
2022-09-22 16:42:47 -07:00
Yuanfang Chen 2380c1b609 [lit][unit] avoid adding gtest binary more than once
Due to CMake mis-configurations, some gtest binaries may be added to the test
list more than once. This patch makes lit avoid such cases and issues a
warning when it happens.
2022-09-22 16:14:50 -07:00
Joel E. Denny 88f183c0db [lit] Work around another windows issue in new test from 28412d1800
Based on result shown at:

<https://lab.llvm.org/buildbot/#/builders/216/builds/10123>
2022-09-21 14:08:10 -04:00
Joel E. Denny b9735db646 [lit] Work around windows issue in new test from 28412d1800
Based on result shown at:

<https://lab.llvm.org/buildbot/#/builders/216/builds/10120>
2022-09-21 13:27:41 -04:00
Joel E. Denny 387924b307 [lit] Increase FileCheck verbosity temporarily
This is to help debug the failure 28412d1800 caused and f47a5df92d
failed to fix at:

<https://lab.llvm.org/buildbot/#/builders/216/builds/10117>
2022-09-21 12:27:45 -04:00
Joel E. Denny f47a5df92d [lit] Try to fix new test from 28412d1800 under Windows
`llvm/utils/lit/tests/Inputs/shtest-define/value-escaped.txt` broke at
least at <https://lab.llvm.org/buildbot/#/builders/216/builds/10114>.

The problem appears to be a non-portable `echo` command line.
2022-09-21 12:06:41 -04:00
Joel E. Denny 28412d1800 [lit] Implement DEFINE and REDEFINE directives
These directives define per-test lit substitutions.  The concept was
discussed at
<https://discourse.llvm.org/t/iterating-lit-run-lines/62596/10>.

For example, the following directives can be inserted into a test file
to define `%{cflags}` and `%{fcflags}` substitutions with empty
initial values, which serve as the parameters of another newly defined
`%{check}` substitution:

```
// DEFINE: %{cflags} =
// DEFINE: %{fcflags} =

// DEFINE: %{check} = %clang_cc1 %{cflags} -emit-llvm -o - %s | \
// DEFINE:            FileCheck %{fcflags} %s
```

The following directives then redefine the parameters before each use
of `%{check}`:

```
// REDEFINE: %{cflags} = -foo
// REDEFINE: %{fcflags} = -check-prefix=FOO
// RUN: %{check}

// REDEFINE: %{cflags} = -bar
// REDEFINE: %{fcflags} = -check-prefix=BAR
// RUN: %{check}
```

Of course, `%{check}` would typically be more elaborate, increasing
the benefit of the reuse.

One issue is that the strings `DEFINE:` and `REDEFINE:` already appear
in 5 tests.  This patch adjusts those tests not to use those strings.
Our prediction is that, in the vast majority of cases, if a test
author mistakenly uses one of those strings for another purpose, the
text appearing after the string will not happen to have the syntax
required for these directives.  Thus, the test author will discover
the mistake immediately when lit reports the syntax error.

This patch also expands the documentation on existing lit substitution
behavior.

Reviewed By: jhenderson, MaskRay, awarzynski

Differential Revision: https://reviews.llvm.org/D132513
2022-09-21 11:32:05 -04:00
Ben Langmuir 4a72459ed6 Revert "[clang][test] Disallow using the default module cache path in lit tests"
This reverts commit d96f526196.

Some systems do not support `env -u`.
2022-09-12 13:10:22 -07:00
Ben Langmuir d96f526196 [clang][test] Disallow using the default module cache path in lit tests
Make the default module cache path invalid when running lit tests so
that tests are forced to provide a cache path. This avoids accidentally
escaping to the system default location, and would have caught the
failure recently found in ClangScanDeps/multiple-commands.c.

Differential Revision: https://reviews.llvm.org/D133622
2022-09-12 09:54:56 -07:00
Joe Loser 27731f0475 [llvm][lit] Respect GTEST_TOTAL_SHARDS and GTEST_SHARD_INDEX env vars
There are a variety of issues with using GTest sharding by default for users of
`lit` using the Google Test formatter as mentioned in
https://github.com/llvm/llvm-project/issues/56492 and
https://github.com/llvm/llvm-project/issues/56491.

Currently, there is no way for users to explicitly control the sharding
behavior, even with the environment variables that GTest provides. This patch
teaches the `googletest` formatter to actually respect `GTEST_TOTAL_SHARDS`
and `GTEST_SHARD_INDEX` environment variables if they are set.

In practice, we could go one step further and not do any of the post-processing
of the JSON files if `GTEST_TOTAL_SHARDS` is `1` for example, but that it left
as a follow-up if desired.  There may be preferred alternative approaches to
disabling sharding entirely through another mechanism, such as a lit config
variable.

Differential Revision: https://reviews.llvm.org/D133542
2022-09-09 17:47:21 -06:00
Christian Sigg 1dbcb79498 [lit] Test changes to make it work with bazel
These non-functional changes will make it easier to add the lit tests to the bazel build (see utils/bazel).

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D133416
2022-09-08 14:52:08 +02:00
Fangrui Song b6e1fd761d [llvm-objcopy] Support --{,de}compress-debug-sections for zstd
Also, add ELFCOMPRESS_ZSTD (2) from the approved generic-abi proposal:
https://groups.google.com/g/generic-abi/c/satyPkuMisk
("Add new ch_type value: ELFCOMPRESS_ZSTD")

Link: https://discourse.llvm.org/t/rfc-zstandard-as-a-second-compression-method-to-llvm/63399
("[RFC] Zstandard as a second compression method to LLVM")

Reviewed By: jhenderson, dblaikie

Differential Revision: https://reviews.llvm.org/D130458
2022-09-08 00:59:14 -07:00
Nikita Popov 0444b40ed3 Revert "[Support] Add llvm::compression::{getReasonIfUnsupported,compress,decompress}"
This reverts commit 19dc3cff0f.
This reverts commit 5b19a1f8e8.
This reverts commit 9397648ac8.
This reverts commit 10842b4475.

Breaks the GCC build, as reported here:
https://reviews.llvm.org/D130506#3776415
2022-09-08 09:33:12 +02:00
Fangrui Song 5b19a1f8e8 [llvm-objcopy] Support --{,de}compress-debug-sections for zstd
Also, add ELFCOMPRESS_ZSTD (2) from the approved generic-abi proposal:
https://groups.google.com/g/generic-abi/c/satyPkuMisk
("Add new ch_type value: ELFCOMPRESS_ZSTD")

Link: https://discourse.llvm.org/t/rfc-zstandard-as-a-second-compression-method-to-llvm/63399
("[RFC] Zstandard as a second compression method to LLVM")

Reviewed By: jhenderson, dblaikie

Differential Revision: https://reviews.llvm.org/D130458
2022-09-07 23:53:40 -07:00
Fangrui Song 83ea47acd7 [test] Make tests pass regardless of gnu++14/gnu++17 default
GCC from 11 onwards defaults to -std=gnu++17 for C++ source files. We want to do the same
(https://discourse.llvm.org/t/c-objc-switch-to-gnu-17-as-the-default-dialect/64360).
Split RUN lines, adjust `-verify`, or add `__cplusplus < 201703L` or `-Wno-dynamic-exception-spec`,
so that tests will pass regardless of gnu++14/gnu++17 default.

We have a desire to mark a test compatible with multiple language standards.
There are ongoing discussions how to add markers in the long term:

* https://discourse.llvm.org/t/iterating-lit-run-lines/62596
* https://discourse.llvm.org/t/lit-run-a-run-line-multiple-times-with-different-replacements/64932

As a workaround in the short term, add lit substitutions `%std_cxx98-`,
`%std_cxx11-14`, etc. They can be used for tests which work across multiple
language standards. If a range has `n` standards, run lit multiple times, with
`LIT_CLANG_STD_GROUP=0`, `LIT_CLANG_STD_GROUP=1`, etc to cover all `n` standards.

Reviewed By: #clang-language-wg, aaron.ballman

Differential Revision: https://reviews.llvm.org/D131464
2022-09-04 05:29:32 +00:00
Petr Hosek b52820edec [lit] Support reading arguments from a file
This allows reading arguments from file using the response file syntax.
We would like to use this in the LLVM build to pass test suites from
subbuilds.

Differential Revision: https://reviews.llvm.org/D132437
2022-08-24 08:01:58 +00:00
Eli Friedman ab0574dac3 Print more information when JSON parsing fails for unittests.
Trying to figure out intermittent failure on reverse-iteration buildbot.
2022-08-23 14:57:49 -07:00
Vitaly Buka fae656b2dd [test] Add 'hwasan' feature and disable a test 2022-08-17 23:50:35 -07:00
Vitaly Buka 3f5f2905c4 [test] Propagate HWASAN_OPTIONS 2022-08-17 18:59:49 -07:00
Fangrui Song ce6dd4e835 Revert D130458 "[llvm-objcopy] Support --{,de}compress-debug-sections for zstd"
This reverts commit c26dc2904b.

The new Zstd dispatch has an ongoing design discussion related to https://reviews.llvm.org/D130516#3688123 .
Revert for now before it is resolved.
2022-07-29 15:46:51 -07:00
Fangrui Song c26dc2904b [llvm-objcopy] Support --{,de}compress-debug-sections for zstd
Also, add ELFCOMPRESS_ZSTD (2) from the approved generic-abi proposal:
https://groups.google.com/g/generic-abi/c/satyPkuMisk
("Add new ch_type value: ELFCOMPRESS_ZSTD")

Link: https://discourse.llvm.org/t/rfc-zstandard-as-a-second-compression-method-to-llvm/63399
("[RFC] Zstandard as a second compression method to LLVM")

Differential Revision: https://reviews.llvm.org/D130458
2022-07-28 10:45:53 -07:00
David Green 7ce39d80a8 [Lit] Sort previously failed tests early
D98179 added a mechanism to sort tests by test time to run slow tests
early, increasing potential parallelism. It also added a feature where
negative tests would be marked as negative, allowing subsequent test
runs to run them earlier. Unfortunately it never actually stored the
negative time, even if all the other code seemed to be inplace to sort
them early. Luckily the fix seems simple.

Differential Revision: https://reviews.llvm.org/D130570
2022-07-27 17:55:11 +01:00
Tom Stellard 809855b56f Bump the trunk major version to 16 2022-07-26 21:34:45 -07:00
Ilya Leoshkevich 0d89963df3 [Lit] Pass through DFLTCC from the surrounding environment
Many distros ship zlib with the IBM Z deflate hardware acceleration
patch [1]. Sometimes it's desirable to disable the acceleration, for
example, for reproducibility. This can be done by exporting DFLTCC=0.
llvm-lit clears this environment variable, which causes
compress-debug-sections-zlib.test fail on z15 and later machines. Add
DFLTCC to the list of variables to keep.

[1] https://github.com/madler/zlib/pull/410

Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D130253
2022-07-23 01:38:30 +02:00
Yuanfang Chen e97b2d4138 [lit][unit] add a test for sanitizer-only test failures
Follow-up for 6b02c53936.
2022-07-15 18:36:38 -07:00
Yuanfang Chen ea7968bf76 [lit][test] explicitly use utf-8 encoding to write testing json file
Related test failure:
https://lab.llvm.org/buildbot/#/builders/178/builds/2527/steps/13/logs/FAIL__lit___googletest-timeout_py
2022-07-15 16:42:50 -07:00
Yuanfang Chen 6b02c53936 [lit][unit] make sure to include failed shard in test summary report
For sanitizer only failures, the tests all pass but still need to
put the shard in failed test summary.
2022-07-15 15:43:33 -07:00
Yuanfang Chen f32ccc2cca [lit] fix a bug in 4cd1c96d37
Only report failure for tests that actually runs.
2022-07-15 14:37:06 -07:00
Yuanfang Chen 4cd1c96d37 [reland][lit][unit] makes sure to print stderr when no test failures are found
In some situations, like running tests with sanitizers, all test
passes but the shard could still fail due to memory issues.

Relands 65769429c0
2022-07-15 13:26:30 -07:00
Yuanfang Chen 041bb94b9c Revert "[lit][unit] makes sure to print stderr when no test failures are found"
This reverts commit 65769429c0.

This patch is incomplete.
2022-07-15 13:26:30 -07:00
Yuanfang Chen 65769429c0 [lit][unit] makes sure to print stderr when no test failures are found
In some situations, like running tests with sanitizers, all test passes
but the shard could still fail due to memory issues.
2022-07-15 12:33:11 -07:00
Ben Langmuir 9044224575 [test] Fix macOS triple check
While the inferred host triple for macOS is something like
<arch>-apple-darwin, it's also valid to have <arch>-apple-macos.
Currently that globally changes whether an SDKROOT is provided in tests,
so make this check more portable.

Differential Revision: https://reviews.llvm.org/D129684
2022-07-13 13:36:16 -07:00
Yuanfang Chen 9d37895a71 [lit][test] relaxed GTEST_TOTAL_SHARDS checking for some googletests (2)
Missed this in 14d3021c10
2022-06-28 10:32:22 -07:00
Yuanfang Chen 14d3021c10 [lit][test] relaxed GTEST_TOTAL_SHARDS checking for some googletests
For machines with a small number of cores, GTEST_TOTAL_SHARDS may be
lower than 6.
2022-06-27 16:17:08 -07:00
Alex Brachet 98052b6463 Revert "[lit] Passthrough CLANG_MODULE_CACHE_PATH env var"
This reverts commit 6466c9abf3.
2022-06-12 03:01:08 +00:00
Alex Brachet 6466c9abf3 [lit] Passthrough CLANG_MODULE_CACHE_PATH env var
This environment variable can be set to control module
caching. It disables caching by setting the variable
empty. As such, it needs to be handled differently
from other environment variables here which are
assumed to not be empty.
2022-06-11 21:04:02 +00:00
Vitaly Buka d33c36235d [lit] Fix setup of sanitizer environment
Not all options were propageted into tests.

Reviewed By: ychen

Differential Revision: https://reviews.llvm.org/D122869
2022-05-19 19:24:16 -07:00
Sam McCall 1236b66a98 [lit] pass LLVM_SYMBOLIZER_PATH through to tests.
Currently several buildbots give unsymbolized traces on crash.
I suspect these are configuring the symbolizer in this way and regressed in
D122251 or thereabouts.

Trying this coupled with a reland of patch that failed on a couple of bots with
no useful stacktrace...
2022-05-18 15:30:37 +02:00