mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-24 20:35:55 +00:00
Next generation hardware handling (#2429)
* Next generation hardware handling * need daemon for some details * fix tests * fix wrong coresys lookup * test initial import * test device lookup * validate if device exists * Add cgroups rules manager * mapping udev from host * Modify validation/options handling * lookup devices * add support for host udev mapping * next * Add policy support to add-ons * Depricate hardware trigger call * next cleanup round * detect USB linking * optimize * readd udev utils for backwards compatibility * fix tests * Add more tests * fix tests * Make device explicit * Add filter * work on tests * Add migration step * clean out auto_uart * Fix all tests * Expose all device information * small improvment * Fix loop over right devices * Use migration for new device format * Update rootfs/etc/cont-init.d/udev.sh Co-authored-by: Franck Nijhof <git@frenck.dev> * Fix old helper * Fix API * add helper for by-id * fix tests * Fix serial helper * Fix hardware API schema * Hide some virtual devices from tracking * Apply suggestions from code review Co-authored-by: Stefan Agner <stefan@agner.ch> * Update supervisor/addons/validate.py Co-authored-by: Stefan Agner <stefan@agner.ch> * Update supervisor/addons/validate.py Co-authored-by: Stefan Agner <stefan@agner.ch> * fix lint * Apply suggestions from code review Co-authored-by: Joakim Sørensen <joasoe@gmail.com> * Apply suggestions from code review Co-authored-by: Joakim Sørensen <joasoe@gmail.com> * fix black * fix lint Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Stefan Agner <stefan@agner.ch> Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
29
tests/hardware/test_policy.py
Normal file
29
tests/hardware/test_policy.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""Test HardwareManager Module."""
|
||||
from pathlib import Path
|
||||
|
||||
from supervisor.hardware.const import PolicyGroup
|
||||
from supervisor.hardware.data import Device
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
|
||||
def test_device_policy(coresys):
|
||||
"""Test device cgroup policy."""
|
||||
device = Device(
|
||||
"ttyACM0",
|
||||
Path("/dev/ttyACM0"),
|
||||
Path("/sys/bus/usb/001"),
|
||||
"tty",
|
||||
[],
|
||||
{"MAJOR": "5", "MINOR": "10"},
|
||||
)
|
||||
|
||||
assert coresys.hardware.policy.get_cgroups_rule(device) == "c 5:10 rwm"
|
||||
|
||||
|
||||
def test_policy_group(coresys):
|
||||
"""Test policy group generator."""
|
||||
assert coresys.hardware.policy.get_cgroups_rules(PolicyGroup.VIDEO) == [
|
||||
"c 239:* rwm",
|
||||
"c 29:* rwm",
|
||||
]
|
||||
Reference in New Issue
Block a user