All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH RFC 1/4] lib/tst_test.c: add 'needs_drivers' option with tst_check_drivers cmd
Date: Thu, 16 Aug 2018 12:59:35 +0200	[thread overview]
Message-ID: <20180816105934.GA4829@rei> (raw)
In-Reply-To: <1533828226-24753-1-git-send-email-alexey.kodanev@oracle.com>

Hi!
> diff --git a/include/tst_test.h b/include/tst_test.h
> index 98dacf3..221796d 100644
> --- a/include/tst_test.h
> +++ b/include/tst_test.h
> @@ -170,6 +170,9 @@ struct tst_test {
>  
>  	/* NULL terminated array of resource file names */
>  	const char *const *resource_files;
> +
> +	/* NULL terminated array of needed kernel drivers */
> +	const char * const *needs_drivers;
>  };
>  
>  /*
> @@ -219,6 +222,8 @@ const char *tst_strstatus(int status);
>  
>  void tst_set_timeout(int timeout);
>  
> +int tst_check_drivers(void);
> +
>  #ifndef TST_NO_DEFAULT_MAIN
>  
>  static struct tst_test test;
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 2f3d357..6cb74cf 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -645,6 +645,29 @@ static int needs_tmpdir(void)
>  	       tst_test->needs_checkpoints;
>  }
>  
> +int tst_check_drivers(void)
> +{
> +	const char *name;
> +	int i, res;
> +
> +	for (i = 0; (name = tst_test->needs_drivers[i]); ++i) {
> +		const char * const argv[] = { "modprobe", name, NULL };
> +
> +		res = tst_run_cmd_(NULL, argv, "/dev/null", "/dev/null", 1);
> +		if (res == 255)
> +			return res; /* it looks like modprobe not available */
> +		if (res) {
> +			if (tst_test->test || tst_test->test_all) {
> +				tst_brk(TCONF, "%s driver not available", name);
> +			} else {
> +				fprintf(stderr, "%s", name);
> +				return res;
> +			}
> +		}
> +	}
> +	return 0;
> +}

I do not like much that we change the behavir based on tst_test content.
Maybe it would be cleaner to define a tst_check_driver(const char *name),
then we can do the loop over tst_test->needs_drivers in the tst_test.c
library and loop over argv in the shell helper.

-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2018-08-16 10:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 15:23 [LTP] [PATCH RFC 1/4] lib/tst_test.c: add 'needs_drivers' option with tst_check_drivers cmd Alexey Kodanev
2018-08-09 15:23 ` [LTP] [PATCH RFC 2/4] lib/tst_test.sh: add TST_NEEDS_DRIVERS parameter Alexey Kodanev
2018-08-14 17:11   ` Petr Vorel
2018-08-16  8:54   ` Petr Vorel
2018-08-16 11:49     ` Alexey Kodanev
2018-08-09 15:23 ` [LTP] [PATCH RFC 3/4] lib/tst_test.sh: add TST_RTNL_CHK() helper function Alexey Kodanev
2018-08-14 18:39   ` Petr Vorel
2018-08-09 15:23 ` [LTP] [PATCH RFC 4/4] network/ipsec: replace ipsec_try() with TST_RTNL_CHK() Alexey Kodanev
2018-08-14 18:40   ` Petr Vorel
2018-08-16 11:16   ` [LTP] [RFC PATCH 2/2] netstress: Update help for -m behavior Petr Vorel
2018-08-16 12:01     ` Alexey Kodanev
2018-08-16 11:42   ` [LTP] [PATCH v2 1/1] network/route: Rewrite route-change-dst into new API Petr Vorel
2018-08-14 17:06 ` [LTP] [PATCH RFC 1/4] lib/tst_test.c: add 'needs_drivers' option with tst_check_drivers cmd Petr Vorel
2018-08-15 15:22   ` Alexey Kodanev
2018-08-16 10:59 ` Cyril Hrubis [this message]
2018-08-16 11:54   ` Alexey Kodanev
2018-08-16 11:53     ` Petr Vorel
2018-08-16 12:21       ` Alexey Kodanev

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=20180816105934.GA4829@rei \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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.