Skip to content

Commit 7ba2f94

Browse files
[#90443] Add USB sysfs test
1 parent 10f1b43 commit 7ba2f94

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

protoplaster/conf/parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from protoplaster.tests.pmic.UCD90320U.test import __file__ as UCD90320U_test
2525
from protoplaster.tests.thermometer.TMP431.test import __file__ as TMP431_test
2626
from protoplaster.tests.i2c_mux.TCA9548A.test import __file__ as TCA9548A_test
27+
from protoplaster.tests.usb.test import __file__ as usb_test
2728
from protoplaster.tests.simple.test import __file__ as simple_test
2829
from protoplaster.tests.http_echo.test import __file__ as http_echo_test
2930
from protoplaster.tools.tools import pr_err, pr_info, pr_warn
@@ -51,6 +52,7 @@
5152
"simple": simple_test,
5253
"ti_dac38j8x_eyescan": ti_dac38j8x_eyescan_test,
5354
"http_echo": http_echo_test,
55+
"usb": usb_test,
5456
}
5557

5658

protoplaster/tests/usb/__init__.py

Whitespace-only changes.

protoplaster/tests/usb/test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from protoplaster.conf.module import ModuleName
2+
import os
3+
4+
5+
@ModuleName("usb")
6+
class TestUsb:
7+
8+
def setup_class(self):
9+
assert hasattr(self, "device"), "'device' is an obligatory argument"
10+
self.sysfs_path = f"/sys/bus/usb/devices/{self.device}"
11+
12+
def test_sysfs_interface(self):
13+
"""
14+
{% macro test_sysfs_interface(device) -%}
15+
check if the sysfs interface exists: `{{ device['sysfs_path'] }}`
16+
{%- endmacro %}
17+
"""
18+
assert os.path.exists(
19+
self.sysfs_path), f"USB interface {self.sysfs_path} doesn't exist"
20+
21+
def name(self):
22+
return f"usb({self.device})"

0 commit comments

Comments
 (0)