martinpitt / umockdev

Mock hardware devices for creating unit tests and bug reporting
https://launchpad.net/umockdev
GNU Lesser General Public License v2.1
308 stars 55 forks source link

[problem]Can I create a fake camera by using this? #195

Closed Tumb1eweed closed 1 year ago

martinpitt commented 2 years ago

In general yes -- the source even contains a PTP camera :grin: However, this is many years old, and the ioctl record most probably does not work with current libusb versions and such. But it should be possible. Did you already try and it failed, or was this just a high-level question?

martinpitt commented 2 years ago

(I used this to run a photo import from f-spot and gphoto a couple of years ago, so it at least used to get quite far. But admittedly I haven't looked at that since then, so it may well have gotten broken.)

Tumb1eweed commented 2 years ago

In general yes -- the source even contains a PTP camera 😁 However, this is many years old, and the ioctl record most probably does not work with current libusb versions and such. But it should be possible. Did you already try and it failed, or was this just a high-level question?

oh i just ask before trying, because i want to use to test transferring data through shared memory in ros2 nodes, and the publisher's data is from camera but i don't want to start a camera (no device), so I want to mock camera (mock xoictl particularly). After experiment I will tell you the result, thanks.

Tumb1eweed commented 2 years ago

(I used this to run a photo import from f-spot and gphoto a couple of years ago, so it at least used to get quite far. But admittedly I haven't looked at that since then, so it may well have gotten broken.)

i forgot to ask, is this tool supporting C++?

benzea commented 2 years ago

There are no real requirements for the code that you are testing. The library itself is vala (i.e. C), so of course it works well from C++ if you want that.

No idea about ROS and the test.

I suppose that works by mmap'ing a device file and doing a few ioctl's on it. With umockdev, that should work, i.e.:

  1. If a read/write/ioctl happens, you can handle it yourself from the test code
  2. When mmap'ed the underlying file is mmap'ed, I think. So, I guess that works if you just create a big enough file on disk in the location and use it as a shared memory.

EDIT: Or, well, maybe I misunderstood this and the shared memory is just between the different processes that are being tested. In that case, we don't care about it.

martinpitt commented 1 year ago

This is stale and there is nothing actionable. Closing.