All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>,
	igt-dev@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t v2 1/4] run-tests.sh: allow to run without sudo
Date: Fri, 20 Apr 2018 14:00:30 +0300	[thread overview]
Message-ID: <87fu3qdtwx.fsf@intel.com> (raw)
In-Reply-To: <20180315005910.18808-2-lucas.demarchi@intel.com>

On Wed, 14 Mar 2018, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
> If the script is already running as root, it doens't need to be
> executed through sudo. This also moves the calls to exec piglit to a
> common function.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  scripts/run-tests.sh | 23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh
> index a98e06ce..1c3f2805 100755
> --- a/scripts/run-tests.sh
> +++ b/scripts/run-tests.sh
> @@ -44,6 +44,21 @@ function download_piglit {
>  	git clone git://anongit.freedesktop.org/piglit "$ROOT/piglit"
>  }
>  
> +function run_piglit # as-root <args>
> +{
> +	local need_root=$1
> +	shift
> +	local sudo
> +
> +	export IGT_TEST_ROOT IGT_CONFIG_PATH
> +
> +	if [ "$need_root" -ne 0 -a "$EUID" -ne 0 ]; then
> +		sudo="sudo --preserve-env=IGT_TEST_ROOT,IGT_CONFIG_PATH"
> +	fi

sudo: option '--preserve-env' doesn't allow an argument

$ sudo --version
Sudo version 1.8.19p1

BR,
Jani.

> +
> +	$sudo $PIGLIT "$@"
> +}
> +
>  function print_help {
>  	echo "Usage: run-tests.sh [options]"
>  	echo "Available options:"
> @@ -111,18 +126,18 @@ if [ ! -x "$PIGLIT" ]; then
>  fi
>  
>  if [ "x$LIST_TESTS" != "x" ]; then
> -	IGT_TEST_ROOT="$IGT_TEST_ROOT" IGT_CONFIG_PATH="$IGT_CONFIG_PATH" "$PIGLIT" print-cmd --format "{name}" igt
> +	run_piglit 0 print-cmd --format "{name}" igt
>  	exit
>  fi
>  
>  if [ "x$RESUME" != "x" ]; then
> -	sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" IGT_CONFIG_PATH="$IGT_CONFIG_PATH" "$PIGLIT" resume "$RESULTS" $NORETRY
> +	run_piglit 1 resume "$RESULTS" $NORETRY
>  else
>  	mkdir -p "$RESULTS"
> -	sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" IGT_CONFIG_PATH="$IGT_CONFIG_PATH" "$PIGLIT" run igt --ignore-missing -o "$RESULTS" -s $VERBOSE $EXCLUDE $FILTER
> +	run_piglit 1 run igt --ignore-missing -o "$RESULTS" -s $VERBOSE $EXCLUDE $FILTER
>  fi
>  
>  if [ "$SUMMARY" == "html" ]; then
> -	"$PIGLIT" summary html --overwrite "$RESULTS/html" "$RESULTS"
> +	run_piglit 0 summary html --overwrite "$RESULTS/html" "$RESULTS"
>  	echo "HTML summary has been written to $RESULTS/html/index.html"
>  fi

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

  parent reply	other threads:[~2018-04-20 10:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15  0:59 [igt-dev] [PATCH i-g-t v2 0/4] run-tests.sh improvements Lucas De Marchi
2018-03-15  0:59 ` [igt-dev] [PATCH i-g-t v2 1/4] run-tests.sh: allow to run without sudo Lucas De Marchi
2018-03-15 11:44   ` Petri Latvala
2018-04-20 11:00   ` Jani Nikula [this message]
2018-04-20 16:11     ` Lucas De Marchi
2018-03-15  0:59 ` [igt-dev] [PATCH i-g-t v2 2/4] run-tests.sh: allow relative IGT_TEST_ROOT and IGT_CONFIG_PATH Lucas De Marchi
2018-03-15 11:44   ` Petri Latvala
2018-03-15  0:59 ` [igt-dev] [PATCH i-g-t v2 3/4] README: clarify comment about tests Lucas De Marchi
2018-03-15 11:47   ` Petri Latvala
2018-03-15  0:59 ` [igt-dev] [PATCH i-g-t v2 4/4] run-tests.sh: use meson build by default Lucas De Marchi
2018-03-15 11:50   ` Petri Latvala
2018-03-20 21:45     ` Lucas De Marchi
2018-03-21 11:16       ` Petri Latvala
2018-03-15  1:20 ` [igt-dev] ✓ Fi.CI.BAT: success for run-tests.sh improvements (rev2) Patchwork
2018-03-15  3:48 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork
2018-03-15 12:00 ` [igt-dev] [PATCH i-g-t v2 0/4] run-tests.sh improvements Arkadiusz Hiler

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=87fu3qdtwx.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    /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.