summaryrefslogtreecommitdiff
diff options
-rwxr-xr-xbin/led_sysfs_brightness.py46
-rw-r--r--data/gpio-loopback.UPX-TGL01.in2
-rw-r--r--data/led-brightness.UPX-TGL01.in4
-rw-r--r--units/gpio/test-plan.pxu1
-rw-r--r--units/gpio/vendor-aaeon.pxu16
-rw-r--r--units/led/test-plan.pxu6
-rw-r--r--units/led/vendor-aaeon.pxu39
7 files changed, 112 insertions, 2 deletions
diff --git a/bin/led_sysfs_brightness.py b/bin/led_sysfs_brightness.py
new file mode 100755
index 0000000..a18f34d
--- /dev/null
+++ b/bin/led_sysfs_brightness.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+#
+# Written by:
+# Kunyang Fan <kunyang_fan@aaeon.com.tw>
+
+import os
+import sys
+
+
+def led_brightness_write(led, brightness):
+ print("{} brightness -> {}".format(led, brightness), flush=True)
+ # test led devices exist
+ if not os.path.exists('/sys/class/leds/{}/brightness'.format(led)):
+ raise SystemExit('External LED {} not exist'.format(led))
+
+ with open('/sys/class/leds/{}/brightness'.format(led), 'wt') as f:
+ f.write('{}\n'.format(brightness))
+
+
+def led_arrays(model_name):
+ led_data = os.path.expandvars(
+ '$PLAINBOX_PROVIDER_DATA/led-brightness.{}.in'.format(model_name))
+ if not os.path.exists(led_data):
+ raise SystemExit(
+ "ERROR: no led information found at: {}".format(led_data))
+ with open(led_data, 'r') as f:
+ for line in f:
+ if line.startswith('#'):
+ continue
+ yield line.strip()
+
+
+def main():
+ if len(sys.argv) < 3:
+ raise SystemExit('Usage: led_syfs_brightness.py MODEL_NAME on/off')
+ model_name = sys.argv[1]
+ if sys.argv[2] == 'on':
+ brightness = 255
+ else:
+ brightness = 0
+ for led in led_arrays(model_name):
+ led_brightness_write(led, brightness)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/data/gpio-loopback.UPX-TGL01.in b/data/gpio-loopback.UPX-TGL01.in
new file mode 100644
index 0000000..e705ad8
--- /dev/null
+++ b/data/gpio-loopback.UPX-TGL01.in
@@ -0,0 +1,2 @@
+# GPIO IDs as presented by sysfs that have paired together:
+22,27
diff --git a/data/led-brightness.UPX-TGL01.in b/data/led-brightness.UPX-TGL01.in
new file mode 100644
index 0000000..d4b4a9c
--- /dev/null
+++ b/data/led-brightness.UPX-TGL01.in
@@ -0,0 +1,4 @@
+# The LED IDs as presented by sysfs to test
+led:0:
+led:1:
+led:2: \ No newline at end of file
diff --git a/units/gpio/test-plan.pxu b/units/gpio/test-plan.pxu
index a32be08..91d83b5 100644
--- a/units/gpio/test-plan.pxu
+++ b/units/gpio/test-plan.pxu
@@ -25,6 +25,7 @@ _name: Automated GPIO tests
_description: Automated GPIO tests for Ubuntu Core devices
bootstrap_include:
model_assertion
+ dmi
include:
gpio/sysfs_loopback_pairs_.*
gpio/gpiomem_loopback_pairs_.*
diff --git a/units/gpio/vendor-aaeon.pxu b/units/gpio/vendor-aaeon.pxu
new file mode 100644
index 0000000..7f8d6bc
--- /dev/null
+++ b/units/gpio/vendor-aaeon.pxu
@@ -0,0 +1,16 @@
+
+unit: template
+template-resource: dmi
+template-filter: dmi.category == 'SYSTEM' and dmi.vendor == 'AAEON' and dmi.product in ('UPX-TGL01')
+template-unit: job
+id: gpio/sysfs_loopback_pairs_{vendor}_{product}
+_summary: Test GPIO lines exposed on headers can be controlled via sysfs
+plugin: shell
+user: root
+category_id: gpio
+estimated_duration: 30.0
+flags: preserve-locale also-after-suspend
+imports: from com.canonical.plainbox import manifest
+requires: manifest.gpio_loopback == 'True'
+command:
+ gpio_sysfs_loopback.py {product}
diff --git a/units/led/test-plan.pxu b/units/led/test-plan.pxu
index fc83aa2..b0d0129 100644
--- a/units/led/test-plan.pxu
+++ b/units/led/test-plan.pxu
@@ -115,5 +115,7 @@ include:
led/bluetooth
led/serial
led/fn
-
-
+ led/sysfs_led_brightness_on_.*
+ led/sysfs_led_brightness_off_.*
+bootstrap_include:
+ dmi
diff --git a/units/led/vendor-aaeon.pxu b/units/led/vendor-aaeon.pxu
new file mode 100644
index 0000000..d4ed7cd
--- /dev/null
+++ b/units/led/vendor-aaeon.pxu
@@ -0,0 +1,39 @@
+
+unit: template
+template-resource: dmi
+template-filter: dmi.category == 'SYSTEM' and dmi.vendor == 'AAEON' and dmi.product in ('UPX-TGL01')
+template-unit: job
+id: led/sysfs_led_brightness_on_{vendor}_{product}
+plugin: user-interact-verify
+category_id: led
+estimated_duration: 30.0
+flags: preserve-locale also-after-suspend
+command:
+ led_sysfs_brightness.py {product} on
+_purpose:
+ Verify that the leds_aaeon driver is working by setting all LEDs to maximum
+ brightness
+_steps:
+ Press ENTER to start the test while watching external LEDs on the SUT
+_verification:
+ The external LEDs should now be on at maximum brightness
+
+unit: template
+template-resource: dmi
+template-filter: dmi.category == 'SYSTEM' and dmi.vendor == 'AAEON' and dmi.product in ('UPX-TGL01')
+template-unit: job
+id: led/sysfs_led_brightness_off_{vendor}_{product}
+plugin: user-interact-verify
+category_id: led
+estimated_duration: 30.0
+flags: preserve-locale also-after-suspend
+depends: led/sysfs_led_brightness_on_{vendor}_{product}
+command:
+ led_sysfs_brightness.py {product} off
+_purpose:
+ Verify that the leds_aaeon driver is working by setting all LEDs to off /
+ minimum brightness
+_steps:
+ Press ENTER to start the test while watching external LEDs on the SUT
+_verification:
+ The external LEDs should now be off or at minimum brightness