martinpitt / umockdev

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

Testbed: Create "bus" and "class" dirs at init #145

Closed dlech closed 3 years ago

dlech commented 3 years ago

libudev expects the "/sys/bus" and "/sys/class" directories to exist when calling udev_enumerate_scan_devices(). When this was called on an empty Testbed, it would return -ENOENT since these directories did not exist.

This fixes the issue by creating the "/sys/bus" and "/sys/class" directories at the same time that "/sys" is created in the Testbed.

num_udev_devices() is modified to call udev_enumerate_scan_devices() directly instead of using GUdev, which ignores the return value of udev_enumerate_scan_devices(). This makes t_testbed_empty() a valid test for the bug we are fixing.

Some vala tests also had to be modified to account for the change.

Fixes: https://github.com/martinpitt/umockdev/issues/144