zephyr: posix: fnmatch: fix known bugs

Describe the bug It appears as though the original fnmatch() implementation that was checked-in with 486b731b40717a16f619b07e5d58aaf7d5143e78 has bugs. This is not surprising since it was checked-in without any test coverage.

The actual failing cases are commented-out in tests/lib/posix/common/src/fnmatch.c (part of #55184)

Please also mention any information which could help others to understand the problem you’re facing:

  • What target platform are you using? N/A
  • What have you tried to diagnose or workaround this issue? Comment-out known failure modes in the test
  • Is this a regression? No, the bugs have always been present

To Reproduce Steps to reproduce the behavior:

  1. Uncomment failure modes in tests/lib/posix/common/src/fnmatch.c 2.west build -p auto -b qemu_cortex_a53 -t run tests/posix/common/
  2. See error

Expected behavior All test cases should pass, including known failure modes.

Impact The shell has been using a buggy version of fnmatch() since approximately 2018.

Logs and console output

*** Booting Zephyr OS build zephyr-v3.3.0-475-gec19849fec26 ***
Running TESTSUITE posix_apis
===================================================================
START - fnmatch

    Assertion failed at WEST_TOPDIR/zephyr/tests/posix/common/src/fnmatch.c:35: posix_apis_fnmatch: fnmatch("[[?*\\]", "\\", 0) is non-zero

 FAIL - fnmatch in 0.001 seconds
===================================================================

Environment (please complete the following information):

  • OS: Any
  • Toolchain (e.g Zephyr SDK, …): Zephyr SDK v0.15.2
  • Commit SHA or Version used: b83cf1f1ee244e48a22844be181fd6ae2366e2c1 but goes as far back as 486b731b40717a16f619b07e5d58aaf7d5143e78

Additional context Noticed in the context of #55185

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 22 (12 by maintainers)

Commits related to this issue

Most upvoted comments

seems like the tests have now moved to tests/posix/c_lib_ext/

I’ve got /lib/posix/options/fnmatch.c passing all tests except this one:

/* zassert_ok(fnmatch("*[[:alpha:]]/""*[[:alnum:]]", "a/b", FNM_PATHNAME)); */

Good enough for a PR?

btw, seems like some of the tests in tests/posix/c_lib_ext/getentropy.c are failing, not sure if its a problem on my end.

The fnmatch-function now sees use also in the http_server_core