Page MenuHomeFreeBSD

libc/tests: add stdbit test framework and unit tests
ClosedPublic

Authored by fuz on Nov 10 2025, 9:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 11, 8:53 PM
Unknown Object (File)
Mon, Dec 1, 4:20 PM
Unknown Object (File)
Sun, Nov 30, 3:45 PM
Unknown Object (File)
Tue, Nov 25, 3:06 PM
Unknown Object (File)
Fri, Nov 21, 9:43 PM
Unknown Object (File)
Fri, Nov 21, 9:42 PM
Unknown Object (File)
Sun, Nov 16, 6:13 PM
Unknown Object (File)
Sat, Nov 15, 3:14 PM
Subscribers

Details

Summary

This adds unit tests for all 70 functions in <stdbit.h>.

I'm sorry for the test framework, but it makes it so I don't
have to write 70 unit tests by hand.

Test Plan

This is the test plan for D53657.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 68544
Build 65427: arc lint + arc unit

Event Timeline

fuz requested review of this revision.Nov 10 2025, 9:35 AM
  • libc/tests/Makefile: use tab, not space for indent
  • libc/tests/stdbit: remove - from /*-
adrian added a subscriber: adrian.

absolutely amazing use of macros and included source files i love it

This revision is now accepted and ready to land.Tue, Nov 18, 3:08 PM
des added inline comments.
lib/libc/tests/stdbit/stdbit-test-framework.c
63

no longer needed

lib/libc/tests/stdbit/stdbit-test-kernel.c
40
47
lib/libc/tests/stdbit/stdbit-test-framework.c
63

If I remove ATF_TP_ADD_TCS, the tests fail to build (undefined symbol main). If I just remove the individual test cases ATF_TP_ADD_TC, then no unit tests end up defined. I am confused as to which part of this is “no longer needed.” Please clarify.

  • fix formatting issues in stdbit unit tests
This revision now requires review to proceed.Wed, Nov 19, 11:23 AM
  • use _WIDTH macros from C23 <limits.h> in stdbit unit tests, see D53825
des requested changes to this revision.Wed, Nov 19, 2:05 PM

I just remembered that you need to add an stdbit directory to etc/mtree/BSD.tests.mk:

--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -382,6 +382,8 @@
             ..
             ssp
             ..
+            stdbit
+            ..
             stdio
             ..
             stdlib
This revision now requires changes to proceed.Wed, Nov 19, 2:05 PM

Thanks, this is something I always forget about.

  • etc/mtree: add stdbit directory to etc/mtree/BSD.tests.mk
This revision is now accepted and ready to land.Tue, Nov 25, 7:58 PM