Commit Graph

165 Commits

Author SHA1 Message Date
David Zarzycki 1858953395 [libcxx testing] Remove ALLOW_RETRIES from two futures tests
These two tests do not use the "thread sleeps X milliseconds" pattern
that other libcxx tests use, so all we can do in order to remove
ALLOW_RETRIES workaround is remove the assumption that measuring the
"quick" return of `wait()` is possible (it is not). Let the test harness
verify overall that `wait()` does not hang.

As a bonus, have the spin-waiting threads `yield()`, which is what well
behaved code should do.
2020-05-14 06:18:23 -04:00
David Zarzycki 1febe28982 [libcxx testing] Remove ALLOW_RETRIES from wait_for futures test
This test tried to verify that "wait()" returned quickly but "quick" is
impossible to define given a busy and/or slow system.

Instead, I've refactored the test to verify that `wait()` actually
waits which the old test did not verify.
2020-05-13 06:47:29 -04:00
David Zarzycki 4f4d6c81f8 [libcxx testing] Remove ALLOW_RETRIES from sleep_until.pass.cpp
Operating systems are best effort by default, so we cannot assume that
sleep-like APIs return as soon as we'd like.

Even if a sleep-like API returns when we want it to, the potential for
preemption means that attempts to measure time are subject to delays.
2020-05-10 05:59:09 -04:00
David Zarzycki 4f4ce13944 [libcxx testing] Make three locking tests more reliable
The challenge with measuring time in tests is that slow and/or busy
machines can cause tests to fail in unexpected ways. After this change,
three tests should be much more robust. The only remaining and tiny race
that I can think of is preemption after `--countDown`. That being said,
the race isn't fixable because the standard library doesn't provide a
way to count threads that are waiting to acquire a lock.

Reviewers: ldionne, EricWF, howard.hinnant, mclow.lists, #libc

Reviewed By: ldionne, #libc

Subscribers: dexonsmith, jfb, broadwaylamb, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D79406
2020-05-09 11:11:26 -04:00
Louis Dionne 2fd7d364cd [libc++] Make the verify-support feature implicit
Tests that require support for Clang-verify are already marked as such
explicitly by their extension, which is .verify.cpp. Requiring the use
of an explicit Lit feature is, after thought, not really helpful.

This is a change in design: we have been bitten in the past by tests not
being enabled when we thought they were. However, the issue was mostly
with file extensions being ignored. The fix for that is not to blindly
require explicit features all the time, but instead to report all files
that are in the suite but that don't match any known test format. This
can be implemented in a follow-up patch.
2020-04-30 11:47:12 -04:00
Louis Dionne d7da36c6e0 [libc++] Mark two timed_mutex tests as flaky 2020-04-29 11:52:17 -04:00
Louis Dionne f17eb4ec20 [libc++] Add UNSUPPORTED markup for shared_mutex and shared_timed_mutex tests
The tests were previously disabled entirely whenever availability markup
was enabled. Instead, enable the tests but add the proper UNSUPPORTED
markup.
2020-04-27 04:23:58 -04:00
Louis Dionne 8c61114c53 [libc++/abi/unwind] Rename Lit features for no exceptions to 'no-exceptions'
Instead of having different names for the same Lit feature accross code
bases, use the same name everywhere. This NFC commit is in preparation
for a refactor where all three projects will be using the same Lit
feature detection logic, and hence it won't be convenient to use
different names for the feature.

Differential Revision: https://reviews.llvm.org/D78370
2020-04-22 08:25:27 -04:00
Louis Dionne 9a39d5a2ec [libc++] Move .fail.cpp tests with verify-support to .verify.cpp 2020-04-17 09:05:28 -04:00
Louis Dionne 7a6aaf9b23 [libc++] Remove workaround for .fail.cpp tests that don't have clang-verify markup
By renaming .fail.cpp tests that don't need clang-verify to .compile.fail.cpp,
the new test format will not try to compile these tests with clang-verify,
and the old test format will work just the same. However, this allows
removing a workaround that requires parsing each test looking for
clang-verify markup.

After this change, a .fail.cpp test should always have clang-verify markup.
When clang-verify is not supported by the compiler, we will just check that
these tests fail to compile. When clang-verify is supported, these tests
will be compiled with clang-verify whether they have markup or not (so
they should have markup, or they will fail).

This simplifies the test suite and also ensures that all of our .fail.cpp
tests provide clang-verify markup. If it's impossible for a test to have
clang-verify markup, it can be moved to a .compile.fail.cpp test, which
are unconditionally just checked for compilation failure.
2020-04-15 10:53:37 -04:00
Louis Dionne 7149bb7068 [libc++] NFC: Clean up a lot of old Lit features
The libc++ test suite has a lot of old Lit features used to XFAIL tests
and mark them as UNSUPPORTED. Many of them are to workaround problems on
old compilers or old platforms. As time goes by, it is good to go and
clean those up to simplify the configuration of the test suite, and also
to reflect the testing reality. It's not useful to have markup that gives
the impression that e.g. clang-3.3 is supported, when we don't really
test on it anymore (and hence several new tests probably don't have the
necessary markup on them).
2020-04-10 17:20:29 -04:00
Louis Dionne 7662ad67c5 [libc++] Mark two std::timed_mutex tests as flaky 2020-04-06 12:41:10 -04:00
Louis Dionne aaaa25e23d [libc++] Remove useless nothing_to_do.pass.cpp tests
The testing script used to test libc++ historically did not like directories
without any testing files, so these tests had been added. Since this is
not necessary anymore, we can now remove these files. This has the benefit
that the total number of tests reflects the real number of tests more
closely, and we also skip some unnecessary work (especially relevant when
running tests over SSH).

However, some nothing_to_do.pass.cpp tests actually serve the purpose of
documenting that an area of the Standard doesn't need to be tested, or is
tested elsewhere. These files are not removed by this commit.

Removal done with:

  import os
  import itertools
  for (dirpath, dirnames, filenames) in itertools.chain(os.walk('./libcxx/test'),
                                                        os.walk('./libcxxabi/test')):
      if len(filenames + dirnames) > 1 and \
         any(p == 'nothing_to_do.pass.cpp' for p in filenames):
          os.remove(os.path.join(dirpath, 'nothing_to_do.pass.cpp'))
2020-04-03 13:48:34 -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 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 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 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 ee87b22a12 [libc+++] Mark two future tests as being FLAKY
They are timing sensitive.
2020-03-11 18:12:59 -04:00
Louis Dionne 06dac0c39a [libc++] Mark the shared_future.wait_for test as being flaky
It is timing sensitive and it fails from time to time. If marking it as
flaky doesn't help, we can try tweaking the time outs.
2020-03-04 10:10:50 -05:00
Eric Fiselier d4ad2adb00 [libc++] Mark more try_lock tests as possibly flaky.
These tests check that an operations happens within a specified
deadline, which causes flaky failures on slow machines or machines
under heavy load.

By adding the // FLAKY_TEST. tag it allows the test suite to
retry or ignore the tests
2020-02-27 13:25:57 -05:00
ogiroux 621388468b Some fixes for open breaks on MacOS and UBSan 2020-02-26 20:51:19 -08:00
Louis Dionne b051cc9327 [NFC][libc++] Refactor some future tests to reduce code duplication
The same test was being repeated over and over again.
That's what functions are for.
2020-02-25 18:16:45 -05:00
Louis Dionne 80e73f2295 [libc++] Adapt a few things around the implementation of P1135R6
- Add the new symbols to the ABI list on Darwin
- Add XFAIL markup to the tests that require dylib support on older platforms
- Add availability markup for back-deployment
2020-02-24 10:59:35 -05:00
Olivier Giroux 54fa9ecd30 [libc++] Implementation of C++20's P1135R6 for libcxx
Differential Revision: https://reviews.llvm.org/D68480
2020-02-24 10:59:35 -05:00
Louis Dionne e16f2cb678 [libc++] Take 2: Implement LWG 2510
Summary:
LWG2510 makes tag types like allocator_arg_t explicitly default
constructible instead of implicitly default constructible. It also
makes the constructors for std::pair and std::tuple conditionally
explicit based on the explicit-ness of the default constructibility
for the pair/tuple's elements.

This was previously committed as r372777 and reverted in r372832 due to
the commit breaking LLVM's build in C++14 mode. This issue has now been
addressed.

Reviewers: mclow.lists

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D65161

llvm-svn: 372983
2019-09-26 14:51:10 +00:00
Ilya Biryukov a3d337a9a7 Revert r372777: [libc++] Implement LWG 2510 and its follow-ups
This also reverts:
 - r372778: [libc++] Implement LWG 3158
 - r372782: [libc++] Try fixing tests that fail on GCC 5 and older
 - r372787: Purge mentions of GCC 4 from the test suite

Reason: the change breaks compilation of LLVM with libc++, for details see
http://lists.llvm.org/pipermail/libcxx-dev/2019-September/000599.html

llvm-svn: 372832
2019-09-25 09:10:38 +00:00
Louis Dionne de8609c62a [libc++] Purge mentions of GCC 4 from the test suite
We don't support GCC 4 and older according to the documentation, so
we should pretend it doesn't exist.

llvm-svn: 372787
2019-09-24 22:42:36 +00:00
Louis Dionne ee9a468d9c [libc++] Try fixing tests that fail on GCC 5 and older
llvm-svn: 372782
2019-09-24 22:13:17 +00:00
Louis Dionne 95411dd426 [libc++] Implement LWG 2510
Summary:
LWG2510 makes tag types like allocator_arg_t explicitly default
constructible instead of implicitly default constructible. It also
makes the constructors for std::pair and std::tuple conditionally
explicit based on the explicit-ness of the default constructibility
for the pair/tuple's elements.

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D65161

llvm-svn: 372777
2019-09-24 20:18:54 +00:00
Dan Albert 85e26f56cb Revert "Revert "Implement std::condition_variable via pthread_cond_clockwait() where available""
With the fix for non-Linux.

This reverts commit c1c519d2f1.

llvm-svn: 372242
2019-09-18 18:13:32 +00:00
Dan Albert c1c519d2f1 Revert "Implement std::condition_variable via pthread_cond_clockwait() where available"
This reverts commit 5e37d7f9ff.

llvm-svn: 372034
2019-09-16 21:20:32 +00:00
Dan Albert 5e37d7f9ff Implement std::condition_variable via pthread_cond_clockwait() where available
std::condition_variable is currently implemented via
pthread_cond_timedwait() on systems that use pthread. This is
problematic, since that function waits by default on CLOCK_REALTIME
and libc++ does not provide any mechanism to change from this
default.

Due to this, regardless of if condition_variable::wait_until() is
called with a chrono::system_clock or chrono::steady_clock parameter,
condition_variable::wait_until() will wait using CLOCK_REALTIME. This
is not accurate to the C++ standard as calling
condition_variable::wait_until() with a chrono::steady_clock parameter
should use CLOCK_MONOTONIC.

This is particularly problematic because CLOCK_REALTIME is a bad
choice as it is subject to discontinuous time adjustments, that may
cause condition_variable::wait_until() to immediately timeout or wait
indefinitely.

This change fixes this issue with a new POSIX function,
pthread_cond_clockwait() proposed on
http://austingroupbugs.net/view.php?id=1216. The new function is
similar to pthread_cond_timedwait() with the addition of a clock
parameter that allows it to wait using either CLOCK_REALTIME or
CLOCK_MONOTONIC, thus allowing condition_variable::wait_until() to
wait using CLOCK_REALTIME for chrono::system_clock and CLOCK_MONOTONIC
for chrono::steady_clock.

pthread_cond_clockwait() is implemented in glibc (2.30 and later) and
Android's bionic (Android API version 30 and later).

This change additionally makes wait_for() and wait_until() with clocks
other than chrono::system_clock use CLOCK_MONOTONIC.<Paste>

llvm-svn: 372016
2019-09-16 17:57:48 +00:00
Nico Weber cc89063bff libcxx: Rename .hpp files in libcxx/test/support to .h
LLVM uses .h as its extension for header files.

Files renamed using:

    for f in libcxx/test/support/*.hpp; do git mv $f ${f%.hpp}.h; done

References to the files updated using:

    for f in $(git diff master | grep 'rename from' | cut -f 3 -d ' '); do
        a=$(basename $f);
        echo $a;
        rg -l $a libcxx | xargs sed -i '' "s/$a/${a%.hpp}.h/";
    done

HPP include guards updated manually using:

    for f in $(git diff master | grep 'rename from' | cut -f 3 -d ' '); do
      echo ${f%.hpp}.h ;
    done | xargs mvim

Differential Revision: https://reviews.llvm.org/D66104

llvm-svn: 369481
2019-08-21 00:14:12 +00:00
Nico Weber 9aae539d4c libcxx: Define __STDCPP_THREADS__ to 1, not to __cplusplus.
[cpp.predefined]p2:

   __STDCPP_THREADS__
    Defined, and has the value integer literal 1, if and only if a program
    can have more than one thread of execution .

Also define it only if it's not defined already, since it's supposed
to be defined by the compiler.

Also move it from thread to __config (which requires setting it only
if _LIBCPP_HAS_NO_THREADS is not defined).

Part of PR33230. The intent is to eventually make the compiler define
this instead.

llvm-svn: 367316
2019-07-30 14:32:47 +00:00
Eric Fiselier 8baf83839e Fix PR27658 - Make ~mutex trivial when possible.
Currently std::mutex has a constexpr constructor, but a non-trivial
destruction.

The constexpr constructor is required to ensure the construction of a
mutex with static storage duration happens at compile time, during
constant initialization, and not during dynamic initialization.
This means that static mutex's are always initialized and can be used
safely during dynamic initialization without the "static initialization
order fiasco".

A trivial destructor is important for similar reasons. If a mutex is
used during dynamic initialization it might also be used during program
termination. If a static mutex has a non-trivial destructor it will be
invoked during termination. This can introduce the "static
deinitialization order fiasco".

Additionally, function-local statics emit a guard variable around
non-trivially destructible types. This results in horrible codegen and
adds a runtime cost to every call to that function. non-local static's
also result in slightly worse codegen but it's not as big of a problem.

Example codegen can be found here: https://goo.gl/3CSzbM

Note: This optimization is not safe with every pthread implementation.
Some implementations allocate on the first call to pthread_mutex_lock
and free the allocation in pthread_mutex_destroy.

Also, changing the triviality of the destructor is not an ABI break.
At least to the best of my knowledge :-)

llvm-svn: 365273
2019-07-07 01:20:54 +00:00
Marshall Clow 7fc6a55688 Add include for 'test_macros.h' to all the tests that were missing them. Thanks to Zoe for the (big, but simple) patch. NFC intended.
llvm-svn: 362252
2019-05-31 18:35:30 +00:00
Casey Carter b574e11217 [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new
Drive-by:
* Fix potential race between check and update of `throw_one` in `operator new`
* Fix latent bug in `operator delete`, which shouldn't decrement `outstanding_new` when passed a null pointer
* Specifically catch the expected `bad_alloc` in `main` instead of `...`

Differential Revision: https://reviews.llvm.org/D50860

llvm-svn: 359827
2019-05-02 21:19:41 +00:00
Louis Dionne afeff20c0f [libc++] Remove unnecessary <iostream> #includes in tests
Some tests #include <iostream> but they don't use anything from the
header. Those are probably artifacts of when the tests were developped.

llvm-svn: 357181
2019-03-28 16:38:15 +00:00
Louis Dionne daf43ed800 [libc++] Add proper XFAILs for shared_mutex tests
Dylib support for shared_mutex was added in macOS 10.12, so the tests
should be XFAILed accordingly instead of being completely disabled
whenever availability is enabled.

rdar://problem/48769104

llvm-svn: 357079
2019-03-27 15:50:34 +00:00
Kamil Rytarowski 61113341f7 Mark another test as flaky
Reported on the NetBSD buildbot.

llvm-svn: 353622
2019-02-09 18:39:07 +00:00
JF Bastien 2df59c5068 Support tests in freestanding
Summary:
Freestanding is *weird*. The standard allows it to differ in a bunch of odd
manners from regular C++, and the committee would like to improve that
situation. I'd like to make libc++ behave better with what freestanding should
be, so that it can be a tool we use in improving the standard. To do that we
need to try stuff out, both with "freestanding the language mode" and
"freestanding the library subset".

Let's start with the super basic: run the libc++ tests in freestanding, using
clang as the compiler, and see what works. The easiest hack to do this:

In utils/libcxx/test/config.py add:

  self.cxx.compile_flags += ['-ffreestanding']

Run the tests and they all fail.

Why? Because in freestanding `main` isn't special. This "not special" property
has two effects: main doesn't get mangled, and main isn't allowed to omit its
`return` statement. The first means main gets mangled and the linker can't
create a valid executable for us to test. The second means we spew out warnings
(ew) and the compiler doesn't insert the `return` we omitted, and main just
falls of the end and does whatever undefined behavior (if you're luck, ud2
leading to non-zero return code).

Let's start my work with the basics. This patch changes all libc++ tests to
declare `main` as `int main(int, char**` so it mangles consistently (enabling us
to declare another `extern "C"` main for freestanding which calls the mangled
one), and adds `return 0;` to all places where it was missing. This touches 6124
files, and I apologize.

The former was done with The Magic Of Sed.

The later was done with a (not quite correct but decent) clang tool:

  https://gist.github.com/jfbastien/793819ff360baa845483dde81170feed

This works for most tests, though I did have to adjust a few places when e.g.
the test runs with `-x c`, macros are used for main (such as for the filesystem
tests), etc.

Once this is in we can create a freestanding bot which will prevent further
regressions. After that, we can start the real work of supporting C++
freestanding fairly well in libc++.

<rdar://problem/47754795>

Reviewers: ldionne, mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commits

Differential Revision: https://reviews.llvm.org/D57624

llvm-svn: 353086
2019-02-04 20:31:13 +00:00
Kamil Rytarowski 47c0eb2bc2 Mark another test as flaky
Reported on the NetBSD 8 buildbot.

llvm-svn: 352064
2019-01-24 17:17:55 +00:00
Kamil Rytarowski d3068a2c2f Mark another test as flaky
Reported on the NetBSD 8 buildbot.

llvm-svn: 351995
2019-01-23 23:24:43 +00:00
Kamil Rytarowski 829d916d7d Mark another test as flaky
Reported on the NetBSD 8 buildbot.

llvm-svn: 351988
2019-01-23 22:35:57 +00:00
Kamil Rytarowski 314bd26db1 Correct mark for flaky tests
Add missing trailing dot.

llvm-svn: 351983
2019-01-23 21:45:02 +00:00
Kamil Rytarowski 776cf71d4f Mark more tests flaky
Reported on the NetBSD 8 buildbot

llvm-svn: 351944
2019-01-23 11:36:19 +00:00
Kamil Rytarowski fe1991b55e Mark thread.condition.condvarany/wait_for.pass.cpp as flaky
Reported on the NetBSD 8 buildbot.

llvm-svn: 351937
2019-01-23 10:11:41 +00:00
Chandler Carruth 57b08b0944 Update more file headers across all of the LLVM projects in the monorepo
to reflect the new license. These used slightly different spellings that
defeated my regular expressions.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351648
2019-01-19 10:56:40 +00:00
Eric Fiselier 7b03b66e5c Mark two more tests as FLAKY
llvm-svn: 350692
2019-01-09 05:48:54 +00:00