Skip to content

Commit 01ca391

Browse files
unicornxRbb666
authored andcommitted
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 <[email protected]>
1 parent cec2dbd commit 01ca391

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

components/utilities/utest/utest.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,13 @@ static void utest_do_run(const char *utest_name)
217217
if (utest_name[len - 1] == '*')
218218
{
219219
len -= 1;
220+
if (rt_memcmp(tc_table[i].name, utest_name, len) != 0)
221+
{
222+
i++;
223+
continue;
224+
}
220225
}
221-
if (rt_memcmp(tc_table[i].name, utest_name, len) != 0)
226+
else if (rt_strcmp(tc_table[i].name, utest_name) != 0)
222227
{
223228
i++;
224229
continue;

0 commit comments

Comments
 (0)