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

Add set_bits fuzz test #6394

Merged
merged 5 commits into from
Sep 20, 2024
Merged

Add set_bits fuzz test #6394

merged 5 commits into from
Sep 20, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Sep 13, 2024

Which issue does this PR close?

Part of #6288

Rationale for this change

The code in #6288 is tricky and includes many special cases and unsafe so extra testing is warranted

What changes are included in this PR?

Refactor the tests for set_bits into a struct and then implement a fuzzer that randomly generates test cases

Are there any user-facing changes?

No, this is entirely testing

@github-actions github-actions bot added the arrow Changes to the arrow crate label Sep 13, 2024
self.write_data
.resize(offset_write_bytes + len + extra_write_data_bytes, 0);

// interestingly set_bits seems to assume the output is already zeroed
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised at this -- if we fill the target with random data the tests fail (I am not sure why)

self.expected_data.resize(self.write_data.len(), 0);
self.expected_data.copy_from_slice(&self.write_data);

self.expected_null_count = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fuzz tester runs this code to compute the expected output (using set_bit and get_bit)

Copy link
Contributor

@kazuyukitanimura kazuyukitanimura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @alamb for creating this

@alamb alamb changed the title Implement set_bits fuzz test Add set_bits fuzz test Sep 18, 2024
@Dandandan Dandandan merged commit 669d405 into apache:master Sep 20, 2024
26 checks passed
@alamb alamb deleted the alamb/set_bits_fuzz branch September 20, 2024 16:13
@alamb
Copy link
Contributor Author

alamb commented Sep 20, 2024

Thank you @Dandandan

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

Successfully merging this pull request may close these issues.

3 participants