public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1231] libstdc++: testsuite: tolerate non-cancelling sleep
@ 2022-06-24 2:30 Alexandre Oliva
0 siblings, 0 replies; only message in thread
From: Alexandre Oliva @ 2022-06-24 2:30 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:0b2c1781db8df9051ce3d160af2113387742fef2
commit r13-1231-g0b2c1781db8df9051ce3d160af2113387742fef2
Author: Alexandre Oliva <oliva@adacore.com>
Date: Thu Jun 23 23:20:46 2022 -0300
libstdc++: testsuite: tolerate non-cancelling sleep
Though sleep, nanosleep and clock_nanosleep are all POSIX cancellation
points, not all target systems follow this POSIX requirement.
30_threads/thread/native_handle/cancel.cc will run until it times out
on such systems.
Rather than failing a C++ library test because of a limitation of the
target system, this patch gives the test a chance to successfully
exercise the features it intends to exercise, by introducing a
cancellation point in a loop that would otherwise run indefinitely on
systems exhibiting this limitation.
for libstdc++-v3/ChangeLog
* testsuite/30_threads/thread/native_handle/cancel.cc: Add an
explicit cancellation point in case sleep_for lacks one.
Diff:
---
libstdc++-v3/testsuite/30_threads/thread/native_handle/cancel.cc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/testsuite/30_threads/thread/native_handle/cancel.cc b/libstdc++-v3/testsuite/30_threads/thread/native_handle/cancel.cc
index dca162b3ace..3cef97e8c53 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/native_handle/cancel.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/native_handle/cancel.cc
@@ -30,7 +30,11 @@ void f(std::atomic<bool>& started)
{
started = true;
while (true)
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ // In case the target system doesn't make sleep a cancellation point...
+ pthread_testcancel();
+ }
}
int main()
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-24 2:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24 2:30 [gcc r13-1231] libstdc++: testsuite: tolerate non-cancelling sleep Alexandre Oliva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).