Skip to contentSkip to conversation

test: Allow simple glob pattern in the test name

PATCH New Andy Shevchenko 2 participants 11 messages Feb 3, 2021 – Feb 8, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

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*

---
 test/dm/test-main.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
test/dm/test-main.c +9 -3
index 69458d62c869..f15527e13d7b 100644
@@ -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;
Signature · 1 line
2.30.0
#1 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

Hi Andy,

Quoted 9 lines · Andy Shevchenko

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*

---
 test/dm/test-main.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

This seems like a good idea to me.

Can you please send it rebased to u-boot-dm/test-working though? I have done a bit of refactoring and this function is now in test/test-main.c

Regards,
Simon

#2 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

Quoted 12 lines · Simon Glass
Quoted 9 lines · Andy Shevchenko

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*

---
 test/dm/test-main.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Quoted 5 lines

This seems like a good idea to me.

Can you please send it rebased to u-boot-dm/test-working though? I have done a bit of refactoring and this function is now in test/test-main.c

I will look at it.

Btw, you have an issue there, i.e. if test case failed, all percentage after it goes red, which is wrong.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

Quoted 1 line · Andy Shevchenko

On Thu, Feb 04, 2021 at 08:17:24PM -0700, Simon Glass wrote:

...

Quoted 2 lines

Btw, you have an issue there, i.e. if test case failed, all percentage after it goes red, which is wrong.

One more thing, is it known bug that either in the original code, or in your new branch the following test case is 100% failed?

        /* Non-existent in DTB */
        ut_asserteq(FDT_ADDR_T_NONE, dev_read_addr(dev));

Can you fix this sooner than later, please?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

Quoted 8 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

On Thu, Feb 04, 2021 at 08:17:24PM -0700, Simon Glass wrote:

...

Quoted 2 lines

Btw, you have an issue there, i.e. if test case failed, all percentage after it goes red, which is wrong.

Quoted 7 lines

One more thing, is it known bug that either in the original code, or in your new branch the following test case is 100% failed?

        /* Non-existent in DTB */
        ut_asserteq(FDT_ADDR_T_NONE, dev_read_addr(dev));

Can you fix this sooner than later, please?

Another annoying issue is the 2+ run on uncleaned build folder, i.e. on the second and following runs it starts out of the sudden to ask my sudo password.

The later to me is a highest priority, now I have to run rm -rf build-sandbox each time, and if I forget - wasted time!

Can you fix this as soon as possible, please?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

On Thu, Feb 04, 2021 at 08:17:24PM -0700, Simon Glass wrote:

...

Quoted 2 lines

Btw, you have an issue there, i.e. if test case failed, all percentage after it goes red, which is wrong.

Quoted 7 lines

One more thing, is it known bug that either in the original code, or in your new branch the following test case is 100% failed?

        /* Non-existent in DTB */
        ut_asserteq(FDT_ADDR_T_NONE, dev_read_addr(dev));

Can you fix this sooner than later, please?

Actually it seems this very patch makes the issue visible (I suppose something with test case names).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

On Thu, Feb 04, 2021 at 08:17:24PM -0700, Simon Glass wrote:

...

Quoted 2 lines

Btw, you have an issue there, i.e. if test case failed, all percentage after it goes red, which is wrong.

One more thing, is it known bug that either in the original code, or in your new branch the following test case is 100% failed?

Quoted 7 lines
Quoted 4 lines
        /* Non-existent in DTB */
        ut_asserteq(FDT_ADDR_T_NONE, dev_read_addr(dev));

Can you fix this sooner than later, please?

Actually it seems this very patch makes the issue visible (I suppose something with test case names).

Okay, actually there *is* a problem with the test suite, i.e. you may not run some test cases twice during the same session.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

Hi Andy,

Quoted 17 lines · Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

On Thu, Feb 04, 2021 at 08:17:24PM -0700, Simon Glass wrote:

...

Quoted 2 lines

Btw, you have an issue there, i.e. if test case failed, all percentage after it goes red, which is wrong.

One more thing, is it known bug that either in the original code, or in your new branch the following test case is 100% failed?

        /* Non-existent in DTB */
        ut_asserteq(FDT_ADDR_T_NONE, dev_read_addr(dev));
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Can you fix this sooner than later, please?

Actually it seems this very patch makes the issue visible (I suppose something with test case names).

Okay, actually there *is* a problem with the test suite, i.e. you may not run some test cases twice during the same session.

If this is related to the squashfs tests? I have disabled them for now in my local tree.

Regards,
Simon

#8 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

Quoted 20 lines · Simon Glass
Quoted 18 lines · Andy Shevchenko
Quoted 17 lines · Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

On Thu, Feb 04, 2021 at 08:17:24PM -0700, Simon Glass wrote:

...

Quoted 2 lines

Btw, you have an issue there, i.e. if test case failed, all percentage after it goes red, which is wrong.

One more thing, is it known bug that either in the original code, or in your new branch the following test case is 100% failed?

        /* Non-existent in DTB */
        ut_asserteq(FDT_ADDR_T_NONE, dev_read_addr(dev));

Can you fix this sooner than later, please?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Actually it seems this very patch makes the issue visible (I suppose something with test case names).

Okay, actually there *is* a problem with the test suite, i.e. you may not run some test cases twice during the same session.

If this is related to the squashfs tests? I have disabled them for now in my local tree.

I don't think it's related to the certain test case, it's a test suite design issue and how some of the test cases have been written. So, if you run u-boot application and manually run ut dm in there,
- first time: Failures: 0
- second time: Failures: 9
- third and next time: Failures: 12

Means that 12 test cases are written badly.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

Hi Andy,

Quoted 31 lines · Andy Shevchenko
Quoted 20 lines · Simon Glass
Quoted 18 lines · Andy Shevchenko
Quoted 17 lines · Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

On Thu, Feb 04, 2021 at 08:17:24PM -0700, Simon Glass wrote:

...

Quoted 2 lines

Btw, you have an issue there, i.e. if test case failed, all percentage after it goes red, which is wrong.

One more thing, is it known bug that either in the original code, or in your new branch the following test case is 100% failed?

        /* Non-existent in DTB */
        ut_asserteq(FDT_ADDR_T_NONE, dev_read_addr(dev));

Can you fix this sooner than later, please?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Actually it seems this very patch makes the issue visible (I suppose something with test case names).

Okay, actually there *is* a problem with the test suite, i.e. you may not run some test cases twice during the same session.

If this is related to the squashfs tests? I have disabled them for now in my local tree.

Quoted 6 lines

I don't think it's related to the certain test case, it's a test suite design issue and how some of the test cases have been written. So, if you run u-boot application and manually run ut dm in there,
- first time: Failures: 0
- second time: Failures: 9
- third and next time: Failures: 12

Means that 12 test cases are written badly.

OK I see. It did not use to be possible to pass all tests without running through pytest, which does some setup. You still need to create a 'spi.bin' file for the SPI tests to pass.

I'm not sure what prevents multiple runs without quitting U-Boot, but I suspect it is just some state hanging around, as we don't reset everything. For example, sandbox provides control of what happens when a sysreset is performed, and perhaps that is not reset to initial values correct by state_reset_for_test()..

Regards,
Simon

#10 lore raw

PATCH 1/1 test: Allow simple glob pattern in the test name

Quoted 37 lines · Simon Glass
Quoted 35 lines · Andy Shevchenko
Quoted 20 lines · Simon Glass
Quoted 18 lines · Andy Shevchenko
Quoted 17 lines · Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

On Thu, Feb 04, 2021 at 08:17:24PM -0700, Simon Glass wrote:

...

Quoted 2 lines

Btw, you have an issue there, i.e. if test case failed, all percentage after it goes red, which is wrong.

One more thing, is it known bug that either in the original code, or in your new branch the following test case is 100% failed?

        /* Non-existent in DTB */
        ut_asserteq(FDT_ADDR_T_NONE, dev_read_addr(dev));

Can you fix this sooner than later, please?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Actually it seems this very patch makes the issue visible (I suppose something with test case names).

Okay, actually there *is* a problem with the test suite, i.e. you may not run some test cases twice during the same session.

If this is related to the squashfs tests? I have disabled them for now in my local tree.

I don't think it's related to the certain test case, it's a test suite design issue and how some of the test cases have been written. So, if you run u-boot application and manually run ut dm in there,
- first time: Failures: 0
- second time: Failures: 9
- third and next time: Failures: 12

Quoted 5 lines
Quoted 1 line

Means that 12 test cases are written badly.

OK I see. It did not use to be possible to pass all tests without running through pytest, which does some setup. You still need to create a 'spi.bin' file for the SPI tests to pass.

I run it _after_ the official pytest passed. So, every file is prepared.

Quoted 5 lines

I'm not sure what prevents multiple runs without quitting U-Boot, but I suspect it is just some state hanging around, as we don't reset everything. For example, sandbox provides control of what happens when a sysreset is performed, and perhaps that is not reset to initial values correct by state_reset_for_test()..

I believe this is the case in most of the cases.

Signature · 2 lines
With Best Regards,
Andy Shevchenko