From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118773 invoked by alias); 9 Jan 2018 14:31:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 118755 invoked by uid 89); 9 Jan 2018 14:31:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=20s X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Jan 2018 14:31:42 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBE30CD663; Tue, 9 Jan 2018 14:31:40 +0000 (UTC) Received: from localhost (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CECD60841; Tue, 9 Jan 2018 14:31:40 +0000 (UTC) Date: Tue, 09 Jan 2018 14:32:00 -0000 From: Jonathan Wakely To: Mike Crowe Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH 1/5] Improve libstdc++-v3 async test Message-ID: <20180109143139.GC5527@redhat.com> References: <20180107205532.13138-1-mac@mcrowe.com> <20180107205532.13138-2-mac@mcrowe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180107205532.13138-2-mac@mcrowe.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.1 (2017-09-22) X-SW-Source: 2018-01/txt/msg00616.txt.bz2 On 07/01/18 20:55 +0000, Mike Crowe wrote: >Add tests for waiting for the future using both std::chrono::steady_clock >and std::chrono::system_clock in preparation for dealing with those clocks >properly in futex.cc. >--- > libstdc++-v3/testsuite/30_threads/async/async.cc | 36 ++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > >diff --git a/libstdc++-v3/testsuite/30_threads/async/async.cc b/libstdc++-v3/testsuite/30_threads/async/async.cc >index 8071cb133fc..7326c5f7cd6 100644 >--- a/libstdc++-v3/testsuite/30_threads/async/async.cc >+++ b/libstdc++-v3/testsuite/30_threads/async/async.cc >@@ -52,17 +52,53 @@ void test02() > VERIFY( status == std::future_status::timeout ); > status = f1.wait_until(std::chrono::system_clock::now()); > VERIFY( status == std::future_status::timeout ); >+ status = f1.wait_until(std::chrono::steady_clock::now()); >+ VERIFY( status == std::future_status::timeout ); > l.unlock(); // allow async thread to proceed > f1.wait(); // wait for it to finish > status = f1.wait_for(std::chrono::milliseconds(0)); > VERIFY( status == std::future_status::ready ); > status = f1.wait_until(std::chrono::system_clock::now()); > VERIFY( status == std::future_status::ready ); >+ status = f1.wait_until(std::chrono::steady_clock::now()); >+ VERIFY( status == std::future_status::ready ); >+} >+ >+void work03() >+{ >+ std::this_thread::sleep_for(std::chrono::seconds(15)); I don't think we want 15s - 20s pauses in the testsuite. Could the sleep_for be 5s, with waits of 500ms, 1s, and then 10s, so the expected wait is only 5s? I don't think it's the end of the world if the test occasionally fails on very loaded machines. >+} >+ >+// This test is slow in order to try and avoid failing on a loaded >+// machine. Nevertheless, it could still fail if the kernel decides >+// not to schedule us for several seconds. It also assumes that no-one >+// will change CLOCK_REALTIME whilst the test is running. >+template >+void test03() >+{ >+ auto const start = CLOCK::now(); >+ future f1 = async(launch::async, &work03); >+ std::future_status status; >+ >+ status = f1.wait_for(std::chrono::seconds(5)); >+ VERIFY( status == std::future_status::timeout ); >+ >+ status = f1.wait_until(start + std::chrono::seconds(10)); >+ VERIFY( status == std::future_status::timeout ); >+ >+ status = f1.wait_until(start + std::chrono::seconds(25)); >+ VERIFY( status == std::future_status::ready ); >+ >+ auto const elapsed = CLOCK::now() - start; >+ VERIFY( elapsed >= std::chrono::seconds(15) ); >+ VERIFY( elapsed < std::chrono::seconds(20) ); > } > > int main() > { > test01(); > test02(); >+ test03(); >+ test03(); > return 0; > } >-- >2.11.0 > >