From patchwork Wed Apr 19 13:29:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Hiler X-Patchwork-Id: 9687453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BAB30602C9 for ; Wed, 19 Apr 2017 13:29:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABFB628395 for ; Wed, 19 Apr 2017 13:29:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A061E28418; Wed, 19 Apr 2017 13:29:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 55FB128395 for ; Wed, 19 Apr 2017 13:29:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B05A96E07B; Wed, 19 Apr 2017 13:29:30 +0000 (UTC) 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 ESMTPS id 18D8C6E07B for ; Wed, 19 Apr 2017 13:29:30 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Apr 2017 06:29:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,221,1488873600"; d="scan'208";a="958725982" Received: from ahiler-desk.igk.intel.com ([172.28.171.131]) by orsmga003.jf.intel.com with ESMTP; 19 Apr 2017 06:29:28 -0700 From: Arkadiusz Hiler To: intel-gfx@lists.freedesktop.org Date: Wed, 19 Apr 2017 15:29:25 +0200 Message-Id: <20170419132925.3266-1-arkadiusz.hiler@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <87inm0twke.fsf@intel.com> References: <87inm0twke.fsf@intel.com> Organization: Intel Technology Poland sp. z o.o. - KRS 101882 - ul. Slowackiego 173, 80-298 Gdansk Subject: [Intel-gfx] [PATCH i-g-t v2] lib/igt_aux: Make procps optional X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Android does not have procps and it's not easy to compile it as a dependency. We can provide alternative, "naive" implementation that just shells out to external commands (i.e. pkill and lsof) in case we do not have the library. v2: do not ifdef insides of functions (J. Nikula) Cc: Jani Nikula Signed-off-by: Arkadiusz Hiler --- configure.ac | 6 +++++- lib/igt_aux.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 12b0ab0..a5a92d5 100644 --- a/configure.ac +++ b/configure.ac @@ -123,7 +123,11 @@ AC_SUBST(ASSEMBLER_WARN_CFLAGS) PKG_CHECK_MODULES(DRM, [libdrm]) PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10]) PKG_CHECK_MODULES(KMOD, [libkmod]) -PKG_CHECK_MODULES(PROCPS, [libprocps]) +PKG_CHECK_MODULES(PROCPS, [libprocps], [procps=yes], [procps=no]) +AM_CONDITIONAL(HAVE_PROCPS, [test "x$procps" = xyes]) +if test x"$procps" = xyes; then + AC_DEFINE(HAVE_PROCPS,1,[Enable process managment without shelling out]) +fi PKG_CHECK_MODULES(VALGRIND, [valgrind], [have_valgrind=yes], [have_valgrind=no]) if test x$have_valgrind = xyes; then diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 2ec6b78..3695fa5 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -50,9 +50,7 @@ #include #include #include - -#include - +#include #include "drmtest.h" #include "i915_drm.h" #include "intel_chipset.h" @@ -71,6 +69,10 @@ #include /* for dirname() */ #endif +#ifdef HAVE_PROCPS +#include +#endif + /** * SECTION:igt_aux * @short_description: Auxiliary libraries and support functions @@ -1281,6 +1283,7 @@ void igt_set_module_param_int(const char *name, int val) igt_set_module_param(name, str); } +#ifdef HAVE_PROCPS /** * igt_terminate_process: * @sig: Signal to send @@ -1317,7 +1320,18 @@ int igt_terminate_process(int sig, const char *comm) closeproc(proc); return err; } +#else /* HAVE_PROCPS */ +#warning "No procps, using naive implementatio of igt_terminate_process" +int igt_terminate_process(int sig, const char *comm) +{ + char pkill_cmd[NAME_MAX]; + snprintf(pkill_cmd, sizeof(pkill_cmd), "pkill -x -%d %s", sig, comm); + return system(pkill_cmd); +} +#endif /* HAVE_PROCPS */ + +#ifdef HAVE_PROCPS struct pinfo { pid_t pid; const char *comm; @@ -1531,6 +1545,18 @@ igt_lsof(const char *dpath) free(sanitized); } +#else /* HAVE_PROCPS */ +#warning "No procps, using naive implementatio of igt_lsof" + +void +igt_lsof(const char *dpath) +{ + char lsof_cmd[NAME_MAX]; + snprintf(lsof_cmd, sizeof(lsof_cmd), "lsof +d %s", dpath); + system(lsof_cmd); + +} +#endif /* HAVE_PROCPS */ static struct igt_siglatency { timer_t timer;