diff options
author | Guilherme Gallo <guilherme.gallo@collabora.com> | 2022-05-15 21:35:48 -0300 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2022-05-23 16:51:47 +0000 |
commit | e00281f6dae98e9dec3da751fc23a451e8627379 (patch) | |
tree | 89c2b17353c0eb183feb42adfcccc967dab9975b /.gitlab-ci/lava/lava_job_submitter.py | |
parent | cc10c53333673fc9b8645001d9efad26eda35223 (diff) | |
download | mesa-e00281f6dae98e9dec3da751fc23a451e8627379.tar.gz |
ci/lava: Fix colored LAVA outputs
LAVA is mangling the escape codes from ANSI during log fetching from the
target device, making the colored lines from deqp, for example, to not
work, inputting noise into the log.
This commit makes the most straightforward fix which is to replace the
mangled characters to the fixed ones.
This approach is error-prone since it may unwittingly replace a genuine
log that resembles the mangled escape code. But this solution should
suffice until we get a proper fix from LAVA developers itself.
Fixes: #5503
Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16520>
Diffstat (limited to '.gitlab-ci/lava/lava_job_submitter.py')
-rwxr-xr-x | .gitlab-ci/lava/lava_job_submitter.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/.gitlab-ci/lava/lava_job_submitter.py b/.gitlab-ci/lava/lava_job_submitter.py index 4c5fba51eba..8a1968b7eb9 100755 --- a/.gitlab-ci/lava/lava_job_submitter.py +++ b/.gitlab-ci/lava/lava_job_submitter.py @@ -72,7 +72,8 @@ CONSOLE_LOG_COLOR_RESET = "\x1b[0m" def print_log(msg): - print("{}: {}".format(datetime.now(), msg)) + # Reset color from timestamp, since `msg` can tint the terminal color + print(f"{CONSOLE_LOG_COLOR_RESET}{datetime.now()}: {msg}") def fatal_err(msg): @@ -370,9 +371,22 @@ def show_job_data(job): print("{}\t: {}".format(field, value)) +def fix_lava_color_log(line): + """This function is a temporary solution for the color escape codes mangling + problem. There is some problem in message passing between the LAVA + dispatcher and the device under test (DUT). Here \x1b character is missing + before `[:digit::digit:?m` ANSI TTY color codes. When this problem is fixed + on the LAVA side, one should remove this function. + """ + line["msg"] = re.sub(r"(\[\d{1,2}m)", "\x1b" + r"\1", line["msg"]) + + def parse_lava_lines(new_lines) -> list[str]: parsed_lines: list[str] = [] for line in new_lines: + prefix = "" + suffix = "" + if line["lvl"] in ["results", "feedback"]: continue elif line["lvl"] in ["warning", "error"]: @@ -381,9 +395,10 @@ def parse_lava_lines(new_lines) -> list[str]: elif line["lvl"] == "input": prefix = "$ " suffix = "" - else: - prefix = "" - suffix = "" + elif line["lvl"] == "target": + fix_lava_color_log(line) + fix_lava_gitlab_section_log(line) + line = f'{prefix}{line["msg"]}{suffix}' parsed_lines.append(line) |