Commit Graph

299 Commits

Author SHA1 Message Date
Louis Dionne a092e3833b [libc++] Remove the %{not} substitution
It has never been used, and it actually doesn't really work because it
assumes that the target supports Python. Instead, it's better to just
use `!` since we're running ShTests in system shells anyway.
2020-04-07 17:12:37 -04:00
Louis Dionne 3fefda6e57 [libc++] Run tests in a directory related to %t instead of /tmp
Instead of creating a temporary directory inside /tmp and running the
tests there, use a directory name based on LIT's %t substitution. This
has the benefit of not hitting /tmp so much (which is slow on some
filesystems). It also has the benefit that `ninja -C build clean` will
automatically remove the artifacts even if a test somehow failed to
remove its temporary directory (I've seen this happen when CTRL-C is
received).
2020-04-07 16:09:52 -04:00
Louis Dionne f8b6529218 [libc++] Translate MODULES_DEFINES annotations to ADDITIONAL_COMPILE_FLAGS
This allows both the old and the new testing formats to handle these
tests with modules enabled.

We also include the modules flags in the %{flags} substitution, which
means that .sh.cpp tests in the old format and all tests in the new
format will use modules flags when enabled.
2020-04-07 14:40:49 -04:00
Louis Dionne f75ebe1ab3 [libc++] Support .sh.s tests in the new format
libc++abi has two of these tests.
2020-04-07 09:13:21 -04:00
Louis Dionne 8a42bf24ae [lit] Move the recursiveExpansionLimit setting to TestingConfig
The LitConfig is shared across the whole test suite. However, since
enabling recursive expansion can be a breaking change for some test
suites, it's important to confine the setting to test suites that
enable it explicitly.

Note that other issues were raised with the way recursiveExpansionLimit
operates. However, this commit simply moves the setting to the right
place -- the mechanism by which it works can be improved independently.

Differential Revision: https://reviews.llvm.org/D77415
2020-04-06 13:58:00 -04:00
Louis Dionne 267273563d [libc++] Make sure we execute tests with the current environment
The new libc++ test format doesn't automatically do this (cause it
would be the wrong place to do it).
2020-04-06 13:38:11 -04:00
Louis Dionne 2c1c4777a5 [libc++] Always use -fsyntax-only in .fail.cpp tests
We had a workaround because GCC 5 does not evaluate static assertions
that are dependent on template parameters. This commit removes the
workaround and marks the corresponding tests as unsupported with GCC 5.
This has the benefit of bringing the new and the old test formats closer
without having to carry a workaround for an old compiler in the new
test format.
2020-04-06 11:38:45 -04:00
Louis Dionne 4e52944ef1 [libc++] Make sure we include %{flags} when building with the new format
Otherwise, we're missing some flags like the flags that are used by
sanitizer builds and the 32-bit builds. In the long term, I think it
would be better to have only %{compile_flags} and %{link_flags}, but
for the benefit of adopting the new format by default, I think it's OK
to add %{flags} to it.
2020-04-06 11:24:04 -04:00
Louis Dionne b00a874b7c [libc++] SSH: Fix tarring of dependencies on Windows
On Windows, we must make sure to close the temporary tar file before we
try to scp it.

This is an alternative approach to https://reviews.llvm.org/D77500.
2020-04-06 09:58:08 -04:00
Louis Dionne ceb58ad61d [libc++] Lit: Add default values for most arguments of test executors 2020-04-03 17:52:41 -04:00
Louis Dionne 80a2ddf65c [libc++] Add an alternative Lit test format
This new test format is simpler and more flexible. It creates Lit ShTests
on the fly that reuse existing substitutions (like %{cxx}) instead of
having complex logic in Python to run the tests. This has the benefit
that virtually no coding is required to customize how the test suite is
run -- one can achieve pretty much anything by defining the appropriate
substitutions in a simple lit.cfg file.

For example, in order to run the tests on an embedded device after
building with a specific SDK, one can set the %{cxx} and %{compile_flags}
substitutions to use that SDK, and the %{exec} substitution to the ssh.py
script currently used for .sh.cpp tests with a remote executor. Dealing with
the SSHExecutor becomes unnecessary, since all tests are treated like ShTests.

As a side effect of this design, configuration files for the test
suite can be as simple as:

	config.substitutions.append(('%{cxx}', '<path-to-compiler>'))
	config.substitutions.append(('%{compile_flags}', '<flags>'))
	config.substitutions.append(('%{link_flags}', '<flags>'))
	config.substitutions.append(('%{exec}', '<script-to-execute>'))

This should allow storing lit.cfg files for various configurations
directly in the repository instead of relying on complicated logic
in config.py to set up the right flags. I've found numerous problems
in that logic in the past years, and it seems like having simple and
explicit configuration files for the configurations we support is
going to solve most of these problems. Specifically, I am hoping to
store configuration files for testing other Standard Libraries in
the repository.

Improving the interaction with the test suite configuration is still a
work in progress, so for now this test format reuses the substitutions and
available features that are set up by the current config.py.

This new test format should support pretty much everything that the current
test format supports, however it will not be enabled by default at first to
make sure we're satisfied with it. For a short period of time, the new format
will require `--param=use_new_format=True` to be enabled, however it is a very
short term goal to replace the current testing format entirely and to simplify
the configuration accordingly.

Differential Revision: https://reviews.llvm.org/D77338
2020-04-03 11:35:27 -04:00
Louis Dionne 937040d181 [libc++] Add REQUIRES for tests that need -fblocks and -fobjc-arc
AppleClang seems to support these extensions by default, but other
compilers don't.
2020-04-03 10:10:35 -04:00
Louis Dionne ff09135fc2 [libc++] Execute tests from the Lit execution root instead of the test tree
Instead of executing tests from within the libc++ test suite, we execute
them from the Lit execution directory. However, since some tests have
file dependencies, we must copy those dependencies to the execution
directory where they are executed.

This has the major benefit that if a test modifies a file (whether it
is wanted or not), other tests will not see those modifications. This
is good because current tests assume that input data is never modified,
however this could be an incorrect assumption if some test does not
behave properly.
2020-04-01 22:17:03 -04:00
Louis Dionne 92e563bc05 [libc++] SSH: Create a tarball of dependencies and scp that instead
The benefit of doing this is that we can now handle directories that
contain symlinks and other arbitrary things, such as the static_test_env
required by filesystem tests.

As a fly-by fix, we also accumulate several commands to perform over SSH
and execute them at once instead of SSHing several times. This should be
faster on average.
2020-04-01 16:38:21 -04:00
Louis Dionne 160b01c9ef [libc++] SSH: Use -p when scp'ing to preserve modes and modification times 2020-04-01 12:32:23 -04:00
Louis Dionne 0489d39ead [libc++] SSH: Properly handle test-executables that are not the first argument
If a ShTest has for example another command in front of the test
executable it wants to execute, ssh.py needs to properly translate
the path of that test executable to the executable on the remote host.
For example, running '%{exec} ! %t.exe', we can't assume that the
test-executable is the first argument after '%{exec}'.
2020-04-01 11:44:39 -04:00
Louis Dionne 64acef386e [libc++] Handle SSH errors more gracefully and make sure we clean up the tmp directory 2020-04-01 11:00:39 -04:00
Sergej Jaskiewicz fee0026fc7 [libc++abi] Fix remote execution of .sh.cpp tests
This aims to fix test failures on the following buildbots:

- http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l
- http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64

Differential Revision: https://reviews.llvm.org/D77190
2020-04-01 10:09:07 -04:00
Louis Dionne 1c0dd57cd3 [libc++] Use 'export' instead of 'env' to run remote commands
This allows running commands that use shell builtins remotely too, when
'env' would complain that it can't find the program.
2020-03-31 17:11:28 -04:00
Louis Dionne 07e462526d [libc++] Allow running .sh.cpp tests with SSHExecutors
This commit adds a script that can be used as an %{exec} substitution
such that .sh.cpp tests can now run on remote hosts when using the
SSHExecutor.
2020-03-31 15:50:42 -04:00
Louis Dionne 89fe36d08a [libc++] Make sure substitutions are expanded inside FILE_DEPENDENCIES 2020-03-31 13:57:17 -04:00
Louis Dionne 34756a1c70 [libc++] Execute tests using an external shell
This makes it closer to how one would run the tests by hand, and it is
also closer to how the SSHExecutor runs the tests remotely. It also
allows using shell builtins in .sh.cpp tests when using %{exec}.
2020-03-31 11:31:39 -04:00
Louis Dionne fb47ffc618 [libc++] Provide a method for adding compiler flags in lit.local.cfg files
That way, local lit configuration files don't have to worry about
deep-copying the compiler instance of the test format, which is
arguably an implementation detail.

We pass the config to this method even though it is not used by the
current test format because this allows replacing the current test
format by other test formats that would require the config to add
new compile flags.
2020-03-31 09:29:18 -04:00
Louis Dionne d3a729ab24 [libc++] Set filesystem test flags in a lit.local.cfg
This reduces the complexity of our already complex global lit configuration,
and also avoids cluttering the compilation commands for all tests with
things that are only relevant to the filesystem tests.

Differential Revision: https://reviews.llvm.org/D76785
2020-03-31 09:29:02 -04:00
Louis Dionne 05bc588abb [libc++] Do not rely on the environment to run filesystem tests
Previously, filesystem tests would require LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT
to be present in the environment and to match the value provided when
compiling, as a macro. This has the problem that it only allows for the
filesystem tests to be run on the same machine they are created.

Instead, we create a temporary directory for each test. Technically,
this is tricky to do because we're relying on some of the code that
we're testing to do this. However, there's no other portable way of
creating temporary direcories in C++, so this is difficult to avoid.

Differential Revision: https://reviews.llvm.org/D76731
2020-03-31 09:03:17 -04:00
Louis Dionne 05b04c685c Recommit "[libc++] NFC: Simplify substitutions by using lit recursive substitutions"
This re-commits cd7f9751c3, which was reverted in 12f6b024f9 because
it broke the LLVM `check-all` target. This commit addresses the underlying
issue by not setting the lit_config.recursiveExpansionLimit parameter of
the libc++ test suite, which is otherwise picked up by other test suites
in LLVM.

Once we've settled on a fix for the underlying issue with
lit_config.recursiveExpansionLimit, we can start using it
again in libc++, but for now we can just work around it.
2020-03-30 18:09:42 -04:00
Louis Dionne 32c9efb423 [libc++] Add support for a new keyword ADDITIONAL_COMPILE_FLAGS
This allows adding compilation flags for a single test, which can help
eliminate some .sh.cpp tests and some custom handling in the libc++
test format.

It also works around the issue that .sh.cpp substitutions are _not_
equivalent to the actual compiler command lines used to compile tests,
since the compiler flags can be modified in local lit configurations,
and substitutions are frozen at that point. For example using %{compile}
in a .sh.cpp test in the coroutines subdirectory will not include the
-fcoroutines-ts flag, which is added in the local lit config, because
the %{compile} substitution is created long before we add -fcoroutines-ts
to the compiler flags (in the lit.local.cfg for coroutines).
2020-03-30 12:40:48 -04:00
David Zarzycki 12f6b024f9
Revert "[libc++] NFC: Simplify substitutions by using lit recursive substitutions"
This reverts commit cd7f9751c3 which has
unintended breakage to non-libcxx projects when using the documented way
of building LLVM. (See the Getting Started guide. I.e. one big CMake setup.)
2020-03-29 21:08:42 -04:00
Louis Dionne e9a2caf34c [libc++] Use braces around %file_dependencies substitution
This one was left out from a previous commit.
2020-03-27 11:33:25 -04:00
Louis Dionne cd7f9751c3 [libc++] NFC: Simplify substitutions by using lit recursive substitutions
Since lit supports expanding substitutions recursively, we can define
substitutions in terms of other substitutions. This allows us to simplify
how libc++ substitutions are defined.

This doesn't change the substitutions at all, it only makes them simpler
to define.
2020-03-27 11:09:08 -04:00
Louis Dionne 08776defa5 [libc++/libc++abi] Properly delimit lit substitutions
lit is not very clever when it performs substitution on RUN lines. It
simply looks for a match anywhere in the line (without tokenization)
and replaces it by the expansion. This means that a RUN line containing
e.g. `-verify-ignore-unexpected=note` wouod be expanded to
`-verify-ignore-unexpected=<substitution for not>e`, which is
surprising and nonsensical.

It also means that something like `%compile_module` could be expanded
to `<substitution-for-%compile>_module` or to the correct substitution,
depending on the order in which substitutions are evaluated by lit.

To avoid such problems, it is a good habit to delimit custom substitutions
with some token. This commit does that for all substitutions used in the
libc++ and libc++abi test suites.
2020-03-27 10:27:38 -04:00
Louis Dionne 3f2f7f895a [libc++] Remove unused lit substitutions 2020-03-27 10:08:57 -04:00
Sterling Augustine 6c6fba8808 Correctly handle using foo = std::foo inside namespaces.
Summary:
The gdb pretty printer misprints variables declared via
using declarations of the form:

namespace foo {
using string_view = std::string_view;

string_view bar;
}

This change fixes that, by deferring the decision to ignore
types not inside std until after desugaring.

Reviewers: #libc!

Subscribers: broadwaylamb, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D76816
2020-03-26 11:20:09 -07:00
Eric Fiselier 076773253e Revert "[libc++] Run the builders Docker containers 'as 'buildbot instead of 'root'"
This reverts commit a32b94c6c3.

The buildbot startup scripts need to run as root. The buildbot
worker should have already been running as a different account.
More investigation needed.
2020-03-26 08:08:01 -04:00
Louis Dionne a5fa5f7cb8 [libc++] Do not force the use of -Werror in verify tests
Forcing -Werror and other warnings means that the test suite isn't
actually testing what most people are seeing in their code -- it seems
better and less arbitrary to compile these tests as close as possible
to the compiler default instead.

Removing -Werror also means that we get to differentiate between
diagnostics that are errors and those that are warnings, which makes
the test suite more precise.

Differential Revision: https://reviews.llvm.org/D76311
2020-03-26 07:54:45 -04:00
Louis Dionne aec82f9256 [libc++] Require the use of clang-verify in .fail.cpp tests that don't fail without it
Some tests do not fail at all when -verify is not supported, unless some
arbitrary warning flag is added to make them fail. We currently used
-Werror=unused-result to make them fail, but doing so makes the test
suite a lot more inscrutable. It seems better to just disable those
tests when -verify is not supported.

Differential Revision: https://reviews.llvm.org/D76256
2020-03-25 16:48:09 -04:00
Louis Dionne 9223b7f927 [libc++] Add a new %exec substitution
It allows executing arbitrary commands with the same environment as
normal .pass.cpp tests, which is handy.
2020-03-25 16:26:57 -04:00
Louis Dionne f03ac38147 [libc++] Drop custom support for flaky tests from libc++ test suite
Instead, use the builtin support in lit. This makes the libc++ custom
test format slightly closer to the builtin ShTest format in behavior.
2020-03-25 14:41:53 -04:00
Louis Dionne a32b94c6c3 [libc++] Run the builders Docker containers 'as 'buildbot instead of 'root' 2020-03-25 12:07:44 -04:00
Louis Dionne 7311b27403 [libc++] Install a recent CMake in the Docker build bots 2020-03-24 18:06:56 -04:00
Louis Dionne 3c84aca9b3 [libc++] Bump Clang support for Clang 4
It's hard to imagine someone using a recent version of libc++ with a
roughly 3 years old Clang. Since we're not testing libc++ with Clang 3.5
anyway, claiming support for it is somewhat of a lie.

Note that we don't test Clang 4 either, however I have no reason to bump
the requirement beyond Clang 4 at the moment, whereas removing Clang 3.5
allows simplifying the test suite.

Differential Revision: https://reviews.llvm.org/D76618
2020-03-23 12:17:04 -04:00
Eric Fiselier c0e1135fb0 [libc++] Fix URL to llvm github 2020-03-21 10:13:50 -04:00
Eric Fiselier deb5103378 [libc++] Rework buildbot configuration for the greater good.
This commit rewrites/removes the docker files used to create
the libc++ buildbots.

The major changes in this patch are:

1. Delete Dockerfiles used to build compilers. These have moved to
   github.com/efcs/compiler-images

2. Minimize the llvm-buildbot docker image. Instead of running the
buildbots from a committed docker image, the builders now build the
image on startup. This means changes to the docker file automatically
propogate to the builders (within ~24 hours without restart).

3. Version the compilers used by the builders. This means the bots
won't start failing because the apt.llvm.org clang package updated.
2020-03-21 10:02:40 -04:00
Louis Dionne 0feaf22c8a [libc++] Properly handle environment variables with '=' in them 2020-03-20 19:29:01 -04:00
Louis Dionne e22fe98d05 [libc++] Make the %run substitution closer to how .pass.cpp tests are executed
Before this patch, the %run substitution did not contain the same
environment variables as normal `pass.cpp` tests. It also didn't
have the right working directory and the script wasn't aware of
potential file dependencies.

With this change, the combination of %build and %run in a .sh.cpp script
should match how pass.cpp tests are actually executed much more closely.
2020-03-20 18:52:14 -04:00
Louis Dionne 7efbd851ad [libc++] Add a new FILE_DEPENDENCIES parser
Instead of considering all the .dat files to be dependencies of a test,
only consider those that are listed in FILE_DEPENDENCIES.
2020-03-20 14:55:52 -04:00
Louis Dionne a4ef2a71d3 [libc++] Move some misplaced compile-time flags
Some compilation-only flags were in %flags, but they should have been
in %compile_flags only.
2020-03-17 17:53:20 -04:00
Louis Dionne 3d9e6c42f8 [libc++] Use env to set the tool's environment on Darwin 2020-03-17 15:40:51 -04:00
Marek Kurdej 05343588e3 [libc++] [P0646] Add feature-test macro for __cpp_lib_list_remove_return_type.
Summary: The return type modification has already been implemented in rL364840 and rL365290.

Reviewers: ldionne, mclow.lists, EricWF, #libc!

Reviewed By: ldionne

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D70275
2020-03-12 11:06:49 +01:00
Petr Hosek dffbaa4014 [libcxx] Drop -D option from libtool when merging archives
This is a follow up to D74108. This option is not supported by older
versions of libtool so remove it. We keep the -s option to build the
index.
2020-03-02 16:07:18 -08:00