-
Notifications
You must be signed in to change notification settings - Fork 60
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
generating input events #247
Comments
I've made this PR mkemlogic#1 as a workaround. This allows me to generate one event at a time, or multiple if needed. |
@martinpitt is this something you would consider to include? lack of this is a show stopper for one of my major clients (~500 employees). They have to maintain their own fork, which they would rather not. |
Hello @mkemlogic! Sorry, I didn't see that PR, as it is against your fork. Please feel free to do one against this repo. I tried to understand your originally described issue. When I run
then in
It is true that I don't see the actual A key press anywhere, but I figure that's because I'm running this in QEMU. (I don't have evtest/evemu installed on my host, read-only image blabla). So the essence of your PR is that you load the script runner not into a thread, but execute it in umockdev's main thread blocking. I.e. during that time it cannot do any of its other functionality such as picking up uevents or servicing other loaded scripts. Also, it seems you need to write things into pipe buffers and crossing your fingers that you don't overrun them, as at that point the write would block and everything is deadlocked. So I'm not a fan of this. We could probably find a secret/undocumented/unsupported way of doing, but I'd like to understand what the actual problem is first? You need more control over the playback, i.e. get a callback or signal or flag file or anything else when the script replay (the ScriptRunner thread) is done? We could build something around eventfd or SIGALRM or similar, with a convenient API, but let's discuss the problem first. Thanks! |
Thank you for the quick reply! Right now I've created files with a single input event in each file. Then I use this function to trigger one event at a time.
Pretty much yes. Or just wait_for_playback_to_finish() So if the solution is very different from my PR then it is maybe better that a new fresh PR is created. I too ran everything in QEMU. Did you run |
Directly from the console. Are you tying to do something like
I.e. you can type, but not record the writes into the device. (I suppose that could be implemented, but it isn't).
So, something like
would be fairly easy to implement. Possibly even with a timeout and corresponding success return code, although that shouldn't be necessary for unit tests. Would that work for you as an API? |
I get that to work from the console too. But it did not work in umockdev-wrapper context.
and then
The
That would work, but it would be even better if one could generate events without even loading them from files. Also, we don't use umockdev for unit tests, but for system test. We use umockdev-wrapper to start a program that starts a server in background. The program then listens to dbus messages from the server triggered by different input events, uevents and sysfs attributes. |
Err, of course I meant But either way, this then? // umockdev script format
umockdev_testbed_set_script("/dev/input/event1", "r 200 blabla", &error);
// evemu format
umockdev_testbed_set_evemu_events("/dev/input/event1", "E: 1234.500000...", &error);
bool success = umockdev_testbed_wait_script(tb, "/dev/input/event1", 1000, &error); The latter could fail with a timeout, or possibly some other fringe cases. |
Yes, exactly what I need :-) |
@mkemlogic OK! You picked a good time, I'll have some time for hobby project hacking on this on the train ride tomorrow 😉 |
:-) |
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
Ah bummer, Thread.join() doesn't have timeout functionality. So if you need that, your test needs to build it by itself with e.g. @mkemlogic want to have a look at #259 ? It's not quite "done" yet, but functional. |
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
Currently it is possible to play back recorded events with
umockdev_testbed_load_evemu_events()
. It would be very useful to be able to generate input events directly from the code, similar toumockdev_testbed_uevent()
. Maybe there is a way I'm not aware of?I have tried:
but the events are nowhere to be found.
evtest
does not pick them up when called like that:Note that evtest run this way can see events submitted by
umockdev_testbed_load_evemu_events()
.The text was updated successfully, but these errors were encountered: