| 1 |
# Copyright 2024 Google LLC |
| 2 |
# |
| 3 |
# Use of this source code is governed by a BSD-style license that can be |
| 4 |
# found in the LICENSE file. |
| 5 |
|
| 6 |
import os |
| 7 |
import subprocess |
| 8 |
import sys |
| 9 |
import time |
| 10 |
|
| 11 |
ADB = sys.argv[1] |
| 12 |
cpu = int(sys.argv[2]) |
| 13 |
gov = sys.argv[3] |
| 14 |
|
| 15 |
log = subprocess.check_output([ADB, 'root']).decode('utf-8') |
| 16 |
# check for message like 'adbd cannot run as root in production builds' |
| 17 |
print(log) |
| 18 |
if 'cannot' in log: |
| 19 |
raise Exception('adb root failed') |
| 20 |
|
| 21 |
subprocess.check_output([ |
| 22 |
ADB, 'shell', |
| 23 |
'echo "%s" > /sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor' % ( |
| 24 |
gov, cpu)]).decode('utf-8') |
| 25 |
actual_gov = subprocess.check_output([ |
| 26 |
ADB, 'shell', 'cat /sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor' % |
| 27 |
cpu]).decode('utf-8').strip() |
| 28 |
if actual_gov != gov: |
| 29 |
raise Exception('(actual, expected) (%s, %s)' % (actual_gov, gov)) |