@@ -30,14 +30,16 @@ ZTEST(posix_c_lib_ext, test_fnmatch)
3030 zassert_equal (fnmatch ("a*.c" , "a/x.c" , FNM_PATHNAME ), FNM_NOMATCH );
3131 zassert_ok (fnmatch ("*/foo" , "/foo" , FNM_PATHNAME ));
3232 zassert_ok (fnmatch ("-O[01]" , "-O1" , 0 ));
33- /* \\ escapes ], no bracket expr, no match */
34- zassert_equal (fnmatch ("[[?*\\]" , "\\" , 0 ), FNM_NOMATCH );
33+ if (!IS_ENABLED (CONFIG_COMMON_LIBC_FNMATCH )) {
34+ /* \\ escapes ], no bracket expr, no match */
35+ zassert_equal (fnmatch ("[[?*\\]" , "\\" , 0 ), FNM_NOMATCH );
36+ /* \\ escapes ], no bracket expr, no match */
37+ zassert_equal (fnmatch ("[]?*\\]" , "]" , 0 ), FNM_NOMATCH );
38+ }
3539 /* \\ unescaped, match */
3640 zassert_ok (fnmatch ("[[?*\\]" , "\\" , FNM_NOESCAPE ));
3741 /* \\ escapes \\, match */
3842 zassert_ok (fnmatch ("[[?*\\\\]" , "\\" , 0 ));
39- /* \\ escapes ], no bracket expr, no match */
40- zassert_equal (fnmatch ("[]?*\\]" , "]" , 0 ), FNM_NOMATCH );
4143 /* \\ unescaped, match */
4244 zassert_ok (fnmatch ("[]?*\\]" , "]" , FNM_NOESCAPE ));
4345 /* \\ escapes \\, match */
@@ -83,9 +85,14 @@ ZTEST(posix_c_lib_ext, test_fnmatch)
8385 zassert_equal (fnmatch ("*/*" , "a/.b" , FNM_PATHNAME | FNM_PERIOD ), FNM_NOMATCH );
8486 zassert_ok (fnmatch ("*?*/*" , "a/.b" , FNM_PERIOD ));
8587 zassert_ok (fnmatch ("*[.]/b" , "a./b" , FNM_PATHNAME | FNM_PERIOD ));
86- zassert_ok (fnmatch ("*[[:alpha:]]/" "*[[:alnum:]]" , "a/b" , FNM_PATHNAME ));
87- zassert_ok (fnmatch ("*[![:digit:]]*/[![:d-d]" , "a/b" , FNM_PATHNAME ));
88- zassert_ok (fnmatch ("*[![:digit:]]*/[[:d-d]" , "a/[" , FNM_PATHNAME ));
88+
89+ /* Disable tests that fail when using Zephyr's fnmatch implementation */
90+ if (!IS_ENABLED (CONFIG_POSIX_C_LIB_EXT )) {
91+ zassert_ok (fnmatch ("*[[:alpha:]]/" "*[[:alnum:]]" , "a/b" , FNM_PATHNAME ));
92+ zassert_ok (fnmatch ("*[![:digit:]]*/[![:d-d]" , "a/b" , FNM_PATHNAME ));
93+ zassert_ok (fnmatch ("*[![:digit:]]*/[[:d-d]" , "a/[" , FNM_PATHNAME ));
94+ }
95+
8996 zassert_not_equal (fnmatch ("*[![:digit:]]*/[![:d-d]" , "a/[" , FNM_PATHNAME ), 0 );
9097 zassert_ok (fnmatch ("a?b" , "a.b" , FNM_PATHNAME | FNM_PERIOD ));
9198 zassert_ok (fnmatch ("a*b" , "a.b" , FNM_PATHNAME | FNM_PERIOD ));
0 commit comments