diff options
author | Jonathan Cave <jonathan.cave@canonical.com> | 2019-12-12 16:52:13 +0800 |
---|---|---|
committer | Jonathan Cave <jonathan.cave@canonical.com> | 2019-12-19 10:50:02 +0000 |
commit | 6fa95f482b6d63f78c37937942ac86586a28f126 (patch) | |
tree | 23113035520f563777e034fd970810e5546ac38d | |
parent | 8ab9cf164babdd2156f639b44ec9f1cf15fe1677 (diff) |
monitor: rework hdmi hotlpug for chamelon board
Switch from use of the MuxPi to the chameleon board/service to carry out an automated HDMI hotplug test.
-rwxr-xr-x | bin/chameleon_hdmi_hotplug.py | 74 | ||||
-rw-r--r-- | units/monitor/jobs.pxu | 16 |
2 files changed, 77 insertions, 13 deletions
diff --git a/bin/chameleon_hdmi_hotplug.py b/bin/chameleon_hdmi_hotplug.py new file mode 100755 index 0000000..7366886 --- /dev/null +++ b/bin/chameleon_hdmi_hotplug.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 + +import sys +import time + +import xmlrpc.client + + +def Chameleon(host, port=9992): + """ + Get a proxy object that is used to control the Chameleon board. + + The interface definition for this object can be found at: + https://chromium.googlesource.com/chromiumos/platform/chameleon/+/refs/heads/master/chameleond/interface.py + """ + print('== Chameleon connection ==') + print('Target device: {}:{}'.format(host, port)) + proxy = xmlrpc.client.ServerProxy('http://{}:{}'.format(host, port)) + try: + # test the proxy works + mac = proxy.GetMacAddress() + print('MAC address: {}'.format(mac)) + except OSError as e: + print(e) + raise SystemExit('ERROR connecting to Chameleon board') + print() + return proxy + + +def get_hdmi_port(chameleon): + supported_ports = chameleon.GetSupportedPorts() + for port in supported_ports: + port_type = chameleon.GetConnectorType(port) + if port_type == 'HDMI': + return port + + +def get_hdmi_status(drm_id): + path = '/sys/class/drm/{}/status'.format(drm_id) + with open(path) as sys_f: + return sys_f.readline().strip() + + +if __name__ == '__main__': + drm_id = sys.argv[1] + c = Chameleon(sys.argv[2]) + + start = get_hdmi_status(drm_id) + print('Starting status: {}'.format(start)) + print(flush=True) + + port_num = get_hdmi_port(c) + + print('chameleon> plug hdmi') + c.Plug(port_num) + time.sleep(10) + + new_status = get_hdmi_status(drm_id) + print('Status after plug request: {}'.format(new_status)) + print(flush=True) + if new_status != 'connected': + raise SystemExit('FAIL: hdmi not connected') + + print('chameleon> unplug hdmi') + c.Unplug(port_num) + time.sleep(10) + + final_status = get_hdmi_status(drm_id) + print('Status after unplug request: {}'.format(final_status)) + print(flush=True) + if final_status != 'disconnected': + raise SystemExit('FAIL: hdmi did not disconnect') + + print('PASS') diff --git a/units/monitor/jobs.pxu b/units/monitor/jobs.pxu index df1bb95..59efbf7 100644 --- a/units/monitor/jobs.pxu +++ b/units/monitor/jobs.pxu @@ -403,17 +403,7 @@ plugin: shell category_id: com.canonical.plainbox::monitor _summary: Automated HDMI hotplug test _description: - This test will use edid injector on muxpi to check if system detect HDMI hotplug -environ: HDMI_PORT MUXPI_IP -requires: manifest.has_muxpi_hdmi == 'True' -imports: from com.canonical.plainbox import manifest + Use chamleon board to simulate connection/disconnection of an HDMI monitor. +environ: HDMI_PORT CHAMELEON_IP command: - export SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" - timeout 60 ssh $SSH_OPTS ubuntu@$MUXPI_IP "stm -hdmi off" || exit 1 - sleep 3 - timeout 60 ssh $SSH_OPTS ubuntu@$MUXPI_IP "stm -hdmi on" || exit 1 - sleep 3 - if [ "$(cat /sys/class/drm/$HDMI_PORT/status)" != "connected" ] ;then exit 1; fi - timeout 60 ssh $SSH_OPTS ubuntu@$MUXPI_IP "stm -hdmi off" || exit 1 - sleep 3 - if [ "$(cat /sys/class/drm/$HDMI_PORT/status)" != "disconnected" ] ;then exit 1; fi + chameleon_hdmi_hotplug.py $HDMI_PORT $CHAMELEON_IP |