Skip to content

Commit

Permalink
Merge pull request #31 from tiagocoutinho/vivid-tests
Browse files Browse the repository at this point in the history
Vivid tests
  • Loading branch information
tiagocoutinho authored Aug 19, 2024
2 parents 1d5ccc8 + 8ebcd6e commit eec3313
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 145 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ jobs:
sudo apt-get install -y linux-modules-extra-$(uname -r)
- name: Setup user groups
run: |
sudo usermod -aG input,audio $USER
sudo modprobe -i uinput
echo KERNEL==\"uinput\", SUBSYSTEM==\"misc\" GROUP=\"docker\", MODE:=\"0666\" | sudo tee /etc/udev/rules.d/99-$USER.rules
echo KERNEL==\"event[0-9]*\", SUBSYSTEM==\"input\" GROUP=\"docker\", MODE:=\"0666\" | sudo tee -a /etc/udev/rules.d/99-$USER.rules
echo SUBSYSTEM==\"video4linux\" GROUP=\"docker\", MODE:=\"0666\" | sudo tee -a /etc/udev/rules.d/99-$USER.rules
cat /etc/udev/rules.d/99-$USER.rules
sudo udevadm control --reload-rules
sudo udevadm trigger
sudo modprobe vivid n_devs=1 node_types=0xe1d3d vid_cap_nr=190 vid_out_nr=191 meta_cap_nr=192 meta_out_nr=193
sudo modprobe -i uinput
sudo modprobe -i vivid n_devs=1 node_types=0xe1d3d vid_cap_nr=190 vid_out_nr=191 meta_cap_nr=192 meta_out_nr=193
lsmod
ls -lsa /dev/video*
- name: Set up Python ${{ matrix.python-version }}
Expand Down
6 changes: 3 additions & 3 deletions docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ $ python -m linuxpy.codegen.cli

## Running tests

Some video tests will only run with a properly configured `v4l2loopback`.
Some video tests will only run with a properly configured `vivid` driver.

```console
$ sudo modprobe v4l2loopback video_nr=199 card_label="Loopback 199"
$ sudo modprobe vivid n_devs=1 vid_cap_nr=190 vid_out_nr=191 meta_cap_nr=192 meta_out_nr=193
```

Additionally the user which runs the tests will need read/write access to
`/dev/video199`.
`/dev/video190`, `/dev/video191`, `/dev/video192` and `/dev/video193`.
On most systems this can be achieved by adding the user to the `video` group:

```console
Expand Down
15 changes: 13 additions & 2 deletions linuxpy/video/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ def raw_read_crop_capabilities(fd, buffer_type: BufferType) -> raw.v4l2_cropcap:


def read_crop_capabilities(fd, buffer_type: BufferType) -> CropCapability:
crop = raw_read_crop_capabilities(fd, buffer_type)
try:
crop = raw_read_crop_capabilities(fd, buffer_type)
except OSError as error:
if error.errno == errno.ENODATA:
return None
raise
return raw_crop_caps_to_crop_caps(crop)


Expand Down Expand Up @@ -1500,7 +1505,13 @@ def get_crop_capabilities(self, buffer_type: BufferType) -> CropCapability:
@property
def crop_capabilities(self) -> dict[BufferType, CropCapability]:
buffer_types = CROP_BUFFER_TYPES & set(self.buffers)
return {buffer_type: self.get_crop_capabilities(buffer_type) for buffer_type in buffer_types}
result = {}
for buffer_type in buffer_types:
crop_cap = self.get_crop_capabilities(buffer_type)
if crop_cap is None:
continue
result[buffer_type] = crop_cap
return result

@property
def formats(self):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dev = [
"ward>=0.68.0b0",
"ward-coverage>=0.3.0",
"ruff>=0.3.0",
"numpy>=1.1",
]
examples = [
"flask>=2,<4",
Expand Down
Loading

0 comments on commit eec3313

Please sign in to comment.