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] 12freq = sys.argv[2] 13idle_timer = "10000" 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([ADB, 'shell', 'stop', 'thermald']).decode('utf-8') 22 23subprocess.check_output([ADB, 'shell', 'echo "%s" > ' 24 '/sys/class/kgsl/kgsl-3d0/gpuclk' % freq]).decode('utf-8') 25 26actual_freq = subprocess.check_output([ADB, 'shell', 'cat ' 27 '/sys/class/kgsl/kgsl-3d0/gpuclk']).decode('utf-8').strip() 28if actual_freq != freq: 29 raise Exception('Frequency (actual, expected) (%s, %s)' 30 % (actual_freq, freq)) 31 32subprocess.check_call([ADB, 'shell', 'echo "%s" > ' 33 '/sys/class/kgsl/kgsl-3d0/idle_timer' % idle_timer]) 34 35actual_timer = subprocess.check_output([ADB, 'shell', 'cat ' 36 '/sys/class/kgsl/kgsl-3d0/idle_timer']).decode('utf-8').strip() 37if actual_timer != idle_timer: 38 raise Exception('idle_timer (actual, expected) (%s, %s)' 39 % (actual_timer, idle_timer)) 40 41for s in ['force_bus_on', 'force_rail_on', 'force_clk_on']: 42 subprocess.check_call([ADB, 'shell', 'echo "1" > ' 43 '/sys/class/kgsl/kgsl-3d0/%s' % s]) 44 actual_set = subprocess.check_output([ADB, 'shell', 'cat ' 45 '/sys/class/kgsl/kgsl-3d0/%s' % s]).decode('utf-8').strip() 46 if actual_set != "1": 47 raise Exception('%s (actual, expected) (%s, 1)' 48 % (s, actual_set)) 49