From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107973 invoked by alias); 28 Sep 2019 08:48:38 -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 98045 invoked by uid 89); 28 Sep 2019 08:48:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT autolearn=ham version=3.3.1 spammy=rep X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 28 Sep 2019 08:48:27 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iE8Ot-0000As-8Y for gcc-patches@gcc.gnu.org; Sat, 28 Sep 2019 04:48:24 -0400 Received: from avasout06.plus.net ([212.159.14.18]:58346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iE8Os-00009E-Vw for gcc-patches@gcc.gnu.org; Sat, 28 Sep 2019 04:48:23 -0400 Received: from deneb ([80.229.24.9]) by smtp with ESMTP id E8LwikL01DGRHE8LxiiJKU; Sat, 28 Sep 2019 09:45:21 +0100 X-Clacks-Overhead: "GNU Terry Pratchett" X-CM-Score: 0.00 Received: from mac by deneb with local (Exim 4.92) (envelope-from ) id 1iE8Lf-0006SJ-03; Sat, 28 Sep 2019 09:45:03 +0100 From: Mike Crowe To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: Mike Crowe Subject: [PATCH 06/11] libstdc++ testsuite: Move slow_clock to its own header Date: Sat, 28 Sep 2019 08:48:00 -0000 Message-Id: <26a4c450153a0990134d6b234b5161123543a4ee.1569660153.git-series.mac@mcrowe.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 212.159.14.18 X-SW-Source: 2019-09/txt/msg01654.txt.bz2 Move slow_clock test class into a header file so that it can be used by other tests in the future. * testsuite/util/slow_clock.h: New file. Move implementation of slow_clock test class. * testsuite/30_threads/condition_variable/members/2.cc: Include slow_clock from header. --- libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc | 17 +---------------- libstdc++-v3/testsuite/util/slow_clock.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 libstdc++-v3/testsuite/util/slow_clock.h diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc index cbac3fa..f821d3f 100644 --- a/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc +++ b/libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc @@ -25,6 +25,7 @@ #include #include #include +#include template void test01() @@ -52,22 +53,6 @@ void test01() } } -struct slow_clock -{ - using rep = std::chrono::system_clock::rep; - using period = std::chrono::system_clock::period; - using duration = std::chrono::system_clock::duration; - using time_point = std::chrono::time_point; - static constexpr bool is_steady = false; - - static time_point now() - { - auto real = std::chrono::system_clock::now(); - return time_point{real.time_since_epoch() / 3}; - } -}; - - void test01_alternate_clock() { try diff --git a/libstdc++-v3/testsuite/util/slow_clock.h b/libstdc++-v3/testsuite/util/slow_clock.h new file mode 100644 index 0000000..13fc94b --- /dev/null +++ b/libstdc++-v3/testsuite/util/slow_clock.h @@ -0,0 +1,38 @@ +// -*- C++ -*- + +// Copyright (C) 2004-2019 Free Software Foundation, Inc. + +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 3, or (at +// your option) any later version. + +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + + +// A clock that ticks at a third of the speed of system_clock that can be used +// to ensure that functions with timeouts don't erroneously return early. + +#include + +struct slow_clock +{ + using rep = std::chrono::system_clock::rep; + using period = std::chrono::system_clock::period; + using duration = std::chrono::system_clock::duration; + using time_point = std::chrono::time_point; + static constexpr bool is_steady = false; + + static time_point now() + { + auto real = std::chrono::system_clock::now(); + return time_point{real.time_since_epoch() / 3}; + } +}; -- git-series 0.9.1