I have a service that manages a USB key (format, mount/umount, read/write, check space) coded in Python 2. This service call system to manage the device (mount/umount, mkfs, state) and monitor /proc/mounts to check mounting status.
There are some tests to check the service behaviour, but I am unable to test the service without a real USB key but it's an issue for Jenkins slaves.
I tried to mount the loop device, but this technic require to modify the service to manage this specific device.
- Do you know some technics to create a virtual device that behaves as a USB key?
- Do you know a way to test this kind of service ?
1 Answer
Reading an article about Linux-USB Gadget API Framework, I found a way to mount a device as if it was a USB key using loop device (here):
create a virtual drive :
fallocate -l 128M /tmp/virtual_drive.imgattach this as loop device:
sudo losetup -o512 /tmp/virtual_drive.img /dev/loop0
Then this virtual device is used as-is by the service.
2