Flutter Engine
The Flutter Engine
set_cpu_online.py
Go to the documentation of this file.
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])
13value = int(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
21# If we try to echo 1 to an already online cpu, adb returns exit code 1.
22# So, check the value before trying to write it.
23prior_status = subprocess.check_output([ADB, 'shell', 'cat '
24 '/sys/devices/system/cpu/cpu%d/online' % cpu]).decode('utf-8').strip()
25if prior_status == str(value):
26 print('CPU %d online already %d' % (cpu, value))
27 sys.exit()
28
29subprocess.check_call([ADB, 'shell', 'echo %s > '
30 '/sys/devices/system/cpu/cpu%d/online' % (value, cpu)])
31actual_status = subprocess.check_output([ADB, 'shell', 'cat '
32 '/sys/devices/system/cpu/cpu%d/online' % cpu]).decode('utf-8').strip()
33if actual_status != str(value):
34 raise Exception('(actual, expected) (%s, %d)' % (actual_status, value))
def print(*args, **kwargs)
Definition: run_tests.py:49
static DecodeResult decode(std::string path)
Definition: png_codec.cpp:124