From patchwork Wed Jan 29 00:25:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jeff.mcgee@intel.com X-Patchwork-Id: 3549281 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 571209F39C for ; Wed, 29 Jan 2014 00:18:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8CCDC20107 for ; Wed, 29 Jan 2014 00:18:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BFA2A20149 for ; Wed, 29 Jan 2014 00:18:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A31D106305; Tue, 28 Jan 2014 16:18:05 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 56F5B106300 for ; Tue, 28 Jan 2014 16:17:57 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 28 Jan 2014 16:17:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,739,1384329600"; d="scan'208";a="446104750" Received: from jeffdesk.fso.intel.com ([10.5.53.1]) by orsmga001.jf.intel.com with ESMTP; 28 Jan 2014 16:17:56 -0800 From: jeff.mcgee@intel.com To: intel-gfx@lists.freedesktop.org Date: Tue, 28 Jan 2014 18:25:04 -0600 Message-Id: <1390955106-29853-3-git-send-email-jeff.mcgee@intel.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1390955106-29853-1-git-send-email-jeff.mcgee@intel.com> References: <1390955106-29853-1-git-send-email-jeff.mcgee@intel.com> Subject: [Intel-gfx] [PATCH 2/4] lib/drmtest: Add igt_wait_helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff McGee igt_wait_helper compliments igt_stop_helper and is used when helper processes are expected to exit naturally. Signed-off-by: Jeff McGee --- lib/drmtest.c | 17 +++++++++++++++++ lib/drmtest.h | 1 + 2 files changed, 18 insertions(+) diff --git a/lib/drmtest.c b/lib/drmtest.c index 8bc70a3..d3d81a3 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -1241,6 +1241,23 @@ void igt_stop_helper(struct igt_helper_process *proc) helper_process_count--; } +void igt_wait_helper(struct igt_helper_process *proc) +{ + int status; + + assert(proc->running); + + while (waitpid(proc->pid, &status, 0) == -1 && + errno == EINTR) + ; + igt_assert(WIFEXITED(status) && WEXITSTATUS(status) == 0); + + proc->running = false; + + helper_process_pids[proc->id] = -1; + helper_process_count--; +} + static void children_exit_handler(int sig) { int ret; diff --git a/lib/drmtest.h b/lib/drmtest.h index d42a6f7..f945a7e 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -290,6 +290,7 @@ struct igt_helper_process { }; bool __igt_fork_helper(struct igt_helper_process *proc); void igt_stop_helper(struct igt_helper_process *proc); +void igt_wait_helper(struct igt_helper_process *proc); #define igt_fork_helper(proc) \ for (; __igt_fork_helper(proc); exit(0))