Procházet zdrojové kódy

componnets: utest: fix case-name matching problem

There is a problem with the matching of case names
in the original code. Due to original code use memcmp
with len, if the input case name and the existing
case name have an inclusion relationship, for example,
if the actual case name is "gpip_irq", and run
`utest_run gpio` will also match successfully, but it's
not expected.

Modify the logic of exact matching and use strcmp instead.
Keep the original wildcard logic, that is,
`utest_run gpio*` can match both "gpio_irq" and "gpio".

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Chen Wang před 2 měsíci
rodič
revize
01ca3911ec
1 změnil soubory, kde provedl 6 přidání a 1 odebrání
  1. 6 1
      components/utilities/utest/utest.c

+ 6 - 1
components/utilities/utest/utest.c

@@ -217,8 +217,13 @@ static void utest_do_run(const char *utest_name)
                 if (utest_name[len - 1] == '*')
                 {
                     len -= 1;
+                    if (rt_memcmp(tc_table[i].name, utest_name, len) != 0)
+                    {
+                        i++;
+                        continue;
+                    }
                 }
-                if (rt_memcmp(tc_table[i].name, utest_name, len) != 0)
+                else if (rt_strcmp(tc_table[i].name, utest_name) != 0)
                 {
                     i++;
                     continue;