This changeset add a new set of tests that comprehensively test strcmp() on
various alignments of the input. This made it easy to smoke out many
exciting new bugs in my SSE strcmp() implementation from D41971.
Sponsored by: The FreeBSD Foundation
Differential D41970
lib/libc/tests/string: add extended unit tests for strcmp() fuz on Sep 25 2023, 6:33 AM. Authored by Tags None Referenced Files
Details This changeset add a new set of tests that comprehensively test strcmp() on Sponsored by: The FreeBSD Foundation n/a
Diff Detail
Event TimelineComment Actions Let me see if I understand this dlopen business correctly. Your plan is that if you create a separate .c file containing "test_strcmp" and link it to t_strcmp.o, then the test will operate on that function. Otherwise, it will operate on the standard strcmp? Comment Actions What I usually do is prepare my own strcmp to be named test_strcmp. Then I assemble and link it into a shared object and preload the shared object with LD_PRELOAD. It doesn't suffice to just name it strcmp, as defects in the code can mean that the test crashes before it gets to actually run any unit tests. This design pattern is already used in some other libc string tests such as contrib/netbsd-tests/lib/libc/string/t_strchr.c. Comment Actions Please don't modify the NetBSD test: if the plan is to test out FreeBSD-specific behavior for strcmp, it should go in its own test. Comment Actions I'm a bit confused -- why would you want to unhook them from the build...? Why not just add the FreeBSD-specific tests to another test file? Comment Actions So there will then be two test files for strcmp? If the build system supports this, sure, why not. Comment Actions
This implements your requested move of the new strcmp unit test into a Comment Actions All of my questions relate to understanding the rationale behind some of the design choices presented in the change.
Comment Actions Will prepare a new revision pending response to my comments.
Comment Actions I'm waiting for a response to my questions so I can prepare an update to this revision. Comment Actions Ok, that part wasn't apparent before. If you're willing to go through upstreaming the change to NetBSD and they accept it, I say it's worth taking -- if however upstream isn't interested in taking changes to the test, I don't see the point in modifying their test: I'd take the test, fork it, apply the necessary changes, then maintain it internally. The goal is to consume the NetBSD test suite without having to hack it too much/do the bare minimum necessary to make it work on FreeBSD, while upstreaming anything possible back to the NetBSD project. It's not where FreeBSD specific tests/testing should go. Comment Actions Also, please add comments for non-obvious things: you have the context now, but I didn't understand the reasoning, and you might not have the context at a later date. The code needs to either be intuitive by design or intuitive via comments. Comment Actions Add comments to clarify parameter choices. |