public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [PATCH v1] test: Allow simple glob pattern in the test name
Date: Wed,  3 Feb 2021 17:32:34 +0200	[thread overview]
Message-ID: <20210203153234.18866-1-andriy.shevchenko@linux.intel.com> (raw)

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>
---
 test/dm/test-main.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 69458d62c869..f15527e13d7b 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -129,17 +129,23 @@ static bool dm_test_run_on_flattree(struct unit_test *test)
 
 static bool test_matches(const char *test_name, const char *find_name)
 {
-	if (!find_name)
+	size_t len = find_name ? strlen(find_name) : 0;
+
+	/* Allow glob expansion in the test name */
+	if (len && find_name[len - 1] == '*')
+		len--;
+
+	if (!len)
 		return true;
 
-	if (!strcmp(test_name, find_name))
+	if (!strncmp(test_name, find_name, len))
 		return true;
 
 	/* All tests have this prefix */
 	if (!strncmp(test_name, "dm_test_", 8))
 		test_name += 8;
 
-	if (!strcmp(test_name, find_name))
+	if (!strncmp(test_name, find_name, len))
 		return true;
 
 	return false;
-- 
2.30.0

             reply	other threads:[~2021-02-03 15:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-03 15:32 Andy Shevchenko [this message]
2021-02-05  3:17 ` [PATCH v1] test: Allow simple glob pattern in the test name Simon Glass
2021-02-05 17:34   ` Andy Shevchenko
2021-02-05 18:15     ` Andy Shevchenko
2021-02-05 18:18       ` Andy Shevchenko
2021-02-05 19:17       ` Andy Shevchenko
2021-02-05 20:46         ` Andy Shevchenko
2021-02-07 14:37           ` Simon Glass
2021-02-08 11:34             ` Andy Shevchenko
2021-02-08 17:07               ` Simon Glass
2021-02-08 17:34                 ` Andy Shevchenko

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=20210203153234.18866-1-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