[gnutls-devel] GnuTLS | tests/eagain-common.h: improve EAGAIN randomization logic (!2116)
Read-only notification of GnuTLS library development activities
gnutls-devel at lists.gnutls.org
Mon Jun 29 17:53:34 CEST 2026
Alexander Sosedkin created a merge request: https://gitlab.com/gnutls/gnutls/-/merge_requests/2116
Project:Branches: asosedkin/gnutls:tests-improve-eagain-randomization to gnutls/gnutls:master
Author: Alexander Sosedkin
<!-- Add a description of the new feature/bug fix. Reference any relevant bugs. -->
* tests/eagain-common.h: improve EAGAIN randomization logic
Before regressing in d821485782334c01a956ac9f5b1da97d4df4c573,
it was a `static unsigned char rnd = 0; if (rnd++ % 2 == 0)`.
Thus the pattern was a steady (0, 1, 0, 1, 0, 1, ...) for each caller,
with no real randomization aside from the multithreaded scenarios,
not even the starting position in the sequence.
After regressing in d821485782334c01a956ac9f5b1da97d4df4c573,
it became an `unsigned int rnd = time(0); if (rnd++ % 3 == 0)`, making it
(0s for an entire second, 1s for another second, 1s for another second, ...)
with the starting point of the sequence being the only randomness.
At the same time, it clearly intended to be a (0, 1, 1, 0, 1, 1, ...)
with a starting position randomization.
This potentially overengineered
`if (<boundary>) <reset>; rnd++ % 6 < 3` approach
aims for a (0, 0, 0, 1, 1, 1, ...)
with the starting sequence point randomization smudge
and occasional hiccups on the second boundaries.
The primary goal is to speed up the tests; the specific sequence is chosen
to cover both the consecutives up to 3 and the transitions
with the starting point evenly smudged in between the runs,
while keeping the infrequent hiccups
to allow for weirder patterns to appear.
Signed-off-by: Alexander Sosedkin <asosedkin at redhat.com>
## Checklist
* [x] Commits have `Signed-off-by:` with name/author being identical to the commit author
* [ ] Code modified for feature
* [ ] Test suite updated with functionality tests
* [ ] Test suite updated with negative tests
* [ ] Documentation updated / NEWS entry present (for non-trivial changes)
## Reviewer's checklist:
* [ ] Any issues marked for closing are addressed
* [ ] There is a test suite reasonably covering new functionality or modifications
* [ ] Function naming, parameters, return values, types, etc., are consistent and according to `CONTRIBUTION.md`
* [ ] This feature/change has adequate documentation added
* [ ] No obvious mistakes in the code
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/2116
You're receiving this email because of your account on gitlab.com. Unsubscribe from this thread: https://gitlab.com/-/namespace/17175643/sent_notifications/5-02s6hotns0ei5bcnp4qew53iw-a84t7/unsubscribe | Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20260629/d1f73c75/attachment.html>
More information about the Gnutls-devel
mailing list