lib/glob: add more KUnit tests for glob
PATCH 1/1 lib/glob: add more KUnit tests for glob
Since there isnt much tests for lib/glob.c, lets go ahead and add some more tests
--- lib/tests/glob_kunit.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
lib/tests/glob_kunit.c +25 -0
@@ -90,6 +90,31 @@ static const struct glob_test_case glob_test_cases[] = { { .pat = "*abcd*abcdef*", .str = "abcabcdabcdeabcdefg", .expected = true }, { .pat = "*abcd*", .str = "abcabcabcabcefg", .expected = false }, { .pat = "*ab*cd*", .str = "abcabcabcabcefg", .expected = false }, + /* backslash escaping */ + { .pat = "\\a", .str = "a", .expected = true }, + { .pat = "\\a", .str = "\\a", .expected = false }, + { .pat = "\\*", .str = "*", .expected = true }, + { .pat = "\\*", .str = "a", .expected = false }, + { .pat = "\\?", .str = "?", .expected = true }, + { .pat = "\\?", .str = "a", .expected = false }, + { .pat = "\\[a]", .str = "[a]", .expected = true }, + { .pat = "\\\\", .str = "\\", .expected = true }, + { .pat = "a\\*b", .str = "a*b", .expected = true }, + { .pat = "a\\*b", .str = "aXb", .expected = false }, + /* trailing backslash */ + { .pat = "a\\", .str = "a", .expected = true }, + { .pat = "\\", .str = "", .expected = true }, + /* backwards ranges */ + { .pat = "[z-a]", .str = "m", .expected = false }, + { .pat = "[!z-a]", .str = "m", .expected = true }, + /* high-bit characters */ + { .pat = "\xc0", .str = "\xc0", .expected = true }, + { .pat = "\xc0", .str = "\x80", .expected = false }, + { .pat = "[\x80-\xff]", .str = "\xc0", .expected = true }, + { .pat = "[\x80-\xff]", .str = "\x7f", .expected = false }, + /* unclosed bracket as literal */ + { .pat = "[abc", .str = "[abc", .expected = true }, + { .pat = "[abc", .str = "a", .expected = false }, };static void glob_case_to_desc (const struct glob_test_case *t,char *desc)
Signature · 1 line
2.34.1
Hi Josh,
Quoted 1 line · Josh Law
Since there isnt much tests for
lib/glob.c, lets go ahead and add some more tests
checkpatch.pl generates the following warnings:
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?) #60:
Since there isnt much tests for lib/glob.c, lets go ahead and add some more tests
WARNING: 'isnt' may be misspelled - perhaps 'isn't'?
#60:
Since there isnt much tests for lib/glob.c, lets go ahead and add some more tests
^^^^
total: 0 errors, 2 warnings, 31 lines checked
I have mentioned this to you multiple times in the past: please always run checkpatch.pl to check your patches before sending them.
Regards,
Kuan-Wei
Quoted 45 lines
Signed-off-by Josh Law <[email protected]>--- lib/tests/glob_kunit.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)lib/tests/glob_kunit.c +25
-0@@ -90,6 +90,31 @@ static const struct glob_test_case glob_test_cases[] = { { .pat = "*abcd*abcdef*", .str = "abcabcdabcdeabcdefg", .expected = true }, { .pat = "*abcd*", .str = "abcabcabcabcefg", .expected = false }, { .pat = "*ab*cd*", .str = "abcabcabcabcefg", .expected = false }, + /* backslash escaping */ + { .pat = "\\a", .str = "a", .expected = true }, + { .pat = "\\a", .str = "\\a", .expected = false }, + { .pat = "\\*", .str = "*", .expected = true }, + { .pat = "\\*", .str = "a", .expected = false }, + { .pat = "\\?", .str = "?", .expected = true }, + { .pat = "\\?", .str = "a", .expected = false }, + { .pat = "\\[a]", .str = "[a]", .expected = true }, + { .pat = "\\\\", .str = "\\", .expected = true }, + { .pat = "a\\*b", .str = "a*b", .expected = true }, + { .pat = "a\\*b", .str = "aXb", .expected = false }, + /* trailing backslash */ + { .pat = "a\\", .str = "a", .expected = true }, + { .pat = "\\", .str = "", .expected = true }, + /* backwards ranges */ + { .pat = "[z-a]", .str = "m", .expected = false }, + { .pat = "[!z-a]", .str = "m", .expected = true }, + /* high-bit characters */ + { .pat = "\xc0", .str = "\xc0", .expected = true }, + { .pat = "\xc0", .str = "\x80", .expected = false }, + { .pat = "[\x80-\xff]", .str = "\xc0", .expected = true }, + { .pat = "[\x80-\xff]", .str = "\x7f", .expected = false }, + /* unclosed bracket as literal */ + { .pat = "[abc", .str = "[abc", .expected = true }, + { .pat = "[abc", .str = "a", .expected = false }, };static void glob_case_to_desc (const struct glob_test_case *t,char *desc)Signature · 1 line
2.34.1
---- On Fri, 03 Apr 2026 16:49:10 +0100 [email protected] wrote ----
Quoted 20 lines
Hi Josh,
Quoted 1 line · Josh Law
Since there isnt much tests for
lib/glob.c, lets go ahead and add some moretests
checkpatch.pl generates the following warnings:
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
#60:
Since there isnt much tests forlib/glob.c, lets go ahead and add some more testsWARNING: 'isnt' may be misspelled - perhaps 'isn't'?
#60:
Since there isnt much tests forlib/glob.c, lets go ahead and add some more tests
^^^^
Quoted 7 lines
total: 0 errors, 2 warnings, 31 lines checked
I have mentioned this to you multiple times in the past: please always run checkpatch.pl to check your patches before sending them.
Regards,
Kuan-Wei
Hi Kuan, it was genuinely my mistake. I forgot to run check patch before sending it over. And this happened. I'll give it a bit before sending over a V2 fixing these issues :)
Quoted 48 lines
Quoted 13 lines
Signed-off-by Josh Law---
lib/tests/glob_kunit.c| 25 +++++++++++++++++++++++++1 file changed, 25 insertions(+)lib/tests/glob_kunit.c +0
-0@@ -90,6 +90,31 @@ static const struct glob_test_case glob_test_cases[] = {Quoted 1 line
{ .pat = "*abcd*abcdef*", .str = "abcabcdabcdeabcdefg", .expected = true
},
Quoted 33 lines
{ .pat = "*abcd*", .str = "abcabcabcabcefg", .expected = false }, { .pat = "*ab*cd*", .str = "abcabcabcabcefg", .expected = false }, + /* backslash escaping */
+ { .pat = "\\a", .str = "a", .expected = true },
+ { .pat = "\\a", .str = "\\a", .expected = false },
+ { .pat = "\\*", .str = "*", .expected = true },
+ { .pat = "\\*", .str = "a", .expected = false },
+ { .pat = "\\?", .str = "?", .expected = true },
+ { .pat = "\\?", .str = "a", .expected = false },
+ { .pat = "\\[a]", .str = "[a]", .expected = true },
+ { .pat = "\\\\", .str = "\\", .expected = true },
+ { .pat = "a\\*b", .str = "a*b", .expected = true },
+ { .pat = "a\\*b", .str = "aXb", .expected = false },
+ /* trailing backslash */
+ { .pat = "a\\", .str = "a", .expected = true },
+ { .pat = "\\", .str = "", .expected = true },
+ /* backwards ranges */
+ { .pat = "[z-a]", .str = "m", .expected = false },
+ { .pat = "[!z-a]", .str = "m", .expected = true },
+ /* high-bit characters */
+ { .pat = "\xc0", .str = "\xc0", .expected = true },
+ { .pat = "\xc0", .str = "\x80", .expected = false },
+ { .pat = "[\x80-\xff]", .str = "\xc0", .expected = true }, + { .pat = "[\x80-\xff]", .str = "\x7f", .expected = false }, + /* unclosed bracket as literal */
+ { .pat = "[abc", .str = "[abc", .expected = true },
+ { .pat = "[abc", .str = "a", .expected = false },
};static void
glob_case_to_desc(const struct glob_test_case *t, char *desc)--
2.34.1
Quoted 23 lines · Josh Law
---- On Fri, 03 Apr 2026 16:49:10 +0100 [email protected] wrote ----
Quoted 20 lines
Hi Josh,
Quoted 1 line · Josh Law
Since there isnt much tests for
lib/glob.c, lets go ahead and add some moretests
checkpatch.pl generates the following warnings:
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
#60:
Since there isnt much tests forlib/glob.c, lets go ahead and add some more testsWARNING: 'isnt' may be misspelled - perhaps 'isn't'?
#60:
Since there isnt much tests forlib/glob.c, lets go ahead and add some more tests
^^^^
Quoted 8 lines
Quoted 7 lines
total: 0 errors, 2 warnings, 31 lines checked
I have mentioned this to you multiple times in the past: please always run checkpatch.pl to check your patches before sending them.
Regards,
Kuan-WeiHi Kuan, it was genuinely my mistake. I forgot to run check patch before sending it over. And this happened. I'll give it a bit before sending over a V2 fixing these issues :)
Additionally, I believe many different people have already pointed out the word-wrapping issues in your replies. Some developers are even getting frustrated because of the repeated reminders. You have promised to fix this, yet every time you send a new email, the exact same problem persists.
I would suggest that you figure out how to completely resolve this issue before attempting to submit new patches. Furthermore, you recently mentioned that you were going to take a break for a while, but less than a few days later, I am already receiving another patch from you.
Regards,
Kuan-Wei
Quoted 49 lines
Quoted 48 lines
Quoted 13 lines
Signed-off-by Josh Law---
lib/tests/glob_kunit.c| 25 +++++++++++++++++++++++++1 file changed, 25 insertions(+)lib/tests/glob_kunit.c +0
-0@@ -90,6 +90,31 @@ static const struct glob_test_case glob_test_cases[] = {Quoted 1 line
{ .pat = "*abcd*abcdef*", .str = "abcabcdabcdeabcdefg", .expected = true
},
Quoted 33 lines
{ .pat = "*abcd*", .str = "abcabcabcabcefg", .expected = false }, { .pat = "*ab*cd*", .str = "abcabcabcabcefg", .expected = false }, + /* backslash escaping */
+ { .pat = "\\a", .str = "a", .expected = true },
+ { .pat = "\\a", .str = "\\a", .expected = false },
+ { .pat = "\\*", .str = "*", .expected = true },
+ { .pat = "\\*", .str = "a", .expected = false },
+ { .pat = "\\?", .str = "?", .expected = true },
+ { .pat = "\\?", .str = "a", .expected = false },
+ { .pat = "\\[a]", .str = "[a]", .expected = true },
+ { .pat = "\\\\", .str = "\\", .expected = true },
+ { .pat = "a\\*b", .str = "a*b", .expected = true },
+ { .pat = "a\\*b", .str = "aXb", .expected = false },
+ /* trailing backslash */
+ { .pat = "a\\", .str = "a", .expected = true },
+ { .pat = "\\", .str = "", .expected = true },
+ /* backwards ranges */
+ { .pat = "[z-a]", .str = "m", .expected = false },
+ { .pat = "[!z-a]", .str = "m", .expected = true },
+ /* high-bit characters */
+ { .pat = "\xc0", .str = "\xc0", .expected = true },
+ { .pat = "\xc0", .str = "\x80", .expected = false },
+ { .pat = "[\x80-\xff]", .str = "\xc0", .expected = true }, + { .pat = "[\x80-\xff]", .str = "\x7f", .expected = false }, + /* unclosed bracket as literal */
+ { .pat = "[abc", .str = "[abc", .expected = true },
+ { .pat = "[abc", .str = "a", .expected = false },
};static void
glob_case_to_desc(const struct glob_test_case *t, char *desc)--
2.34.1