summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2022-07-14 14:19:14 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-26 19:43:40 +0000
commitf37d95b3edc6ff7bbda96fe7a4147273db66c306 (patch)
treeaaf408cfa525efce460cddb4153101b1db492109 /util
parent160af3cb3634f645ef0ca1a3c312c68cc3316869 (diff)
downloadchrome-ec-f37d95b3edc6ff7bbda96fe7a4147273db66c306.tar.gz
ec: Switch black to 80 cols and reformat files
Add pyproject.toml config file to set black to 80 columns. Remove column length overrides from other config files. Reformat python files to 80 cols. BRANCH=None BUG=b:238434058 TEST=presubmit/CQ Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I870a68f1bb751f4bad97024045f6e3075489e80f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3764071 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/build_with_clang.py7
-rwxr-xr-xutil/config_option_check.py12
-rwxr-xr-xutil/ec3po/console.py98
-rwxr-xr-xutil/ec3po/console_unittest.py18
-rw-r--r--util/ec3po/interpreter.py20
-rwxr-xr-xutil/ec3po/interpreter_unittest.py44
-rwxr-xr-xutil/ec_openocd.py13
-rwxr-xr-xutil/flash_jlink.py12
-rwxr-xr-xutil/fptool.py4
-rwxr-xr-xutil/inject-keys.py7
-rwxr-xr-xutil/kconfig_check.py39
-rw-r--r--util/run_ects.py5
-rw-r--r--util/test_kconfig_check.py15
-rwxr-xr-xutil/twister_launcher.py4
-rwxr-xr-xutil/uart_stress_tester.py37
-rwxr-xr-xutil/update_release_branch.py21
-rwxr-xr-xutil/zephyr_to_resultdb.py4
17 files changed, 275 insertions, 85 deletions
diff --git a/util/build_with_clang.py b/util/build_with_clang.py
index 98da942152..3606e53657 100755
--- a/util/build_with_clang.py
+++ b/util/build_with_clang.py
@@ -41,7 +41,9 @@ def main() -> int:
parser = argparse.ArgumentParser()
log_level_choices = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
- parser.add_argument("--log_level", "-l", choices=log_level_choices, default="DEBUG")
+ parser.add_argument(
+ "--log_level", "-l", choices=log_level_choices, default="DEBUG"
+ )
parser.add_argument(
"--num_threads", "-j", type=int, default=multiprocessing.cpu_count()
@@ -67,7 +69,8 @@ def main() -> int:
if len(failed_boards) > 0:
logging.error(
- "The following boards failed to compile:\n%s", "\n".join(failed_boards)
+ "The following boards failed to compile:\n%s",
+ "\n".join(failed_boards),
)
return 1
diff --git a/util/config_option_check.py b/util/config_option_check.py
index 8263e61709..c1e57dfc82 100755
--- a/util/config_option_check.py
+++ b/util/config_option_check.py
@@ -172,7 +172,8 @@ def print_missing_config_options(hunks, config_options):
for l in h.lines:
# Check for the existence of a CONFIG_* in the line.
match = filter(
- lambda opt: opt in ALLOWLIST_CONFIGS, config_option_re.findall(l.string)
+ lambda opt: opt in ALLOWLIST_CONFIGS,
+ config_option_re.findall(l.string),
)
if not match:
continue
@@ -189,7 +190,10 @@ def print_missing_config_options(hunks, config_options):
# is no longer being used in the entire repo.
if l.line_type == "-":
- if option not in options_in_use and option in config_options:
+ if (
+ option not in options_in_use
+ and option in config_options
+ ):
deprecated_options.add(option)
else:
violations.add(option)
@@ -370,7 +374,9 @@ def get_hunks():
line_type = match.groups(1)[0]
# We only care about modifications.
if line_type != " ":
- hunk_lines.append(Line(line_num, match.groups(2)[1], line_type))
+ hunk_lines.append(
+ Line(line_num, match.groups(2)[1], line_type)
+ )
# Deletions don't count towards the line numbers.
if line_type != "-":
line_num += 1
diff --git a/util/ec3po/console.py b/util/ec3po/console.py
index 3b3c1c89f5..289c40f825 100755
--- a/util/ec3po/console.py
+++ b/util/ec3po/console.py
@@ -140,7 +140,13 @@ class Console(object):
"""
def __init__(
- self, controller_pty, user_pty, interface_pty, cmd_pipe, dbg_pipe, name=None
+ self,
+ controller_pty,
+ user_pty,
+ interface_pty,
+ cmd_pipe,
+ dbg_pipe,
+ name=None,
):
"""Initalises a Console object with the provided arguments.
@@ -320,7 +326,9 @@ class Console(object):
# Restore the partial cmd.
if self.history_pos == len(self.history):
- self.logger.debug("Restoring partial command of %r", self.partial_cmd)
+ self.logger.debug(
+ "Restoring partial command of %r", self.partial_cmd
+ )
# Backspace the line.
for _ in range(self.input_buffer_pos):
self.SendBackspace()
@@ -439,7 +447,9 @@ class Console(object):
else:
self.logger.error(
- r"Bad or unhandled escape sequence. got ^[%c\(%d)", chr(byte), byte
+ r"Bad or unhandled escape sequence. got ^[%c\(%d)",
+ chr(byte),
+ byte,
)
self.esc_state = 0
return
@@ -468,7 +478,9 @@ class Console(object):
# END key.
if byte == ord("~"):
self.logger.debug("End key pressed.")
- self.MoveCursor("right", len(self.input_buffer) - self.input_buffer_pos)
+ self.MoveCursor(
+ "right", len(self.input_buffer) - self.input_buffer_pos
+ )
self.esc_state = 0 # Reset the state.
self.logger.debug("ESC sequence complete.")
return
@@ -488,7 +500,11 @@ class Console(object):
return
# Don't store 2 consecutive identical commands in the history.
- if self.history and self.history[-1] != self.input_buffer or not self.history:
+ if (
+ self.history
+ and self.history[-1] != self.input_buffer
+ or not self.history
+ ):
self.history.append(self.input_buffer)
# Split the command up by spaces.
@@ -536,13 +552,15 @@ class Console(object):
# Increase the interrogation timeout for stability purposes.
self.interrogation_timeout = ENHANCED_EC_INTERROGATION_TIMEOUT
self.logger.debug(
- "Increasing interrogation timeout to %rs.", self.interrogation_timeout
+ "Increasing interrogation timeout to %rs.",
+ self.interrogation_timeout,
)
else:
# Reduce the timeout in order to reduce the perceivable delay.
self.interrogation_timeout = NON_ENHANCED_EC_INTERROGATION_TIMEOUT
self.logger.debug(
- "Reducing interrogation timeout to %rs.", self.interrogation_timeout
+ "Reducing interrogation timeout to %rs.",
+ self.interrogation_timeout,
)
return is_enhanced
@@ -582,7 +600,8 @@ class Console(object):
if self.pending_oobm_cmd:
self.oobm_queue.put(self.pending_oobm_cmd)
self.logger.debug(
- "Placed %r into OOBM command queue.", self.pending_oobm_cmd
+ "Placed %r into OOBM command queue.",
+ self.pending_oobm_cmd,
)
# Reset the state.
@@ -687,7 +706,9 @@ class Console(object):
# Ctrl+E. Move cursor to end of the line.
elif byte == ControlKey.CTRL_E:
self.logger.debug("Control+E pressed.")
- self.MoveCursor("right", len(self.input_buffer) - self.input_buffer_pos)
+ self.MoveCursor(
+ "right", len(self.input_buffer) - self.input_buffer_pos
+ )
# Ctrl+F. Move cursor right 1 column.
elif byte == ControlKey.CTRL_F:
@@ -776,7 +797,9 @@ class Console(object):
self.input_buffer_pos += count
else:
- raise AssertionError(("The only valid directions are 'left' and 'right'"))
+ raise AssertionError(
+ ("The only valid directions are 'left' and 'right'")
+ )
self.logger.debug("input_buffer_pos: %d", self.input_buffer_pos)
# Move the cursor.
@@ -792,7 +815,8 @@ class Console(object):
# correct the cursor.
if diff < 0:
self.logger.warning(
- "Resetting input buffer position to %d...", len(self.input_buffer)
+ "Resetting input buffer position to %d...",
+ len(self.input_buffer),
)
self.MoveCursor("left", -diff)
return
@@ -835,14 +859,16 @@ class Console(object):
mode = cmd[1].lower()
self.timestamp_enabled = mode == b"on"
self.logger.info(
- "%sabling uart timestamps.", "En" if self.timestamp_enabled else "Dis"
+ "%sabling uart timestamps.",
+ "En" if self.timestamp_enabled else "Dis",
)
elif cmd[0] == b"rawdebug":
mode = cmd[1].lower()
self.raw_debug = mode == b"on"
self.logger.info(
- "%sabling per interrupt debug logs.", "En" if self.raw_debug else "Dis"
+ "%sabling per interrupt debug logs.",
+ "En" if self.raw_debug else "Dis",
)
elif cmd[0] == b"interrogate" and len(cmd) >= 2:
@@ -858,10 +884,14 @@ class Console(object):
# Update the assumptions of the EC image.
self.enhanced_ec = enhanced
- self.logger.debug("Enhanced EC image is now %r", self.enhanced_ec)
+ self.logger.debug(
+ "Enhanced EC image is now %r", self.enhanced_ec
+ )
# Send command to interpreter as well.
- self.cmd_pipe.send(b"enhanced " + str(self.enhanced_ec).encode("ascii"))
+ self.cmd_pipe.send(
+ b"enhanced " + str(self.enhanced_ec).encode("ascii")
+ )
else:
self.PrintOOBMHelp()
@@ -904,7 +934,9 @@ class Console(object):
self.enhanced_ec = False
# Inform the interpreter of the result.
- self.cmd_pipe.send(b"enhanced " + str(self.enhanced_ec).encode("ascii"))
+ self.cmd_pipe.send(
+ b"enhanced " + str(self.enhanced_ec).encode("ascii")
+ )
self.logger.debug("Enhanced EC image? %r", self.enhanced_ec)
# Clear look buffer since a match was found.
@@ -952,7 +984,9 @@ def StartLoop(console, command_active, shutdown_pipe=None):
"""
try:
console.logger.debug("Console is being served on %s.", console.user_pty)
- console.logger.debug("Console controller is on %s.", console.controller_pty)
+ console.logger.debug(
+ "Console controller is on %s.", console.controller_pty
+ )
console.logger.debug(
"Command interface is being served on %s.", console.interface_pty
)
@@ -975,7 +1009,11 @@ def StartLoop(console, command_active, shutdown_pipe=None):
controller_connected = not events
# Check to see if pipes or the console are ready for reading.
- read_list = [console.interface_pty, console.cmd_pipe, console.dbg_pipe]
+ read_list = [
+ console.interface_pty,
+ console.cmd_pipe,
+ console.dbg_pipe,
+ ]
if controller_connected:
read_list.append(console.controller_pty)
if shutdown_pipe is not None:
@@ -995,7 +1033,9 @@ def StartLoop(console, command_active, shutdown_pipe=None):
# Ctrl+A, Ctrl+E, etc.
try:
line = bytearray(
- os.read(console.controller_pty, CONSOLE_MAX_READ)
+ os.read(
+ console.controller_pty, CONSOLE_MAX_READ
+ )
)
console.logger.debug(
"Input from user: %s, locked:%s",
@@ -1046,7 +1086,9 @@ def StartLoop(console, command_active, shutdown_pipe=None):
try:
data = console.cmd_pipe.recv()
except EOFError:
- console.logger.debug("ec3po console received EOF from cmd_pipe")
+ console.logger.debug(
+ "ec3po console received EOF from cmd_pipe"
+ )
continue_looping = False
else:
# Write it to the user console.
@@ -1066,7 +1108,9 @@ def StartLoop(console, command_active, shutdown_pipe=None):
try:
data = console.dbg_pipe.recv()
except EOFError:
- console.logger.debug("ec3po console received EOF from dbg_pipe")
+ console.logger.debug(
+ "ec3po console received EOF from dbg_pipe"
+ )
continue_looping = False
else:
if console.interrogation_mode == b"auto":
@@ -1151,10 +1195,14 @@ def main(argv):
)
parser.add_argument(
"ec_uart_pty",
- help=("The full PTY name that the EC UART is present on. eg: /dev/pts/12"),
+ help=(
+ "The full PTY name that the EC UART is present on. eg: /dev/pts/12"
+ ),
)
parser.add_argument(
- "--log-level", default="info", help="info, debug, warning, error, or critical"
+ "--log-level",
+ default="info",
+ help="info, debug, warning, error, or critical",
)
# Parse arguments.
@@ -1173,7 +1221,9 @@ def main(argv):
elif opts.log_level == "critical":
log_level = logging.CRITICAL
else:
- parser.error("Invalid log level. (info, debug, warning, error, critical)")
+ parser.error(
+ "Invalid log level. (info, debug, warning, error, critical)"
+ )
# Start logging with a timestamp, module, and log level shown in each log
# entry.
diff --git a/util/ec3po/console_unittest.py b/util/ec3po/console_unittest.py
index 45ab2ff44c..dcf66810e0 100755
--- a/util/ec3po/console_unittest.py
+++ b/util/ec3po/console_unittest.py
@@ -625,7 +625,9 @@ class TestConsoleEditingMethods(unittest.TestCase):
# We expect the test string, followed by a jump to the beginning of the
# line, and finally a move right 1.
- exp_console_out = test_str + OutputStream.MoveCursorLeft(len((test_str)))
+ exp_console_out = test_str + OutputStream.MoveCursorLeft(
+ len((test_str))
+ )
# A move right 1 column.
exp_console_out += OutputStream.MoveCursorRight(1)
@@ -653,7 +655,9 @@ class TestConsoleEditingMethods(unittest.TestCase):
# We expect the test string, followed by a jump to the beginning of the
# line, and finally a move right 1.
- exp_console_out = test_str + OutputStream.MoveCursorLeft(len((test_str)))
+ exp_console_out = test_str + OutputStream.MoveCursorLeft(
+ len((test_str))
+ )
# A move right 1 column.
exp_console_out += OutputStream.MoveCursorRight(1)
@@ -704,7 +708,9 @@ class TestConsoleEditingMethods(unittest.TestCase):
test_str = b"accelinfo on"
input_stream = BytesToByteList(test_str)
# Jump to beginning of line and then kill it with Ctrl+K.
- input_stream.extend([console.ControlKey.CTRL_A, console.ControlKey.CTRL_K])
+ input_stream.extend(
+ [console.ControlKey.CTRL_A, console.ControlKey.CTRL_K]
+ )
# Send the sequence out.
for byte in input_stream:
@@ -1207,7 +1213,8 @@ class TestConsoleCompatibility(unittest.TestCase):
# At this point, we should have negotiated to enhanced.
self.assertTrue(
- self.console.enhanced_ec, msg=("Did not negotiate to enhanced EC image.")
+ self.console.enhanced_ec,
+ msg=("Did not negotiate to enhanced EC image."),
)
# The command would have been dropped however, so verify this...
@@ -1623,7 +1630,8 @@ class TestOOBMConsoleCommands(unittest.TestCase):
# The EC image should be assumed to be enhanced.
self.assertTrue(
- self.console.enhanced_ec, "The image should be assumed to be enhanced."
+ self.console.enhanced_ec,
+ "The image should be assumed to be enhanced.",
)
diff --git a/util/ec3po/interpreter.py b/util/ec3po/interpreter.py
index 591603e038..bfe7d1ed8d 100644
--- a/util/ec3po/interpreter.py
+++ b/util/ec3po/interpreter.py
@@ -147,7 +147,9 @@ class Interpreter(object):
command: A string which contains the command to be sent.
"""
self.ec_cmd_queue.put(command)
- self.logger.log(1, "Commands now in queue: %d", self.ec_cmd_queue.qsize())
+ self.logger.log(
+ 1, "Commands now in queue: %d", self.ec_cmd_queue.qsize()
+ )
# Add the EC UART as an output to be serviced.
if self.connected and self.ec_uart_pty not in self.outputs:
@@ -215,12 +217,16 @@ class Interpreter(object):
self.inputs.remove(fileobj)
if fileobj in self.outputs:
self.outputs.remove(fileobj)
- self.logger.debug("Removed fileobj. Remaining inputs: %r", self.inputs)
+ self.logger.debug(
+ "Removed fileobj. Remaining inputs: %r", self.inputs
+ )
# Close the file.
fileobj.close()
# Mark the interpreter as disconnected now.
self.connected = False
- self.logger.debug("Disconnected from %s.", self.ec_uart_pty_name)
+ self.logger.debug(
+ "Disconnected from %s.", self.ec_uart_pty_name
+ )
return
elif command == b"reconnect":
@@ -248,7 +254,9 @@ class Interpreter(object):
# Ignore any other commands while in the disconnected state.
self.logger.log(1, "command: '%s'", command)
if not self.connected:
- self.logger.debug("Ignoring command because currently disconnected.")
+ self.logger.debug(
+ "Ignoring command because currently disconnected."
+ )
return
# Remove leading and trailing spaces only if this is an enhanced EC image.
@@ -354,7 +362,9 @@ class Interpreter(object):
if self.enhanced_ec:
self.logger.debug("The current EC image seems enhanced.")
else:
- self.logger.debug("The current EC image does NOT seem enhanced.")
+ self.logger.debug(
+ "The current EC image does NOT seem enhanced."
+ )
# Done interrogating.
self.interrogating = False
# For now, just forward everything the EC sends us.
diff --git a/util/ec3po/interpreter_unittest.py b/util/ec3po/interpreter_unittest.py
index 73188fab9f..b7a29baa57 100755
--- a/util/ec3po/interpreter_unittest.py
+++ b/util/ec3po/interpreter_unittest.py
@@ -40,7 +40,9 @@ class TestEnhancedECBehaviour(unittest.TestCase):
# Create the pipes that the interpreter will use.
self.cmd_pipe_user, self.cmd_pipe_itpr = threadproc_shim.Pipe()
- self.dbg_pipe_user, self.dbg_pipe_itpr = threadproc_shim.Pipe(duplex=False)
+ self.dbg_pipe_user, self.dbg_pipe_itpr = threadproc_shim.Pipe(
+ duplex=False
+ )
# Mock the open() function so we can inspect reads/writes to the EC.
self.ec_uart_pty = mock.mock_open()
@@ -91,7 +93,9 @@ class TestEnhancedECBehaviour(unittest.TestCase):
self.itpr.HandleUserData()
self.itpr.SendCmdToEC()
# Since the EC image is enhanced, we should have sent a packed command.
- expected_ec_calls.append(mock.call().write(self.itpr.PackCommand(test_cmd)))
+ expected_ec_calls.append(
+ mock.call().write(self.itpr.PackCommand(test_cmd))
+ )
expected_ec_calls.append(mock.call().flush())
# Now that the first command was sent, we should send another command which
@@ -116,7 +120,9 @@ class TestEnhancedECBehaviour(unittest.TestCase):
self.itpr.HandleUserData()
self.itpr.SendCmdToEC()
# Since the EC image is enhanced, we should have sent a packed command.
- expected_ec_calls.append(mock.call().write(self.itpr.PackCommand(test_cmd)))
+ expected_ec_calls.append(
+ mock.call().write(self.itpr.PackCommand(test_cmd))
+ )
expected_ec_calls.append(mock.call().flush())
# Finally, verify that the appropriate writes were actually sent to the EC.
@@ -156,7 +162,9 @@ class TestEnhancedECBehaviour(unittest.TestCase):
self.itpr.HandleUserData()
self.itpr.SendCmdToEC()
packed_cmd = self.itpr.PackCommand(test_cmd)
- expected_ec_calls.extend([mock.call().write(packed_cmd), mock.call().flush()])
+ expected_ec_calls.extend(
+ [mock.call().write(packed_cmd), mock.call().flush()]
+ )
# Have the EC return the error string twice.
mock_os.read.side_effect = [b"&&EE", b"&&EE"]
for i in range(2):
@@ -180,7 +188,9 @@ class TestEnhancedECBehaviour(unittest.TestCase):
self.itpr.SendCmdToEC()
# Now assume that the last one goes through with no trouble.
- expected_ec_calls.extend([mock.call().write(packed_cmd), mock.call().flush()])
+ expected_ec_calls.extend(
+ [mock.call().write(packed_cmd), mock.call().flush()]
+ )
self.itpr.SendCmdToEC()
# Verify all the calls.
@@ -247,7 +257,9 @@ class TestEnhancedECBehaviour(unittest.TestCase):
# Now, the interrogation should be complete and we should know that the
# current EC image is enhanced.
- self.assertFalse(self.itpr.interrogating, msg=("interrogating should be False"))
+ self.assertFalse(
+ self.itpr.interrogating, msg=("interrogating should be False")
+ )
self.assertTrue(self.itpr.enhanced_ec, msg="enhanced_ec sholud be True")
# Now let's perform another interrogation, but pretend that the EC ignores
@@ -259,7 +271,9 @@ class TestEnhancedECBehaviour(unittest.TestCase):
self.assertTrue(self.itpr.interrogating, "interrogating sholud be True")
# We should assume that the image is not enhanced until we get the valid
# response.
- self.assertFalse(self.itpr.enhanced_ec, "enhanced_ec should be False now.")
+ self.assertFalse(
+ self.itpr.enhanced_ec, "enhanced_ec should be False now."
+ )
# Let's pretend that we get a random debug print. This should clear the
# interrogating flag.
@@ -267,8 +281,12 @@ class TestEnhancedECBehaviour(unittest.TestCase):
self.itpr.HandleECData()
# Verify that interrogating flag is cleared and enhanced_ec is still False.
- self.assertFalse(self.itpr.interrogating, "interrogating should be False.")
- self.assertFalse(self.itpr.enhanced_ec, "enhanced_ec should still be False.")
+ self.assertFalse(
+ self.itpr.interrogating, "interrogating should be False."
+ )
+ self.assertFalse(
+ self.itpr.enhanced_ec, "enhanced_ec should still be False."
+ )
class TestUARTDisconnection(unittest.TestCase):
@@ -287,7 +305,9 @@ class TestUARTDisconnection(unittest.TestCase):
# Create the pipes that the interpreter will use.
self.cmd_pipe_user, self.cmd_pipe_itpr = threadproc_shim.Pipe()
- self.dbg_pipe_user, self.dbg_pipe_itpr = threadproc_shim.Pipe(duplex=False)
+ self.dbg_pipe_user, self.dbg_pipe_itpr = threadproc_shim.Pipe(
+ duplex=False
+ )
# Mock the open() function so we can inspect reads/writes to the EC.
self.ec_uart_pty = mock.mock_open()
@@ -383,7 +403,9 @@ class TestUARTDisconnection(unittest.TestCase):
self.itpr.HandleUserData()
# Verify interpreter is connected.
- self.assertTrue(self.itpr.connected, ("The interpreter should be connected."))
+ self.assertTrue(
+ self.itpr.connected, ("The interpreter should be connected.")
+ )
# Verify that the EC UART is now a member of the inputs.
self.assertTrue(self.itpr.ec_uart_pty in self.itpr.inputs)
# Since we have issued no commands during the disconnected state, no
diff --git a/util/ec_openocd.py b/util/ec_openocd.py
index 11956ffa1c..bff3e801ec 100755
--- a/util/ec_openocd.py
+++ b/util/ec_openocd.py
@@ -83,7 +83,10 @@ def debug(interface, board, port, executable):
openocd_args += ["-c", f"gdb_port {port}"]
openocd = subprocess.Popen(
- openocd_args, encoding="utf-8", stdout=subprocess.PIPE, stderr=subprocess.STDOUT
+ openocd_args,
+ encoding="utf-8",
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
)
# Wait for OpenOCD to start, it'll open a port for GDB connections
@@ -213,11 +216,15 @@ def main():
target_file = args.file.resolve()
if args.command == "flash":
- image_file = get_flash_file(args.board) if target_file == None else target_file
+ image_file = (
+ get_flash_file(args.board) if target_file == None else target_file
+ )
flash(args.interface, args.board, image_file, args.verify)
elif args.command == "debug":
executable_file = (
- get_executable_file(args.board) if target_file == None else target_file
+ get_executable_file(args.board)
+ if target_file == None
+ else target_file
)
debug(args.interface, args.board, args.port, executable_file)
else:
diff --git a/util/flash_jlink.py b/util/flash_jlink.py
index 50a0bfca20..eef29b98f4 100755
--- a/util/flash_jlink.py
+++ b/util/flash_jlink.py
@@ -142,7 +142,9 @@ def flash(jlink_exe, remote, device, interface, cmd_file):
logging.debug(f"Checking connection to {remote}.")
if not is_tcp_port_open(ip, port):
- logging.error(f"JLink server doesn't seem to be listening on {remote}.")
+ logging.error(
+ f"JLink server doesn't seem to be listening on {remote}."
+ )
logging.error("Ensure that JLinkRemoteServerCLExe is running.")
return 1
cmd.extend(["-ip", remote])
@@ -162,7 +164,9 @@ def flash(jlink_exe, remote, device, interface, cmd_file):
]
)
logging.debug('Running command: "%s"', " ".join(cmd))
- completed_process = subprocess.run(cmd) # pylint: disable=subprocess-run-check
+ completed_process = subprocess.run(
+ cmd
+ ) # pylint: disable=subprocess-run-check
logging.debug("JLink return code: %d", completed_process.returncode)
return completed_process.returncode
@@ -205,7 +209,9 @@ def main(argv: list):
)
log_level_choices = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
- parser.add_argument("--log_level", "-l", choices=log_level_choices, default="DEBUG")
+ parser.add_argument(
+ "--log_level", "-l", choices=log_level_choices, default="DEBUG"
+ )
args = parser.parse_args(argv)
logging.basicConfig(level=args.log_level)
diff --git a/util/fptool.py b/util/fptool.py
index b7f2150289..6b33a0b1f0 100755
--- a/util/fptool.py
+++ b/util/fptool.py
@@ -44,7 +44,9 @@ def main(argv: list) -> int:
# Parser for "flash" subcommand.
parser_decrypt = subparsers.add_parser("flash", help=cmd_flash.__doc__)
- parser_decrypt.add_argument("image", nargs="?", help="Path to the firmware image")
+ parser_decrypt.add_argument(
+ "image", nargs="?", help="Path to the firmware image"
+ )
parser_decrypt.set_defaults(func=cmd_flash)
opts = parser.parse_args(argv)
return opts.func(opts)
diff --git a/util/inject-keys.py b/util/inject-keys.py
index d05d4fbed7..292dd4f492 100755
--- a/util/inject-keys.py
+++ b/util/inject-keys.py
@@ -125,7 +125,9 @@ def inject_event(key, press):
print("%s: invalid key: %s" % (this_script, key))
sys.exit(1)
(row, col) = KEYMATRIX[key]
- subprocess.call(["ectool", "kbpress", str(row), str(col), "1" if press else "0"])
+ subprocess.call(
+ ["ectool", "kbpress", str(row), str(col), "1" if press else "0"]
+ )
def inject_key(key):
@@ -191,7 +193,8 @@ usage_check(arg_len % 2 == 1, "mismatched arguments")
for i in range(1, arg_len, 2):
usage_check(
- sys.argv[i] in ("-s", "-k", "-p", "-r"), "unknown flag: %s" % sys.argv[i]
+ sys.argv[i] in ("-s", "-k", "-p", "-r"),
+ "unknown flag: %s" % sys.argv[i],
)
for i in range(1, arg_len, 2):
diff --git a/util/kconfig_check.py b/util/kconfig_check.py
index 651078448d..ed832b26a1 100755
--- a/util/kconfig_check.py
+++ b/util/kconfig_check.py
@@ -212,7 +212,10 @@ class KconfigCheck:
with open(configs_file, "r") as inf:
configs = re.findall(
"%sCONFIG_([A-Za-z0-9_]*)%s"
- % ((use_defines and "#define " or ""), (use_defines and " " or "")),
+ % (
+ (use_defines and "#define " or ""),
+ (use_defines and " " or ""),
+ ),
inf.read(),
)
return configs
@@ -265,7 +268,9 @@ class KconfigCheck:
return kconfig_files
@classmethod
- def scan_kconfigs(cls, srcdir, prefix="", search_paths=None, try_kconfiglib=True):
+ def scan_kconfigs(
+ cls, srcdir, prefix="", search_paths=None, try_kconfiglib=True
+ ):
"""Scan a source tree for Kconfig options
Args:
@@ -297,7 +302,9 @@ class KconfigCheck:
else:
kconfigs = []
# Remove the prefix if present
- expr = re.compile(r"\n(config|menuconfig) (%s)?([A-Za-z0-9_]*)\n" % prefix)
+ expr = re.compile(
+ r"\n(config|menuconfig) (%s)?([A-Za-z0-9_]*)\n" % prefix
+ )
for fname in cls.find_kconfigs(srcdir):
with open(fname) as inf:
found = re.findall(expr, inf.read())
@@ -381,7 +388,12 @@ class KconfigCheck:
Exit code: 0 if OK, 1 if a problem was found
"""
new_adhoc, unneeded_adhoc, updated_adhoc = self.check_adhoc_configs(
- configs_file, srcdir, allowed_file, prefix, use_defines, search_paths
+ configs_file,
+ srcdir,
+ allowed_file,
+ prefix,
+ use_defines,
+ search_paths,
)
if new_adhoc:
file_list = "\n".join(["CONFIG_%s" % name for name in new_adhoc])
@@ -411,7 +423,9 @@ To temporarily disable this, use: ALLOW_CONFIG=1 make ...
with open(NEW_ALLOWED_FNAME, "w") as out:
for config in updated_adhoc:
print("CONFIG_%s" % config, file=out)
- now_in_kconfig = "\n".join(["CONFIG_%s" % name for name in unneeded_adhoc])
+ now_in_kconfig = "\n".join(
+ ["CONFIG_%s" % name for name in unneeded_adhoc]
+ )
print(
f"""The following options are now in Kconfig:
@@ -427,7 +441,13 @@ update in your CL:
return 0
def do_build(
- self, configs_file, srcdir, allowed_file, prefix, use_defines, search_paths
+ self,
+ configs_file,
+ srcdir,
+ allowed_file,
+ prefix,
+ use_defines,
+ search_paths,
):
"""Find new ad-hoc configs in the configs_file
@@ -445,7 +465,12 @@ update in your CL:
Exit code: 0 if OK, 1 if a problem was found
"""
new_adhoc, _, updated_adhoc = self.check_adhoc_configs(
- configs_file, srcdir, allowed_file, prefix, use_defines, search_paths
+ configs_file,
+ srcdir,
+ allowed_file,
+ prefix,
+ use_defines,
+ search_paths,
)
with open(NEW_ALLOWED_FNAME, "w") as out:
combined = sorted(new_adhoc + updated_adhoc)
diff --git a/util/run_ects.py b/util/run_ects.py
index cf32184462..6d89b39f23 100644
--- a/util/run_ects.py
+++ b/util/run_ects.py
@@ -68,7 +68,10 @@ def main():
help="Echo commands to be executed without running them.",
)
parser.add_argument(
- "-s", "--sync", action="store_true", help="Sync tree before running tests."
+ "-s",
+ "--sync",
+ action="store_true",
+ help="Sync tree before running tests.",
)
parser.add_argument(
"-u", "--upload", action="store_true", help="Upload test results."
diff --git a/util/test_kconfig_check.py b/util/test_kconfig_check.py
index d4942821ae..41c95e951c 100644
--- a/util/test_kconfig_check.py
+++ b/util/test_kconfig_check.py
@@ -134,11 +134,14 @@ rsource "subdir/Kconfig.wibble"
with tempfile.TemporaryDirectory() as srctree:
self.setup_srctree(srctree)
self.assertEqual(
- ["MENU_KCONFIG", "MY_KCONFIG"], checker.scan_kconfigs(srctree, PREFIX)
+ ["MENU_KCONFIG", "MY_KCONFIG"],
+ checker.scan_kconfigs(srctree, PREFIX),
)
@classmethod
- def setup_allowed_and_configs(cls, allowed_fname, configs_fname, add_new_one=True):
+ def setup_allowed_and_configs(
+ cls, allowed_fname, configs_fname, add_new_one=True
+ ):
"""Set up the 'allowed' and 'configs' files for tests
Args:
@@ -181,7 +184,9 @@ rsource "subdir/Kconfig.wibble"
self.setup_srctree(srctree)
with tempfile.NamedTemporaryFile() as allowed:
with tempfile.NamedTemporaryFile() as configs:
- self.setup_allowed_and_configs(allowed.name, configs.name)
+ self.setup_allowed_and_configs(
+ allowed.name, configs.name
+ )
ret_code = kconfig_check.main(
[
"-c",
@@ -204,7 +209,9 @@ rsource "subdir/Kconfig.wibble"
"""Same Kconfig should be returned for kconfiglib / adhoc"""
if not kconfig_check.USE_KCONFIGLIB:
self.fail("No kconfiglib available")
- zephyr_path = pathlib.Path("../../../src/third_party/zephyr/main").resolve()
+ zephyr_path = pathlib.Path(
+ "../../../src/third_party/zephyr/main"
+ ).resolve()
if not zephyr_path.exists():
self.fail("No zephyr tree available")
os.environ["ZEPHYR_BASE"] = str(zephyr_path)
diff --git a/util/twister_launcher.py b/util/twister_launcher.py
index e6e5999252..36549d4e50 100755
--- a/util/twister_launcher.py
+++ b/util/twister_launcher.py
@@ -62,7 +62,9 @@ def main():
ec_base = cros_checkout / "src" / "platform" / "ec"
# Module paths, including third party modules and the EC application.
- zephyr_modules = find_modules(cros_checkout / "src" / "third_party" / "zephyr")
+ zephyr_modules = find_modules(
+ cros_checkout / "src" / "third_party" / "zephyr"
+ )
zephyr_modules.append(ec_base)
# Prepare environment variables for export to Twister and inherit the
diff --git a/util/uart_stress_tester.py b/util/uart_stress_tester.py
index c44262016c..6417376a08 100755
--- a/util/uart_stress_tester.py
+++ b/util/uart_stress_tester.py
@@ -46,7 +46,10 @@ TPM_CMD = (
)
# A ChromeOS TPM command for the cr50 stress
# purpose.
-CR50_LOAD_GEN_CMD = "while [[ -f %s ]]; do %s; done &" % (FLAG_FILENAME, TPM_CMD)
+CR50_LOAD_GEN_CMD = "while [[ -f %s ]]; do %s; done &" % (
+ FLAG_FILENAME,
+ TPM_CMD,
+)
# A command line to run TPM_CMD in background
# infinitely.
@@ -231,7 +234,9 @@ class UartSerial(object):
" to this port, and try it again." % self.serial.port
)
- self.logger.info("Detected as %s UART", self.dev_prof["device_type"])
+ self.logger.info(
+ "Detected as %s UART", self.dev_prof["device_type"]
+ )
# Log displays the UART type (AP|EC) instead of device filename.
self.logger = logging.getLogger(
type(self).__name__ + "| " + self.dev_prof["device_type"]
@@ -266,7 +271,9 @@ class UartSerial(object):
)
self.num_ch_exp = int(self.serial.baudrate * self.duration / 10)
- chargen_cmd = "chargen " + str(CHARGEN_TXT_LEN) + " " + str(self.num_ch_exp)
+ chargen_cmd = (
+ "chargen " + str(CHARGEN_TXT_LEN) + " " + str(self.num_ch_exp)
+ )
if self.usb_output:
chargen_cmd += " usb"
self.test_cli = [chargen_cmd]
@@ -304,9 +311,13 @@ class UartSerial(object):
self.char_loss_occurrences = 0
data_starve_count = 0
- total_num_ch = self.num_ch_exp # Expected number of characters in total
+ total_num_ch = (
+ self.num_ch_exp
+ ) # Expected number of characters in total
ch_exp = CHARGEN_TXT[0]
- ch_cap = "z" # any character value is ok for loop initial condition.
+ ch_cap = (
+ "z" # any character value is ok for loop initial condition.
+ )
while self.num_ch_cap < total_num_ch:
captured = self.get_output()
@@ -325,7 +336,9 @@ class UartSerial(object):
# If it is not alpha-numeric, terminate the test.
if ch_cap not in CRLF:
# If it is neither a CR nor LF, then it is an error case.
- self.logger.error("Whole captured characters: %r", captured)
+ self.logger.error(
+ "Whole captured characters: %r", captured
+ )
raise ChargenTestError(
err_msg
% (
@@ -509,7 +522,9 @@ class ChargenTest(object):
# Print the result.
char_lost = self.print_result()
if char_lost:
- raise ChargenTestError("Test failed: lost %d character(s)" % char_lost)
+ raise ChargenTestError(
+ "Test failed: lost %d character(s)" % char_lost
+ )
self.logger.info("Test is done")
@@ -537,7 +552,9 @@ Examples:
parser = argparse.ArgumentParser(
description=description, formatter_class=argparse.RawTextHelpFormatter
)
- parser.add_argument("port", type=str, nargs="*", help="UART device path to test")
+ parser.add_argument(
+ "port", type=str, nargs="*", help="UART device path to test"
+ )
parser.add_argument(
"-c",
"--cr50",
@@ -580,7 +597,9 @@ def main():
loglevel = logging.INFO
log_format += " | %(message)s"
- logging.basicConfig(level=loglevel, format=log_format, datefmt=date_format)
+ logging.basicConfig(
+ level=loglevel, format=log_format, datefmt=date_format
+ )
# Create a ChargenTest object
utest = ChargenTest(
diff --git a/util/update_release_branch.py b/util/update_release_branch.py
index 4d9c89df4a..c2fc5ff116 100755
--- a/util/update_release_branch.py
+++ b/util/update_release_branch.py
@@ -136,7 +136,14 @@ def get_relevant_commits(head, merge_head, fmt, relevant_paths):
stdout.
"""
if fmt:
- cmd = ["git", "log", fmt, head + ".." + merge_head, "--", relevant_paths]
+ cmd = [
+ "git",
+ "log",
+ fmt,
+ head + ".." + merge_head,
+ "--",
+ relevant_paths,
+ ]
else:
cmd = ["git", "log", head + ".." + merge_head, "--", relevant_paths]
@@ -281,7 +288,10 @@ def main(argv):
arglist.append("-X" + opts.strategy_option)
subprocess.run(arglist, check=True)
else:
- print("We have already started merge process.", "Attempt to generate commit.")
+ print(
+ "We have already started merge process.",
+ "Attempt to generate commit.",
+ )
print("Generating commit message...")
branch = subprocess.run(
@@ -308,7 +318,12 @@ def main(argv):
commit_msg = git_commit_msg(branch, head, merge_head, relevant_paths, cmd)
subprocess.run(["git", "commit", "--signoff", "-m", commit_msg], check=True)
subprocess.run(["git", "commit", "--amend"], check=True)
- print(("Finished! **Please review the commit to see if it's to your " "liking.**"))
+ print(
+ (
+ "Finished! **Please review the commit to see if it's to your "
+ "liking.**"
+ )
+ )
if __name__ == "__main__":
diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py
index 07b4ecc010..19301aa50b 100755
--- a/util/zephyr_to_resultdb.py
+++ b/util/zephyr_to_resultdb.py
@@ -50,7 +50,9 @@ def testcase_summary(testcase):
or "reason" in testcase
or translate_status(testcase["status"]) == "SKIP"
):
- html = '<p><text-artifact artifact-id="artifact-content-in-request"></p>'
+ html = (
+ '<p><text-artifact artifact-id="artifact-content-in-request"></p>'
+ )
return html