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 6import os 7import subprocess 8import sys 9import time 10 11ADB = sys.argv[1] 12cpu = int(sys.argv[2]) 13gov = sys.argv[3] 14 15log = subprocess.check_output([ADB, 'root']).decode('utf-8') 16# check for message like 'adbd cannot run as root in production builds' 17print(log) 18if 'cannot' in log: 19 raise Exception('adb root failed') 20 21subprocess.check_output([ 22 ADB, 'shell', 23 'echo "%s" > /sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor' % ( 24 gov, cpu)]).decode('utf-8') 25actual_gov = subprocess.check_output([ 26 ADB, 'shell', 'cat /sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor' % 27 cpu]).decode('utf-8').strip() 28if actual_gov != gov: 29 raise Exception('(actual, expected) (%s, %s)' % (actual_gov, gov)) 30