Skip to content

Commit 472e2f9

Browse files
author
Matthew West
committed
Fix PWM test failure on some Debian 8.5, Linux 4.4
#108 (comment)
1 parent 0b8def4 commit 472e2f9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/test_pwm_setup.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22
import os
33
import platform
4+
import glob
45

56
import Adafruit_BBIO.PWM as PWM
67

@@ -16,7 +17,16 @@ def test_start_pwm(self):
1617
PWM.start("P9_14", 0)
1718

1819
if kernel >= '4.1.0':
19-
pwm_dir = "/sys/devices/platform/ocp/48302000.epwmss/48302200.ehrpwm/pwm/pwmchip2/pwm0"
20+
# On 4.1+, the pwm subdirectory sometimes takes different names:
21+
# .pwm or .ehrpwm, etc.
22+
results = glob.glob(
23+
"/sys/devices/platform/ocp/48302000.*/" +
24+
"48302200.*/pwm/pwmchip2/pwm0")
25+
# We expect that there will be a result (a directory fitting
26+
# our path exists) so test that with an assertion.
27+
assert len(results) > 0
28+
# Continue with the pwm_dir found
29+
pwm_dir = results[0]
2030
else:
2131
files = os.listdir('/sys/devices')
2232
ocp = '/sys/devices/'+[s for s in files if s.startswith('ocp')][0]

0 commit comments

Comments
 (0)