mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-11-23 18:24:13 +08:00
ci: bare-metal: cros-servo: Create strutured logs for a630
Use the CustomLogger class and CLI tool to create strutured logs for cros-servo scripts. Below is an example for a630. { "_timestamp": "2023-10-18T18:14:16.114117", "dut_job_type": "sdm845-cheza-r3", "farm": "google", "dut_jobs": [ { "status": "pass", "submitter_start_time": "2023-10-18T18:14:16.255163", "dut_start_time": "2023-10-18T18:14:16.328396", "dut_submit_time": "2023-10-18T18:14:16.330469", "dut_end_time": "2023-10-18T18:33:47.034774", "dut_name": "google-freedreno-cheza-18", "dut_state": "finished", "dut_job_phases": [ { "name": "boot", "start_time": "2023-10-18T18:14:16.329576", "end_time": "2023-10-18T18:14:24.495826" }, { "name": "test", "start_time": "2023-10-18T18:14:24.495855", "end_time": "2023-10-18T18:33:47.136979" } ], "submitter_end_time": "2023-10-18T18:33:47.207702" } ], "job_combined_status": "pass", "dut_attempt_counter": 1 } Signed-off-by: Vignesh Raman <vignesh.raman@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25807>
This commit is contained in:
parent
dc69d797ba
commit
dc66de3029
@ -9,6 +9,7 @@
|
||||
# We're run from the root of the repo, make a helper var for our paths
|
||||
BM=$CI_PROJECT_DIR/install/bare-metal
|
||||
CI_COMMON=$CI_PROJECT_DIR/install/common
|
||||
CI_INSTALL=$CI_PROJECT_DIR/install
|
||||
|
||||
# Runner config checks
|
||||
if [ -z "$BM_SERIAL" ]; then
|
||||
@ -98,15 +99,26 @@ fi
|
||||
echo "$BM_CMDLINE" > /tftp/cmdline
|
||||
|
||||
set +e
|
||||
STRUCTURED_LOG_FILE=job_detail.json
|
||||
python3 $CI_INSTALL/custom_logger.py ${STRUCTURED_LOG_FILE} --update dut_job_type "${DEVICE_TYPE}"
|
||||
python3 $CI_INSTALL/custom_logger.py ${STRUCTURED_LOG_FILE} --update farm "${FARM}"
|
||||
python3 $CI_INSTALL/custom_logger.py ${STRUCTURED_LOG_FILE} --create-dut-job dut_name "${CI_RUNNER_DESCRIPTION}"
|
||||
python3 $CI_INSTALL/custom_logger.py ${STRUCTURED_LOG_FILE} --update-dut-time submit "${CI_JOB_STARTED_AT}"
|
||||
python3 $BM/cros_servo_run.py \
|
||||
--cpu $BM_SERIAL \
|
||||
--ec $BM_SERIAL_EC \
|
||||
--test-timeout ${TEST_PHASE_TIMEOUT:-20}
|
||||
ret=$?
|
||||
python3 $CI_INSTALL/custom_logger.py ${STRUCTURED_LOG_FILE} --close-dut-job
|
||||
python3 $CI_INSTALL/custom_logger.py ${STRUCTURED_LOG_FILE} --close
|
||||
set -e
|
||||
|
||||
# Bring artifacts back from the NFS dir to the build dir where gitlab-runner
|
||||
# will look for them.
|
||||
cp -Rp /nfs/results/. results/
|
||||
if [ -f "${STRUCTURED_LOG_FILE}" ]; then
|
||||
cp -p ${STRUCTURED_LOG_FILE} results/
|
||||
echo "Structured log file is available at https://${CI_PROJECT_ROOT_NAMESPACE}.pages.freedesktop.org/-/${CI_PROJECT_NAME}/-/jobs/${CI_JOB_ID}/artifacts/results/${STRUCTURED_LOG_FILE}"
|
||||
fi
|
||||
|
||||
exit $ret
|
||||
|
@ -7,11 +7,12 @@ import argparse
|
||||
import re
|
||||
import sys
|
||||
|
||||
from custom_logger import CustomLogger
|
||||
from serial_buffer import SerialBuffer
|
||||
|
||||
|
||||
class CrosServoRun:
|
||||
def __init__(self, cpu, ec, test_timeout):
|
||||
def __init__(self, cpu, ec, test_timeout, logger):
|
||||
self.cpu_ser = SerialBuffer(
|
||||
cpu, "results/serial.txt", "R SERIAL-CPU> ")
|
||||
# Merge the EC serial into the cpu_ser's line stream so that we can
|
||||
@ -19,6 +20,7 @@ class CrosServoRun:
|
||||
self.ec_ser = SerialBuffer(
|
||||
ec, "results/serial-ec.txt", "R SERIAL-EC> ", line_queue=self.cpu_ser.line_queue)
|
||||
self.test_timeout = test_timeout
|
||||
self.logger = logger
|
||||
|
||||
def close(self):
|
||||
self.ec_ser.close()
|
||||
@ -36,6 +38,7 @@ class CrosServoRun:
|
||||
RED = '\033[0;31m'
|
||||
NO_COLOR = '\033[0m'
|
||||
print(RED + message + NO_COLOR)
|
||||
self.logger.update_status_fail(message)
|
||||
|
||||
def run(self):
|
||||
# Flush any partial commands in the EC's prompt, then ask for a reboot.
|
||||
@ -43,6 +46,7 @@ class CrosServoRun:
|
||||
self.ec_write("reboot\n")
|
||||
|
||||
bootloader_done = False
|
||||
self.logger.create_job_phase("boot")
|
||||
tftp_failures = 0
|
||||
# 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
|
||||
@ -79,9 +83,10 @@ class CrosServoRun:
|
||||
return 1
|
||||
|
||||
if not bootloader_done:
|
||||
print("Failed to make it through bootloader, abandoning run.")
|
||||
self.print_error("Failed to make it through bootloader, abandoning run.")
|
||||
return 1
|
||||
|
||||
self.logger.create_job_phase("test")
|
||||
for line in self.cpu_ser.lines(timeout=self.test_timeout, phase="test"):
|
||||
if re.search("---. end Kernel panic", line):
|
||||
return 1
|
||||
@ -125,8 +130,10 @@ class CrosServoRun:
|
||||
result = re.search("hwci: mesa: (\S*)", line)
|
||||
if result:
|
||||
if result.group(1) == "pass":
|
||||
self.logger.update_dut_job("status", "pass")
|
||||
return 0
|
||||
else:
|
||||
self.logger.update_status_fail("test fail")
|
||||
return 1
|
||||
|
||||
self.print_error(
|
||||
@ -144,11 +151,14 @@ def main():
|
||||
'--test-timeout', type=int, help='Test phase timeout (minutes)', required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
servo = CrosServoRun(args.cpu, args.ec, args.test_timeout * 60)
|
||||
logger = CustomLogger("job_detail.json")
|
||||
logger.update_dut_time("start", None)
|
||||
servo = CrosServoRun(args.cpu, args.ec, args.test_timeout * 60, logger)
|
||||
retval = servo.run()
|
||||
|
||||
# power down the CPU on the device
|
||||
servo.ec_write("power off\n")
|
||||
logger.update_dut_time("end", None)
|
||||
servo.close()
|
||||
|
||||
sys.exit(retval)
|
||||
|
Loading…
Reference in New Issue
Block a user