From patchwork Sun Oct 6 05:42:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2115 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D2CB561565 for ; Sun, 6 Oct 2019 07:43:01 +0200 (CEST) Received: from pendragon.ideasonboard.com (modemcable151.96-160-184.mc.videotron.ca [184.160.96.151]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0539BDD for ; Sun, 6 Oct 2019 07:43:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1570340581; bh=QYJDNAQiNNwZsS8ceNKSWRJymrJOjv+NUJEQgOjHaXc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eW5EJR020t222g/yBW5pVUZ7C1wNI3cr6HVapseKdB/Erd12hP1yb3EEksnD+LLGa yyfNXPc0XJLIiaze3NA+ObUdp5jaWuJwqqiCF6HatLwJk7pBuK9rzCKbqIFLX80RFE iwV82X9bGdePljkGNSX74bOKidSRVJJmC6CTXKgc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 6 Oct 2019 08:42:55 +0300 Message-Id: <20191006054255.15655-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191006053226.8976-10-laurent.pinchart@ideasonboard.com> References: <20191006053226.8976-10-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1.1 9/9] test: timer: Test start() with absolute deadline X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Oct 2019 05:43:02 -0000 Signed-off-by: Laurent Pinchart --- test/timer.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/timer.cpp b/test/timer.cpp index 5ff94dbbdeb0..63e5a1d24041 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -35,6 +35,15 @@ public: Timer::start(msec); } + void start(std::chrono::steady_clock::time_point deadline) + { + count_ = 0; + start_ = std::chrono::steady_clock::now(); + expiration_ = std::chrono::steady_clock::time_point(); + + Timer::start(deadline); + } + int jitter() { std::chrono::steady_clock::duration duration = expiration_ - deadline(); @@ -127,6 +136,16 @@ protected: return TestFail; } + /* Timer with absolute deadline. */ + timer.start(std::chrono::steady_clock::now() + std::chrono::milliseconds(200)); + + dispatcher->processEvents(); + + if (timer.hasFailed()) { + cout << "Absolute timer test failed" << endl; + return TestFail; + } + /* Two timers. */ timer.start(1000); timer2.start(300);