ci/bare-metal: Use section for boot messages from cros-servo
Signed-off-by: Daniel Stone <daniels@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31602>
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
# First stage: very basic setup to bring up network and /dev etc
|
# First stage: very basic setup to bring up network and /dev etc
|
||||||
/init-stage1.sh
|
/init-stage1.sh
|
||||||
|
|
||||||
|
export CURRENT_SECTION=dut_boot
|
||||||
|
|
||||||
# Second stage: run jobs
|
# Second stage: run jobs
|
||||||
test $? -eq 0 && /init-stage2.sh
|
test $? -eq 0 && /init-stage2.sh
|
||||||
|
|
||||||
|
@@ -4,12 +4,20 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import datetime
|
||||||
|
import math
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from custom_logger import CustomLogger
|
from custom_logger import CustomLogger
|
||||||
from serial_buffer import SerialBuffer
|
from serial_buffer import SerialBuffer
|
||||||
|
|
||||||
|
ANSI_ESCAPE="\x1b[0K"
|
||||||
|
ANSI_COLOUR="\x1b[0;36m"
|
||||||
|
ANSI_RESET="\x1b[0m"
|
||||||
|
SECTION_START="start"
|
||||||
|
SECTION_END="end"
|
||||||
|
|
||||||
class CrosServoRun:
|
class CrosServoRun:
|
||||||
def __init__(self, cpu, ec, test_timeout, logger):
|
def __init__(self, cpu, ec, test_timeout, logger):
|
||||||
@@ -40,6 +48,31 @@ class CrosServoRun:
|
|||||||
print(RED + message + NO_COLOR)
|
print(RED + message + NO_COLOR)
|
||||||
self.logger.update_status_fail(message)
|
self.logger.update_status_fail(message)
|
||||||
|
|
||||||
|
def get_rel_timestamp(self):
|
||||||
|
now = datetime.datetime.now(tz=datetime.UTC)
|
||||||
|
then_env = os.getenv("CI_JOB_STARTED_AT")
|
||||||
|
if not then_env:
|
||||||
|
return ""
|
||||||
|
delta = now - datetime.datetime.fromisoformat(then_env)
|
||||||
|
return f"[{math.floor(delta.seconds / 60):02}:{(delta.seconds % 60):02}]"
|
||||||
|
|
||||||
|
def get_cur_timestamp(self):
|
||||||
|
return str(int(datetime.datetime.timestamp(datetime.datetime.now())))
|
||||||
|
|
||||||
|
def print_gitlab_section(self, action, name, description, collapse=True):
|
||||||
|
assert action in [SECTION_START, SECTION_END]
|
||||||
|
out = ANSI_ESCAPE + "section_" + action + ":"
|
||||||
|
out += self.get_cur_timestamp() + ":"
|
||||||
|
out += name
|
||||||
|
if action == "start" and collapse:
|
||||||
|
out += "[collapsed=true]"
|
||||||
|
out += "\r" + ANSI_ESCAPE + ANSI_COLOUR
|
||||||
|
out += self.get_rel_timestamp() + " " + description + ANSI_RESET
|
||||||
|
print(out)
|
||||||
|
|
||||||
|
def boot_section(self, action):
|
||||||
|
self.print_gitlab_section(action, "dut_boot", "Booting hardware device", True)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# Flush any partial commands in the EC's prompt, then ask for a reboot.
|
# Flush any partial commands in the EC's prompt, then ask for a reboot.
|
||||||
self.ec_write("\n")
|
self.ec_write("\n")
|
||||||
@@ -47,6 +80,7 @@ class CrosServoRun:
|
|||||||
|
|
||||||
bootloader_done = False
|
bootloader_done = False
|
||||||
self.logger.create_job_phase("boot")
|
self.logger.create_job_phase("boot")
|
||||||
|
self.boot_section(SECTION_START)
|
||||||
tftp_failures = 0
|
tftp_failures = 0
|
||||||
# This is emitted right when the bootloader pauses to check for input.
|
# This is emitted right when the bootloader pauses to check for input.
|
||||||
# Emit a ^N character to request network boot, because we don't have a
|
# Emit a ^N character to request network boot, because we don't have a
|
||||||
|
Reference in New Issue
Block a user