From patchwork Thu Feb 13 12:45:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2807 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 EF27F6043A for ; Thu, 13 Feb 2020 13:45:59 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8450C504 for ; Thu, 13 Feb 2020 13:45:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1581597959; bh=yTjfeCUuzzHClP8uKiPMr2KvanveOhM2krUNf7dyVFI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EGSev8OEUJ7Ntcp+BURwjRwWcJZOz9ecpQbZ12vl1/Z+6Qb/ZMHV7ZdZwJxSmpDXb ddwxfPVNcdiIaBgfYdf821T6wAJpS2yt9YwKXm9SiiLlTNB4dh2eN/Fl/F85c5jfwv mWjfMf3lZkiQ9DjrgTizEagKlzW8VBkUDBt0hCp4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 13 Feb 2020 14:45:38 +0200 Message-Id: <20200213124538.21556-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213124538.21556-1-laurent.pinchart@ideasonboard.com> References: <20200213124538.21556-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] test: thread: Test waiting on a thread that is not running 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: Thu, 13 Feb 2020 12:46:00 -0000 Test that Thread::wait() on a thread that hasn't been started, or on a thread that is known to have completed, returns without a timeout. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- test/threads.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/threads.cpp b/test/threads.cpp index 1fa26020ce5c..0454761de12c 100644 --- a/test/threads.cpp +++ b/test/threads.cpp @@ -101,6 +101,25 @@ protected: delete thread; + /* Test waiting on a thread that isn't running. */ + thread = new Thread(); + + timeout = !thread->wait(); + if (timeout) { + cout << "Waiting for non-started thread timed out" << endl; + return TestFail; + } + + thread->start(); + thread->exit(0); + thread->wait(); + + timeout = !thread->wait(); + if (timeout) { + cout << "Waiting for already stopped thread timed out" << endl; + return TestFail; + } + return TestPass; }