From patchwork Tue Sep 10 09:04:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1955 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C8D560BCF for ; Tue, 10 Sep 2019 11:04:26 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8CBEB54A; Tue, 10 Sep 2019 11:04:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1568106265; bh=2x7rlLvn5jUG9FQq4tmlXuHgNXRG2mXOyVonii+cnu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jHCzExoUMR+DBHv1UoHTq8U2Fy4iyAkSxo+VDhKqGXPJ5xN/krJEq1DOrm2PvRT+3 iaYLH5fc3tkGIrAAO1qp5RghPJxYsmJEk3Nw+hYPxG394/X7tztWHN3qtfq3h7+Sq0 d8Tefi+DBhS11hDZCxdYaQWHH2BhsFGlhTPq3AAE= From: Kieran Bingham To: LibCamera Devel Date: Tue, 10 Sep 2019 10:04:16 +0100 Message-Id: <20190910090418.30502-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190910090418.30502-1-kieran.bingham@ideasonboard.com> References: <20190910090418.30502-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] test: process: Fix forking race X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Sep 2019 09:04:26 -0000 The procFinished event handler is registered after the process is started, leading to the opportunity of a missed race. Register the handler before the process is launched. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Laurent Pinchart --- test/process/process_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp index d264555e545f..701f156b5053 100644 --- a/test/process/process_test.cpp +++ b/test/process/process_test.cpp @@ -47,12 +47,13 @@ protected: int exitCode = 42; vector args; args.push_back(to_string(exitCode)); + proc_.finished.connect(this, &ProcessTest::procFinished); + int ret = proc_.start("/proc/self/exe", args); if (ret) { cerr << "failed to start process" << endl; return TestFail; } - proc_.finished.connect(this, &ProcessTest::procFinished); timeout.start(100); while (timeout.isRunning()) From patchwork Tue Sep 10 09:04:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1956 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D45A60BCF for ; Tue, 10 Sep 2019 11:04:26 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D6CDCBB9; Tue, 10 Sep 2019 11:04:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1568106266; bh=ngFkpqmcfqibqup+BaoOoYotHpofc0VDc/8GMef3HQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vGwUQ24eUIqLiTleRZfJxdESbHtF0gp2Z4YzV4fouNy9uyzH1SD2wjQ7+Lv/PSY3e ZHxLE+BocYe0EC57yGhARfTt6KI758ufZ+GFWgTTWdftqrv1sE3UWci5a+JFIGjK2y khAtgxUG0dsxuW+7vJi84DYi2tmmT+lir1/QgYWg= From: Kieran Bingham To: LibCamera Devel Date: Tue, 10 Sep 2019 10:04:17 +0100 Message-Id: <20190910090418.30502-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190910090418.30502-1-kieran.bingham@ideasonboard.com> References: <20190910090418.30502-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] test: process: Initialise member variables X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Sep 2019 09:04:26 -0000 The ProcessTest() declares member variables but leaves them unitialised. Set them appropriately from the constructor. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- test/process/process_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp index 701f156b5053..f3cabe0a36c7 100644 --- a/test/process/process_test.cpp +++ b/test/process/process_test.cpp @@ -35,6 +35,7 @@ class ProcessTest : public Test { public: ProcessTest() + : exitStatus_(Process::NotExited), exitCode_(-1) { } From patchwork Tue Sep 10 09:04:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1957 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9183C60BCF for ; Tue, 10 Sep 2019 11:04:26 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 36F44DAD; Tue, 10 Sep 2019 11:04:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1568106266; bh=5rcwvtbiWsOCeHPp+GvhSqGv0opTRe9bziOjq8I6b0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YcoUUZ5ybevk+xRRv3KeWN1PrSsmxHoqdETdzjN6enEgjdW26c1ipa49E8/V3MuEa EjcyZVeoWJAHK6rH+Svh4019Z3mA+reRlxXfW8amNhnBn5Xnh4DgysrOSKTqkqp7x0 PiJuS8CguU9XPJDb6cr6WofeBueWxSCd936StHvs= From: Kieran Bingham To: LibCamera Devel Date: Tue, 10 Sep 2019 10:04:18 +0100 Message-Id: <20190910090418.30502-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190910090418.30502-1-kieran.bingham@ideasonboard.com> References: <20190910090418.30502-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] test: process: Extend timeout duration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Sep 2019 09:04:26 -0000 The process test runs for just 100mS. The spawned process runs for at least 50mS. Ordinarily this should allow plenty of time for both the process to be spawned and run, but when adding extra debug instrumentation, the processes can be slowed down, leading to a false negative test failure. Extend the timeout to 2 seconds to allow the short process to be run correctly - but use the now initialised exitStatus_ to exit the event loop as soon as the process has completed. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- test/process/process_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp index f3cabe0a36c7..7e7b3c2c8bf3 100644 --- a/test/process/process_test.cpp +++ b/test/process/process_test.cpp @@ -56,8 +56,8 @@ protected: return TestFail; } - timeout.start(100); - while (timeout.isRunning()) + timeout.start(2000); + while (timeout.isRunning() && exitStatus_ == Process::NotExited) dispatcher->processEvents(); if (exitStatus_ != Process::NormalExit) {