From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 2/4] test: Allow simple glob pattern in the test name
Date: Thu, 11 Feb 2021 16:40:10 +0200 [thread overview]
Message-ID: <20210211144012.55676-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20210211144012.55676-1-andriy.shevchenko@linux.intel.com>
When run `ut dm [test name]` allow to use simple pattern to run all tests
started with given prefix. For example, to run all ACPI test cases:
ut dm acpi*
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: rebased against dm/test-working branch (Simon)
test/test-main.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/test/test-main.c b/test/test-main.c
index e1b49e091ab6..8fcbc2361214 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -128,10 +128,17 @@ static bool ut_test_run_on_flattree(struct unit_test *test)
static bool test_matches(const char *prefix, const char *test_name,
const char *select_name)
{
+ size_t len;
+
if (!select_name)
return true;
- if (!strcmp(test_name, select_name))
+ /* Allow glob expansion in the test name */
+ len = select_name[strlen(select_name) - 1] == '*' ? strlen(select_name) : 0;
+ if (len-- == 1)
+ return true;
+
+ if (!strncmp(test_name, select_name, len))
return true;
if (!prefix) {
@@ -146,7 +153,7 @@ static bool test_matches(const char *prefix, const char *test_name,
test_name += strlen(prefix);
}
- if (!strcmp(test_name, select_name))
+ if (!strncmp(test_name, select_name, len))
return true;
return false;
--
2.30.0
next prev parent reply other threads:[~2021-02-11 14:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 14:40 [PATCH v2 1/4] test: Include /sbin to the PATH when creating ext4 disk image Andy Shevchenko
2021-02-11 14:40 ` Andy Shevchenko [this message]
2021-02-18 4:45 ` [PATCH v2 2/4] test: Allow simple glob pattern in the test name Simon Glass
2021-04-29 16:03 ` Simon Glass
2021-02-11 14:40 ` [PATCH v2 3/4] test: Use positive conditional in test_matches() Andy Shevchenko
2021-02-18 4:45 ` Simon Glass
2021-04-29 16:03 ` Simon Glass
2021-02-11 14:40 ` [PATCH v2 4/4] test: Don't unmount not (yet) mounted system Andy Shevchenko
2021-02-18 4:45 ` Simon Glass
2021-02-18 10:55 ` Andy Shevchenko
2021-02-19 4:52 ` Simon Glass
2021-03-30 19:41 ` Andy Shevchenko
2021-03-30 19:53 ` Tom Rini
2021-03-30 21:50 ` Andy Shevchenko
2021-03-31 13:47 ` Tom Rini
2021-05-13 11:32 ` Heinrich Schuchardt
2021-05-17 6:36 ` Andy Shevchenko
2021-02-11 14:46 ` [PATCH v2 1/4] test: Include /sbin to the PATH when creating ext4 disk image Andy Shevchenko
2021-02-18 4:45 ` Simon Glass
2021-03-15 13:59 ` Andy Shevchenko
2021-03-18 16:56 ` Tom Rini
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=20210211144012.55676-2-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox