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 umockdev_testbed_wait_script(), add API to add scripts/evemu as strings #259

Merged
merged 6 commits into from
Dec 26, 2024

Conversation

martinpitt
Copy link
Owner

Fixes #247

This is mostly in a "this train ride ends here" state, but it works, and isn't too horrible. It could still use some fine-tuning, documentation, etc. @mkemlogic you weren't too happy about the names, we can do some bikeshedding 😉

What do you think?

@mkemlogic
Copy link

That was quick. I'm not sure I will have time before Christmas, but I should find some time before this year ends. It will be fun playing with this.

@martinpitt
Copy link
Owner Author

@mkemlogic No worries, please enjoy your holidays! (As am I..) There is no rush here, we can talk about it in January.

Script replay happens in the background in a thread. This API waits for
a script (or evemu events, which are translated to scripts) to finish,
so that tests can synchronize them with other system events.

Fixes #247
Start with the emulated device fd, it belongs together with the (purely
descriptive) `device` argument.
This will make it possible to hand it scripts which are not in files.
@martinpitt martinpitt force-pushed the wait branch 2 times, most recently from a516910 to 1d403b0 Compare December 23, 2024 15:28
@martinpitt
Copy link
Owner Author

a516910 went green, but with a retry. Doing a no-change push to re-run the tests, there could be a new flake.

/* load it */
success = umockdev_testbed_load_evemu_events(fixture->testbed, "/dev/input/event1", tmppath, &error);
success = umockdev_testbed_load_evemu_events_from_string(fixture->testbed, "/dev/input/event1", test_data, &error);

Choose a reason for hiding this comment

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

Should I be able to call umockdev_testbed_load_evemu_events_from_string()more than once?
I'm getting ERROR:../src/umockdev.vala:1086:umockdev_testbed_load_script_from_stream: assertion failed: (!this.dev_script_runner.contains (owned_dev))

I think this error was the motivation for my hack.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, you should be able to do that. I just pushed an update which asserts that this works. However, in between two load calls you have to call umockdev_testbed_wait_script() to ensure that the previous script is finished. That will flush the script from the this.dev_script_runner dictionary.

Copy link
Owner Author

@martinpitt martinpitt Dec 26, 2024

Choose a reason for hiding this comment

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

update which asserts that this works

I.e. I added unit tests for that, I didn't change the code. If that doesn't work for you, can you please point me to example code that fails? Thanks!

This makes it more comfortable to deal with lots of small hand-crafted
scripts instead of few big records.
This makes it more comfortable to deal with lots of small
hand-crafted evemu events.
@mkemlogic
Copy link

I'm sorry, I simply forgot about the umockdev_testbed_wait_script().
It works perfectly now.
I really appreciate adding this feature!

@martinpitt martinpitt marked this pull request as ready for review December 26, 2024 17:14
@martinpitt
Copy link
Owner Author

@mkemlogic Cool, thank you for testing! This is a nice new feature indeed! I'll do a release in the next days.

@martinpitt martinpitt merged commit ba63ef8 into main Dec 26, 2024
36 checks passed
@martinpitt martinpitt deleted the wait branch December 26, 2024 17:15
@martinpitt
Copy link
Owner Author

@mkemlogic released: https://github.com/martinpitt/umockdev/releases/tag/0.19.0 packaging for Fedora/Debian/Ubuntu in the next days.

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.

generating input events
2 participants