All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Arkadiusz Hiler <arkadiusz.hiler@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH i-g-t 04/13] lib/igt_aux: Make procps optional
Date: Wed, 19 Apr 2017 15:24:01 +0300	[thread overview]
Message-ID: <87inm0twke.fsf@intel.com> (raw)
In-Reply-To: <20170419110155.6828-5-arkadiusz.hiler@intel.com>

On Wed, 19 Apr 2017, Arkadiusz Hiler <arkadiusz.hiler@intel.com> wrote:
> 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.
>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> ---
>  configure.ac  |  6 +++++-
>  lib/igt_aux.c | 24 +++++++++++++++++++++---
>  2 files changed, 26 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..4efb45b 100644
> --- a/lib/igt_aux.c
> +++ b/lib/igt_aux.c
> @@ -50,9 +50,7 @@
>  #include <sys/utsname.h>
>  #include <termios.h>
>  #include <assert.h>
> -
> -#include <proc/readproc.h>
> -
> +#include <linux/limits.h>
>  #include "drmtest.h"
>  #include "i915_drm.h"
>  #include "intel_chipset.h"
> @@ -71,6 +69,10 @@
>  #include <libgen.h>   /* for dirname() */
>  #endif
>  
> +#ifdef HAVE_PROCPS
> +#include <proc/readproc.h>
> +#endif
> +
>  /**
>   * SECTION:igt_aux
>   * @short_description: Auxiliary libraries and support functions
> @@ -1295,6 +1297,7 @@ void igt_set_module_param_int(const char *name, int val)
>   */
>  int igt_terminate_process(int sig, const char *comm)
>  {
> +#ifdef HAVE_PROCPS

Please move ifdefs *outside* the functions, and add another function for
the !HAVE_PROCPS branch.

Same below.

BR,
Jani.

>  	PROCTAB *proc;
>  	proc_t *proc_info;
>  	int err = 0;
> @@ -1316,6 +1319,12 @@ int igt_terminate_process(int sig, const char *comm)
>  
>  	closeproc(proc);
>  	return err;
> +#else
> +#warning "No procps, using naive implementation of igt_terminate_process"
> +	char pkill_cmd[NAME_MAX];
> +	snprintf(pkill_cmd, sizeof(pkill_cmd), "pkill -x -%d %s", sig, comm);
> +	return system(pkill_cmd);
> +#endif
>  }
>  
>  struct pinfo {
> @@ -1324,6 +1333,7 @@ struct pinfo {
>  	const char *fn;
>  };
>  
> +#ifdef HAVE_PROCPS
>  static void
>  __igt_show_stat(struct pinfo *info)
>  {
> @@ -1499,6 +1509,7 @@ __igt_lsof(const char *dir)
>  
>  	closeproc(proc);
>  }
> +#endif
>  
>  /**
>   * igt_lsof: Lists information about files opened by processes.
> @@ -1510,6 +1521,7 @@ __igt_lsof(const char *dir)
>  void
>  igt_lsof(const char *dpath)
>  {
> +#ifdef HAVE_PROCPS
>  	struct stat st;
>  	size_t len = strlen(dpath);
>  	char *sanitized;
> @@ -1530,6 +1542,12 @@ igt_lsof(const char *dpath)
>  	__igt_lsof(sanitized);
>  
>  	free(sanitized);
> +#else
> +#warning "No procps, using naive implementation of igt_lsof"
> +	char lsof_cmd[NAME_MAX];
> +	snprintf(lsof_cmd, sizeof(lsof_cmd), "lsof +d %s", dpath);
> +	system(lsof_cmd);
> +#endif
>  }
>  
>  static struct igt_siglatency {

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-04-19 12:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19 11:01 [PATCH i-g-t 00/13] Fix IGTs for Android Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 01/13] tests/drm_import_export: Include {i915_, }drm.h properly Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 02/13] Make conditions on HAVE_UDEV consistent Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 03/13] lib/igt_aux: Include unistd.h for gettid() on Android Arkadiusz Hiler
2017-04-19 12:22   ` Jani Nikula
2017-04-19 14:02     ` Arkadiusz Hiler
2017-04-19 14:23       ` Jani Nikula
2017-04-20 10:33         ` Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 04/13] lib/igt_aux: Make procps optional Arkadiusz Hiler
2017-04-19 12:24   ` Jani Nikula [this message]
2017-04-19 13:29     ` [PATCH i-g-t v2] " Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 05/13] chamelium: Fix build issues on Android Arkadiusz Hiler
2017-05-02  9:53   ` Petri Latvala
2017-05-05 11:46     ` Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 06/13] tools/Android.mk: Add guc_logger and l3_parity skip list Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 07/13] tests/Android.mk: Add perf to " Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 08/13] benchmarks/Android.mk: Add gem_latency " Arkadiusz Hiler
2017-04-19 16:58   ` Chris Wilson
2017-04-20 10:18     ` Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 09/13] Android.mk: Fix libkmod use Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 10/13] Android.mk: Filter out *.h from src files Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 11/13] Android.mk: Use drm stubs Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 12/13] tools/Android.mk: Fix zlib inclusion Arkadiusz Hiler
2017-04-19 11:01 ` [PATCH i-g-t 13/13] tests/gem_exec_nop: Disable headless subtest on cairoless Android Arkadiusz Hiler
2017-05-04  8:00   ` Petri Latvala
2017-05-05 11:47     ` Arkadiusz Hiler
  -- strict thread matches above, loose matches on Subject: below --
2017-05-16 13:24 [PATCH i-g-t v2 00/13] Fix IGTs for Android Arkadiusz Hiler
2017-05-16 13:24 ` [PATCH i-g-t 04/13] lib/igt_aux: Make procps optional Arkadiusz Hiler
2017-05-16 13:50   ` Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87inm0twke.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=arkadiusz.hiler@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.