From patchwork Tue Oct 15 17:57:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Crowe X-Patchwork-Id: 1177265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-511041-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=mcrowe.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="hfdMztNI"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mcrowe.com header.i=@mcrowe.com header.b="qvY2IcvH"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46t38F0VM3z9sPF for ; Wed, 16 Oct 2019 04:58:52 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; q=dns; s=default; b=aQG 7X03NHgGlgmME9jfSdqXBICwFLOiKVxNyQ1YV7gaVqelBkmYVdWjRKMvRml7vQa2 ryLHZTopZ4z4+2wpNV2xPfqZdOa/m5rN/3hmHWaCM7NH5vfn72IhCPDqpOLVjbgt 3D1IOoS5izBsVH4Nx8mvm8Qk+utRFPe2lo1ENds0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=default; bh=gS3DLD9JJ N9T911v/cMnX8PVzmg=; b=hfdMztNIl1tgNqzHOZYOZKIoJltMVx3OTJwBayafB M4N+WCnnqXeAQSH3AGDgFpuzOQPka0A8lamzvs/wBQTx05XF7pp2eRQ8BHCBj1on qjwx9teXX6U/eSCikJIlVMINmHiEIw4rIUpAq7itdPKpT4cXaPaVnAtptWkvfaJj r4= Received: (qmail 58925 invoked by alias); 15 Oct 2019 17:57:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 58866 invoked by uid 89); 15 Oct 2019 17:57:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1569, 100ms, HContent-Transfer-Encoding:8bit X-HELO: avasout04.plus.net Received: from avasout04.plus.net (HELO avasout04.plus.net) (212.159.14.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Oct 2019 17:57:51 +0000 Received: from deneb ([80.229.24.9]) by smtp with ESMTP id KR4uitK4f37rvKR4viYB1U; Tue, 15 Oct 2019 18:57:51 +0100 X-Clacks-Overhead: "GNU Terry Pratchett" X-CM-Score: 0.00 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mcrowe.com; s=20191005; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=joHMQ9RpW0bQRbGgAHAckjQxmZ43Di4tGizB9KhcdMo=; b=qvY2IcvHtY5EyQD0Vmts1HGQQG S2cM4fFuPiw6YTQqqArQbWN0iT8/dfs2BkXJURMYT8XnS8OqmmhIPi4wBcIXd9fFQDsR1SYMNHsWL I7cfNWKzVpYBR57uI0ZsUHyOdMIWUStMWBAwJwH3UCrBZakvn1gDIrh/Y3R3C2M1aG70DqS7QOuTu Gwt8Z5a2USAJxLJgN7xddoMNudi/sF5Z3uhHsL9q1eHaEnp1Z/z/XBIBlEZFYiQPIy+yfrU6pKEqm bl8WxBzMQEOpXX3Mx4+EL6OVkxTR7CXY4Q1i0FWNPfiUnIcNlbyFnSEjWfWlY7PU7TRujib5/JhAN z0db6+Xw==; Received: from mac by deneb with local (Exim 4.92) (envelope-from ) id 1iKR4l-0003rN-NX; Tue, 15 Oct 2019 18:57:39 +0100 From: Mike Crowe To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: Mike Crowe Subject: [PATCH v2 08/11] libstdc++ testsuite: Also test shared_timed_mutex with steady_clock Date: Tue, 15 Oct 2019 18:57:27 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 * testsuite/30_threads/shared_timed_mutex/try_lock/3.cc: Convert existing test to templated function so that it can be called with both system_clock and steady_clock. --- libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc b/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc index fd21033..1cf191c 100644 --- a/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc +++ b/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc @@ -27,7 +27,8 @@ #include #include -int main() +template +void test() { typedef std::shared_timed_mutex mutex_type; @@ -42,15 +43,15 @@ int main() { using namespace std::chrono; auto timeout = 100ms; - auto start = system_clock::now(); + auto start = clock_type::now(); b = m.try_lock_for(timeout); - auto t = system_clock::now() - start; + auto t = clock_type::now() - start; VERIFY( !b ); VERIFY( t >= timeout ); - start = system_clock::now(); + start = clock_type::now(); b = m.try_lock_until(start + timeout); - t = system_clock::now() - start; + t = clock_type::now() - start; VERIFY( !b ); VERIFY( t >= timeout ); } @@ -71,3 +72,9 @@ int main() VERIFY( false ); } } + +int main() +{ + test(); + test(); +}