Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine Out_channel string/bytes generator #483

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jmid
Copy link
Collaborator

@jmid jmid commented Nov 1, 2024

As part of carving a reproducer for #444, I realized that its string and bytes generators could be refined to have a bigger chance of producing strings stressing the channel boundary logic.

This quick little PR attempts such a refinement.
It is based on a size_gen generator that produces numbers around powers of 2:

let size_gen =
      Gen.(map2 (fun pos size_adj ->
                   let res = 1 lsl (pos-1) in
                   if size_adj < res then res-size_adj else res) (int_bound 18) (int_bound 10));;
val size_gen : int QCheck.Gen.t = <fun>
Gen.generate ~n:10 size_gen;;
- : int list = [65531; 16378; 65535; 128; 8185; 0; 249; 4; 59; 28]
Gen.generate ~n:10 size_gen;;
- : int list = [65531; 126; 1; 512; 131066; 13; 252; 4087; 16380; 120]
Gen.generate ~n:10 size_gen;;
- : int list = [0; 65533; 15; 8190; 4089; 4094; 8; 65528; 2044; 65530]

@jmid
Copy link
Collaborator Author

jmid commented Nov 4, 2024

This times out on MSVC bytecode and MinGW bytecode trunk, where I suspect the underlying buffer size to differ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant