summaryrefslogtreecommitdiff
path: root/.gitlab-ci/lava
diff options
context:
space:
mode:
authorGuilherme Gallo <guilherme.gallo@collabora.com>2022-11-27 23:38:33 -0300
committerMarge Bot <emma+marge@anholt.net>2022-12-21 12:44:49 +0000
commitf040122bedb64bb6f4c26d7e272da874ae7f9a05 (patch)
treef1d2610395d96c21273f932a22ecef66303f3ce6 /.gitlab-ci/lava
parentce0ca7ed21d6c621812db82fce70d4e06881818f (diff)
downloadmesa-f040122bedb64bb6f4c26d7e272da874ae7f9a05.tar.gz
ci/lava: Feed yaml.load with raw bytes data
LAVA uses XMLRPC to send jobs information and control, more specifically it sends device logs via YAML dumps encoded in UTF-8 bytes. In Python, we have xmlrpc.client.Binary class as the serializer protocol, we get the logs wrapped by this class, which encodes the data as UTF-8 bytes data. We were converting the encoded data to a string via the `str` function, but this led the loaded YAML data to use single quotes instead of double quotes for string values that made special characters, such as `\x1b` to be escaped as `\\x1b`. With this fix, we can now drop one of the hacks that fixed the bash colors. Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20051>
Diffstat (limited to '.gitlab-ci/lava')
-rwxr-xr-x.gitlab-ci/lava/lava_job_submitter.py6
-rw-r--r--.gitlab-ci/lava/utils/__init__.py1
-rw-r--r--.gitlab-ci/lava/utils/log_follower.py14
3 files changed, 5 insertions, 16 deletions
diff --git a/.gitlab-ci/lava/lava_job_submitter.py b/.gitlab-ci/lava/lava_job_submitter.py
index 9c4af85cfde..c338cc8cd95 100755
--- a/.gitlab-ci/lava/lava_job_submitter.py
+++ b/.gitlab-ci/lava/lava_job_submitter.py
@@ -272,8 +272,12 @@ class LAVAJob:
def _load_log_from_data(self, data) -> list[str]:
lines = []
+ if isinstance(data, xmlrpc.client.Binary):
+ # We are dealing with xmlrpc.client.Binary
+ # Let's extract the data
+ data = data.data
# When there is no new log data, the YAML is empty
- if loaded_lines := yaml.load(str(data), Loader=loader(False)):
+ if loaded_lines := yaml.load(data, Loader=loader(False)):
lines = loaded_lines
self.last_log_line += len(lines)
return lines
diff --git a/.gitlab-ci/lava/utils/__init__.py b/.gitlab-ci/lava/utils/__init__.py
index 0be88266d35..18bb459c1a4 100644
--- a/.gitlab-ci/lava/utils/__init__.py
+++ b/.gitlab-ci/lava/utils/__init__.py
@@ -3,7 +3,6 @@ from .gitlab_section import GitlabSection
from .log_follower import (
LogFollower,
fatal_err,
- fix_lava_color_log,
fix_lava_gitlab_section_log,
hide_sensitive_data,
print_log,
diff --git a/.gitlab-ci/lava/utils/log_follower.py b/.gitlab-ci/lava/utils/log_follower.py
index c61a9aa4e60..506cb7b8a3b 100644
--- a/.gitlab-ci/lava/utils/log_follower.py
+++ b/.gitlab-ci/lava/utils/log_follower.py
@@ -150,19 +150,6 @@ class LogFollower:
self._buffer = []
return buffer
-
-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:?:digit:?m` ANSI TTY color codes, or the more
- complicated ones with number values for text format before background and
- foreground colors.
- When this problem is fixed on the LAVA side, one should remove this function.
- """
- line["msg"] = re.sub(r"(\[(\d+;){0,2}\d{1,3}m)", "\x1b" + r"\1", line["msg"])
-
-
def fix_lava_gitlab_section_log(line):
"""This function is a temporary solution for the Gitlab section markers
mangling problem. Gitlab parses the following lines to define a collapsible
@@ -195,7 +182,6 @@ def parse_lava_line(line) -> Optional[str]:
prefix = "$ "
suffix = ""
elif line["lvl"] == "target":
- fix_lava_color_log(line)
fix_lava_gitlab_section_log(line)
return f'{prefix}{line["msg"]}{suffix}'