From patchwork Sun Oct 6 05:32:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2114 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 59A016196C for ; Sun, 6 Oct 2019 07:32:41 +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 B659FDD for ; Sun, 6 Oct 2019 07:32:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1570339961; bh=K4zCgQQ/cfTe4ehoUQ4IDib/z6/RbtUFOL7+XatkA0Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=M3ABP5AkNMoiyci+3ihzqGYP72CGeQRbI4ycDgGh4x5EBSRVi112SwYYEpnIUMIWv syLdV7yWRz55ZjoCTuLsFEeyxdrKwQvy8ymNbnRBZCL3a2YV9lwqjlKaybE18UbC44 7NAZesfOct/gMnRh1U5QJ9G6r9k8s8g9CSMK3OzM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 6 Oct 2019 08:32:26 +0300 Message-Id: <20191006053226.8976-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191006053226.8976-1-laurent.pinchart@ideasonboard.com> References: <20191006053226.8976-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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:32:41 -0000 Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- test/timer.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/timer.cpp b/test/timer.cpp index 5ff94dbbdeb0..93ce26a0a9a3 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.isRunning() || timer.jitter() > 50) { + cout << "Absolute timer test failed" << endl; + return TestFail; + } + /* Two timers. */ timer.start(1000); timer2.start(300);