Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions kernelci/kbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def __init__(
self._artifacts = []
self._current_job = None
self._config_full = ""
self._compiler_version = None
self._srcdir = None
self._firmware_dir = None
self._af_dir = None
Expand Down Expand Up @@ -259,7 +258,6 @@ def __init__(
self._artifacts = jsonobj["artifacts"]
self._current_job = jsonobj["current_job"]
self._config_full = jsonobj["config_full"]
self._compiler_version = jsonobj["compiler_version"]
self._srcdir = jsonobj["srcdir"]
self._srctarball = jsonobj["srctarball"]
self._firmware_dir = jsonobj["firmware_dir"]
Expand Down Expand Up @@ -1263,36 +1261,10 @@ def _write_metadata(self):
metadata["build"]["srcdir"] = self._srcdir
metadata["build"]["config_full"] = self._config_full
metadata["build"]["backend"] = self._backend
if self._compiler_version:
metadata["build"]["compiler_version"] = self._compiler_version

with open(os.path.join(self._af_dir, "metadata.json"), "w") as f:
json.dump(metadata, f, indent=4)

def _preserve_tuxmake_metadata(self):
"""
Rename tuxmake's metadata.json to tuxmake_metadata.json so it
survives _write_metadata overwriting it, and keep the compiler
version it records for our own metadata and the node data
"""
metadata_path = os.path.join(self._af_dir, "metadata.json")
if self._backend != "tuxmake" or not os.path.exists(metadata_path):
return
try:
with open(metadata_path) as f:
tux_meta = json.load(f)
except (OSError, json.JSONDecodeError):
return
if not isinstance(tux_meta, dict) or "tuxmake" not in tux_meta:
return
os.rename(
metadata_path,
os.path.join(self._af_dir, "tuxmake_metadata.json"),
)
version_full = tux_meta.get("compiler", {}).get("version_full")
if version_full:
self._compiler_version = version_full

def serialize(self, filename):
"""Serialize class to json

Expand Down Expand Up @@ -1332,7 +1304,6 @@ def verify_build(self):
)
self._artifacts.append(file)
# Update manifest/metadata
self._preserve_tuxmake_metadata()
self._write_metadata()
print("Artifacts verified")

Expand Down Expand Up @@ -1717,8 +1688,6 @@ def submit(self, retcode, dry_run=False):
results["node"]["data"] = node["data"]
results["node"]["data"]["arch"] = self._arch
results["node"]["data"]["compiler"] = self._compiler
if self._compiler_version:
results["node"]["data"]["compiler_version"] = self._compiler_version
# As we are late to change data formats, we need to keep
# defconfig as string, not list, so we use + to separate
# multiple defconfigs
Expand Down
56 changes: 0 additions & 56 deletions tests/test_kbuild.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
"""Tests for kernelci.kbuild build script generation and metadata"""

import json
import os
import sys
import types
Expand All @@ -20,7 +19,6 @@ def _kbuild(tmp_path, compiler="clang-21", arch="x86_64"):
kbuild._fragments = []
kbuild._fragment_files = []
kbuild._config_full = ""
kbuild._compiler_version = None
kbuild._backend = "tuxmake"
kbuild._dtbs_check = True
kbuild._steps = []
Expand Down Expand Up @@ -84,60 +82,6 @@ def test_no_probe_for_gcc_without_tuxmake(self, tmp_path, monkeypatch):
assert not any("--version" in s for s in kbuild._steps)


class TestPreserveTuxmakeMetadata:
def test_preserves_tuxmake_metadata(self, tmp_path):
kbuild = _kbuild(tmp_path)
af_dir = tmp_path / "artifacts"
tux_meta = {
"tuxmake": {"version": "1.40.0"},
"compiler": {
"name": "clang",
"version": "21.1.8",
"version_full": "Debian clang version 21.1.8",
},
}
(af_dir / "metadata.json").write_text(json.dumps(tux_meta))
kbuild._preserve_tuxmake_metadata()
kbuild._write_metadata()
preserved = json.loads((af_dir / "tuxmake_metadata.json").read_text())
assert preserved == tux_meta
own = json.loads((af_dir / "metadata.json").read_text())
assert own["build"]["backend"] == "tuxmake"
assert own["build"]["compiler_version"] == "Debian clang version 21.1.8"
assert kbuild._compiler_version == "Debian clang version 21.1.8"

def test_ignores_own_metadata(self, tmp_path):
kbuild = _kbuild(tmp_path)
af_dir = tmp_path / "artifacts"
own_meta = {"build": {"backend": "tuxmake"}}
(af_dir / "metadata.json").write_text(json.dumps(own_meta))
kbuild._preserve_tuxmake_metadata()
kbuild._write_metadata()
assert not (af_dir / "tuxmake_metadata.json").exists()
own = json.loads((af_dir / "metadata.json").read_text())
assert "compiler_version" not in own["build"]

def test_handles_invalid_json(self, tmp_path):
kbuild = _kbuild(tmp_path)
af_dir = tmp_path / "artifacts"
(af_dir / "metadata.json").write_text("not json {")
kbuild._preserve_tuxmake_metadata()
kbuild._write_metadata()
assert not (af_dir / "tuxmake_metadata.json").exists()
own = json.loads((af_dir / "metadata.json").read_text())
assert own["build"]["arch"] == "x86_64"

def test_no_existing_metadata(self, tmp_path):
kbuild = _kbuild(tmp_path)
af_dir = tmp_path / "artifacts"
kbuild._preserve_tuxmake_metadata()
kbuild._write_metadata()
assert not (af_dir / "tuxmake_metadata.json").exists()
own = json.loads((af_dir / "metadata.json").read_text())
assert own["build"]["compiler"] == "clang-21"
assert "compiler_version" not in own["build"]


class FakeStorage:
def __init__(self):
self.single_uploads = []
Expand Down