Chromium Code Reviews| Index: tools/perf/contrib/cros_benchmarks/cros_utils.py |
| diff --git a/tools/perf/contrib/cros_benchmarks/cros_utils.py b/tools/perf/contrib/cros_benchmarks/cros_utils.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dafbb922c7651ecee735ca659cb32fd41a1a09ac |
| --- /dev/null |
| +++ b/tools/perf/contrib/cros_benchmarks/cros_utils.py |
| @@ -0,0 +1,45 @@ |
| +# Copyright 2017 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import os |
| +import subprocess |
| + |
| +def FindKeyboardDevice(dut_ip): |
| + # find the device support events EV=120013 |
|
bccheng
2017/05/19 09:09:14
find if the device supports event "EV=120013"
deanliao_goog
2017/05/19 09:49:46
Comment should be English sentence, which means it
vovoy
2017/05/22 03:54:07
Done.
|
| + cmd = ['ssh', 'root@' + dut_ip, 'cat', '/proc/bus/input/devices'] |
| + p = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
| + out = p.communicate()[0] |
| + for line in out.splitlines(): |
| + handler_prefix = 'H: Handlers=' |
| + if line.startswith(handler_prefix): |
| + handlers = line[len(handler_prefix):].split() |
| + kbd_event = 'B: EV=120013' |
| + if line.startswith(kbd_event): |
| + for handler in handlers: |
| + if handler.startswith('event'): |
| + return '/dev/input/' + handler |
| + raise Exception('keyboard device not found') |
| + |
| +def SetupKeyDispatch(dut_ip): |
| + cur_dir=os.path.dirname(os.path.abspath(__file__)) |
|
bccheng
2017/05/19 09:09:14
space around =
vovoy
2017/05/22 03:54:07
Done.
|
| + send_key_filename = cur_dir + '/data/send_key_tab_switch' |
| + log_key_filename = cur_dir + '/data/log_key_tab_switch' |
| + |
| + kbd_dev = FindKeyboardDevice(dut_ip) |
| + send_key_content = '#!/bin/bash\n' |
| + send_key_content += ('evemu-play --insert-slot0 ' + kbd_dev + |
| + ' < /home/root/log_key_tab_switch') |
| + with open(send_key_filename, 'w') as f: |
| + f.write(send_key_content) |
| + os.chmod(send_key_filename, 0774) |
| + |
| + os.system('scp -q %s root@%s:/usr/local/tmp/' % (log_key_filename, dut_ip)) |
| + os.system('scp -q %s root@%s:/usr/local/tmp/' % (send_key_filename, dut_ip)) |
| + |
| +def SwitchTab(platform_backend): |
| + platform_backend.RunCommand('/usr/local/tmp/send_key_tab_switch') |
| + |
| +def NoScreenOff(platform_backend): |
| + platform_backend.RunCommand('set_power_policy --ac_screen_off_delay=3600') |
| + platform_backend.RunCommand('set_power_policy --ac_screen_dim_delay=3500') |