summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/thread/thread.condition
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Revert "Implement std::condition_variable via ↵Dan Albert2019-09-181-11/+22
| | | | | | | | | | pthread_cond_clockwait() where available"" With the fix for non-Linux. This reverts commit c1c519d2f1a66dd2eeaa4c321d8d7b50f623eb71. llvm-svn: 372242
* Revert "Implement std::condition_variable via pthread_cond_clockwait() where ↵Dan Albert2019-09-161-22/+11
| | | | | | | | available" This reverts commit 5e37d7f9ff257ec62d733d3d94b11f03e0fe51ca. llvm-svn: 372034
* Implement std::condition_variable via pthread_cond_clockwait() where availableDan Albert2019-09-161-11/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add include for 'test_macros.h' to all the tests that were missing them. ↵Marshall Clow2019-05-3122-0/+44
| | | | | | Thanks to Zoe for the (big, but simple) patch. NFC intended. llvm-svn: 362252
* Support tests in freestandingJF Bastien2019-02-0427-27/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Mark another test as flakyKamil Rytarowski2019-01-231-0/+2
| | | | | | Reported on the NetBSD 8 buildbot. llvm-svn: 351988
* Correct mark for flaky testsKamil Rytarowski2019-01-232-2/+2
| | | | | | Add missing trailing dot. llvm-svn: 351983
* Mark more tests flakyKamil Rytarowski2019-01-231-0/+2
| | | | | | Reported on the NetBSD 8 buildbot llvm-svn: 351944
* Mark thread.condition.condvarany/wait_for.pass.cpp as flakyKamil Rytarowski2019-01-231-0/+2
| | | | | | Reported on the NetBSD 8 buildbot. llvm-svn: 351937
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1927-108/+81
| | | | | | | | | | | | | | | | | | 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
* Mark more tests as flakyEric Fiselier2019-01-072-0/+4
| | | | llvm-svn: 350550
* Move POSIX specific test under test/libcxx subdirectoryEric Fiselier2017-05-121-76/+0
| | | | llvm-svn: 302865
* test: mark requirement for pthread testSaleem Abdulrasool2017-02-121-0/+1
| | | | | | | | This test explicitly is checking the behaviour of std::thread and pthread interactions. This requires pthreads. Add an appropriate requirement. llvm-svn: 294903
* [libcxx] [test] Fix comment typos, strip trailing whitespace.Stephan T. Lavavej2017-01-181-3/+3
| | | | | | No functional change, no code review. llvm-svn: 292434
* fix newly failing c++03 testsEric Fiselier2016-12-241-3/+6
| | | | llvm-svn: 290472
* Fix unused parameters and variablesEric Fiselier2016-12-231-4/+5
| | | | llvm-svn: 290459
* [libcxx] [test] D26314: Fix MSVC warning C4189 "local variable is ↵Stephan T. Lavavej2016-11-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initialized but not referenced". test/std/depr/depr.c.headers/inttypes_h.pass.cpp test/std/input.output/file.streams/c.files/cinttypes.pass.cpp test/std/input.output/iostream.forward/iosfwd.pass.cpp Add test() to avoid a bunch of void-casts, although we still need a few. test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp skippingws was unused (it's unclear to me whether this was mistakenly copy-pasted from round_trip() below). test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp test/std/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp test/std/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp test/std/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp test/std/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp test/std/localization/locales/locale.global.templates/use_facet.pass.cpp When retrieving facets, the references are unused. test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp "std::ios_base::iostate err = ios.goodbit;" was completely unused here. test/std/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp test/std/numerics/c.math/ctgmath.pass.cpp test/std/numerics/rand/rand.device/entropy.pass.cpp test/std/numerics/rand/rand.device/eval.pass.cpp test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp test/std/thread/futures/futures.promise/dtor.pass.cpp test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp These variables are verifying types but are otherwise unused. test/std/strings/basic.string/string.capacity/reserve.pass.cpp old_cap was unused (it's unclear to me whether it was intended to be used). test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp These tests contained unused characters. llvm-svn: 286847
* Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: ↵Roger Ferrer Ibanez2016-10-311-1/+1
| | | | | | | | | | | | | libcpp-no-exceptions" tests that only check exceptions and nothing else This is a follow up of D24562. These tests do not check anything but exceptions, so it makes sense to mark them as UNSUPPORTED under a library built without exceptions. Differential Revision: https://reviews.llvm.org/D26075 llvm-svn: 285550
* Fix PR30202 - notify_all_at_thread_exit seg faults if run from a raw pthread ↵Eric Fiselier2016-09-031-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | context. Summary: This patch allows threads not created using `std::thread` to use `std::notify_all_at_thread_exit` by ensuring the TL state has been initialized within `std::notify_all_at_thread_exit`. Additionally this patch "fixes" a potential oddity in `__thread_local_pointer::reset(pointer)`, which would previously delete the old thread local data. However there should *never* be old thread local data because pthread *should* null it out on thread exit. Unfortunately it's possible that pthread failed to do this according to the spec: > > Upon key creation, the value NULL shall be associated with the new key in all active threads. Upon thread creation, the value NULL shall be associated with all defined keys in the new thread. > > An optional destructor function may be associated with each key value. At thread exit, if a key value has a non-NULL destructor pointer, and the thread has a non-NULL value associated with that key, the value of the key is set to NULL, and then the function pointed to is called with the previously associated value as its sole argument. The order of destructor calls is unspecified if more than one destructor exists for a thread when it exits. > > If, after all the destructors have been called for all non-NULL values with associated destructors, there are still some non-NULL values with associated destructors, then the process is repeated. If, after at least {PTHREAD_DESTRUCTOR_ITERATIONS} iterations of destructor calls for outstanding non-NULL values, there are still some non-NULL values with associated destructors, implementations may stop calling destructors, or they may continue calling destructors until no non-NULL values with associated destructors exist, even though this might result in an infinite loop. However if pthread fails to delete the value it is probably incorrect for us to do it. Destroying the value performs all of the "at thread exit" actions registered with it but we are way past "at thread exit". Reviewers: mclow.lists, bcraig, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24159 llvm-svn: 280588
* Move more _LIBCPP_VERSION tests to test/libcxx.Eric Fiselier2016-06-221-22/+0
| | | | llvm-svn: 273365
* Move native_handle thread tests to test/libcxxEric Fiselier2016-06-221-29/+0
| | | | llvm-svn: 273341
* Make it possible to build a no-exceptions variant of libcxx.Asiri Rathnayake2015-11-101-0/+1
| | | | | | | | | | | | Fixes a small omission in libcxx that prevents libcxx being built when -DLIBCXX_ENABLE_EXCEPTIONS=0 is specified. This patch adds XFAILS to all those tests that are currently failing on the new -fno-exceptions library variant. Follow-up patches will update the tests (progressively) to cope with the new library variant. Change-Id: I4b801bd8d8e4fe7193df9e55f39f1f393a8ba81a llvm-svn: 252598
* Finally get the test suite passing in C++03!!Eric Fiselier2015-08-281-0/+4
| | | | | | | | | After months of work there are only 4 tests still failing in C++03. This patch fixes those tests. All of the libc++ builders should be green. llvm-svn: 246275
* Remove test_atomic.h headerEric Fiselier2015-08-192-7/+8
| | | | | | | Because <atomic> can now be used in C++03 there is no need for the test_atomic.h header. This commit removes the header and converts all usages to use <atomic> instead. llvm-svn: 245468
* [libcxx] Add Atomic test helper and fix TSAN failures.Eric Fiselier2015-08-185-130/+142
| | | | | | | | | | | | | | | | | | | Summary: This patch attempts to fix the last 3 TSAN failures on the libc++ bot (http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-tsan/builds/143). This patch also adds a `Atomic` test type that can be used where `<atomic>` cannot. `wait.exception.pass.cpp` and `wait_for.exception.pass.cpp` were failing because the test replaced `std::terminate` with `std::exit`. `std::exit` would asynchronously run the TLS and static destructors and this would cause a race condition. See PR22606 and D8802 for more details. This is fixed by using `_Exit` to prevent cleanup. `notify_all_at_thread_exit.pass.cpp` exercises the same race condition but for different reasons. I fixed this test by manually joining the thread before beginning program termination. Reviewers: EricWF, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11046 llvm-svn: 245389
* Move test into test/std subdirectory.Eric Fiselier2014-12-2030-0/+1881
llvm-svn: 224658
OpenPOWER on IntegriCloud