From patchwork Mon Jul 27 12:53:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9016 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 617A3BD878 for ; Mon, 27 Jul 2020 12:53:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E2A4B61253; Mon, 27 Jul 2020 14:53:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Btgk82qm"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 79286605B2 for ; Mon, 27 Jul 2020 14:53:28 +0200 (CEST) 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 D94A1556; Mon, 27 Jul 2020 14:53:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1595854408; bh=CD8CVUiZ0udeYoSpTg2cA84GaYb9xPqX3XgXp1pFhy4=; h=From:To:Cc:Subject:Date:From; b=Btgk82qmh23NeR/gZ6BrSHiYMT8pvVggLArIwijGbrlx+0ozYq7qFKVuXcS/rGERp xGgIYePf9Mdp/tdjHZ4ZJ+aLiZSVmXjFNP0kbXQGrWY1wJtyTgZJOb3NsJnTya4el2 HfBtqfyxIWltMw5p4hCwOZPnFQ72Jp/z8u2YLTJc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Jul 2020 15:53:17 +0300 Message-Id: <20200727125317.23680-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] test: process: Test Process::kill() 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: , Cc: You-Sheng Yang Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a test to ensure that Process::kill() on an unstarted process is safe. This aims at ensuring we don't kill other processes unexpectedly. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- test/process/process_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) If you want to try this at home *without* the corresponding fix to the Process class ("libcamera: process: Fix killing innocent processes unexpectedly"), make sure to save all your work first. It's a very effective implementation of an ejection seat. diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp index ce0cc7c972cd..721a7c9d46ff 100644 --- a/test/process/process_test.cpp +++ b/test/process/process_test.cpp @@ -51,6 +51,10 @@ protected: args.push_back(to_string(exitCode)); proc_.finished.connect(this, &ProcessTest::procFinished); + /* Test that kill() on an unstarted process is safe. */ + proc_.kill(); + + /* Test starting the process and retrieving the exit code. */ int ret = proc_.start("/proc/self/exe", args); if (ret) { cerr << "failed to start process" << endl;