Skip to content

convert existing unit tests to proptest - #155

Open
lforchini wants to merge 1 commit into
test/modify-existingfrom
convert-to-prop
Open

lforchini wants to merge 1 commit into
test/modify-existingfrom
convert-to-prop

Conversation

@lforchini

Copy link
Copy Markdown
Collaborator

Rework the QMP envelope, config round-trip, rolling counter reset and VM
ownership tests into property-based tests, so they cover arbitrary inputs
rather than a single hand-picked example.

Signed-off-by: Leonardo Forchini leonardo.forchini@nutanix.com


Stack created with GitHub Stacks CLI • Give Feedback 💬

@lforchini
lforchini added this pull request to stack #157 October 23, 2026 08:45
@lforchini
lforchini removed this pull request from stack #157 October 23, 2026 08:49
@lforchini
lforchini added this pull request to stack #159 October 23, 2026 08:50
@lforchini
lforchini removed this pull request from stack #159 October 30, 2026 10:48
@lforchini
lforchini added this pull request to stack #173 October 30, 2026 10:50
@lforchini
lforchini marked this pull request as ready for review October 30, 2026 10:54
Comment thread proptest-regressions/config.txt Outdated
@@ -0,0 +1,7 @@
# Seeds for failure cases proptest has generated in the past. It is

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit, "This file contains seeds for failure ..."?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've since changed how I'm testing config round-trip so this seed file isn't relevant. I've dropped it for now. The wording here is autogenerated by proptest.

Comment thread proptest-regressions/config.txt Resolved
Comment thread src/backends/qemu/libvirt.rs Resolved
Comment thread src/rolling.rs Resolved

/// Create an arbitrary parsed JSON value used to exercise parser failure
/// paths.
fn arb_json() -> impl Strategy<Value = serde_json::Value> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not familiar with proptest at all, is the below construct something obvious assuming some familiarity with proptest or do we need some documentation?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This function describes a proptest strategy to generate arbitrary serde_json::Values in a deterministic way. A simpler example of a strategy is the let leaf = prop_oneof![...] which selects the value of a key-value pair (either null, any bool, any i32, or a string matching that regex). The function also uses more complex strategies to generate Vecs and HashMaps where you give them a strategy and a capacity range.

The prop_recursive is the most complex part and it's mostly the example from the docs.

Comment thread src/config.rs Resolved
@lforchini
lforchini removed this pull request from stack #173 November 5, 2026 15:02
@lforchini
lforchini added this pull request to stack #176 November 5, 2026 15:03
@lforchini
lforchini removed this pull request from stack #176 November 5, 2026 15:09
@lforchini
lforchini added this pull request to stack #178 November 5, 2026 15:10
@lforchini
lforchini removed this pull request from stack #178 November 6, 2026 10:23
@lforchini
lforchini added this pull request to stack #180 November 6, 2026 10:24
@lforchini
lforchini force-pushed the convert-to-prop branch 4 times, most recently from e561d09 to f24477f Compare November 12, 2026 08:40
Rework the QMP envelope, config round-trip, rolling counter reset and VM
ownership tests into property-based tests, so they cover arbitrary inputs
rather than a single hand-picked example.

Signed-off-by: Leonardo Forchini <leonardo.forchini@nutanix.com>

@tmakatos tmakatos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have to review this from scratch.

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.

2 participants