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
16 changes: 6 additions & 10 deletions kernelci/kbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,9 @@ def __init__(
self._dtbs_check = params["dtbs_check"]
else:
self._dtbs_check = False
if params.get("kselftest") == "disable":
self._kselftest = False
else:
self._kselftest = True
self._kselftest = (
not self._dtbs_check and params.get("kselftest") != "disable"
)
self._extra_targets = params.get("extra_targets", [])
self._apijobname = jobname
self._steps = []
Expand Down Expand Up @@ -277,9 +276,7 @@ def __init__(
)
self._full_artifacts = jsonobj["full_artifacts"]
self._dtbs_check = jsonobj["dtbs_check"]
self._kselftest = jsonobj.get(
"kselftest", jsonobj.get("kfselftest")
)
self._kselftest = jsonobj["kselftest"]
self._coverage = jsonobj.get("coverage", False)
self._extra_targets = jsonobj.get("extra_targets", [])
return
Expand Down Expand Up @@ -878,7 +875,6 @@ def _build_with_tuxmake(self):
if not self._dtbs_check:
self._fetch_firmware()

build_kselftest = not self._dtbs_check and self._kselftest
kernel_build_dir = f"{self._workspace}/kernel_build"

self.startjob("build_tuxmake")
Expand All @@ -900,7 +896,7 @@ def _build_with_tuxmake(self):
cmd_parts = self._tuxmake_base(
self._af_dir, defconfig, extra_defconfigs
)
if build_kselftest:
if self._kselftest:
cmd_parts.append(f"--build-dir={kernel_build_dir}")

# Build targets depend on mode. kselftest is built in a separate
Expand Down Expand Up @@ -972,7 +968,7 @@ def _build_with_tuxmake(self):

self.addcmd("cd ..")

if build_kselftest:
if self._kselftest:
self._build_kselftest_tuxmake(
defconfig, extra_defconfigs, kernel_build_dir
)
Expand Down
49 changes: 48 additions & 1 deletion tests/test_kbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def _kbuild(tmp_path, compiler="clang-21", arch="x86_64"):
kbuild._config_full = ""
kbuild._backend = "tuxmake"
kbuild._dtbs_check = True
kbuild._kselftest = False
kbuild._steps = []
kbuild._artifacts = []
kbuild._current_job = None
Expand Down Expand Up @@ -211,13 +212,59 @@ def test_no_kept_kernel_tree_without_kselftest(self, tmp_path, monkeypatch):

def test_no_kselftest_build_for_dtbs_check(self, tmp_path, monkeypatch):
(kernel,) = _tuxmake_invocations(
tmp_path, monkeypatch, True, dtbs_check=True
tmp_path, monkeypatch, False, dtbs_check=True
)

assert "--build-dir" not in kernel
assert kernel.split()[-1] == "dtbs_check"


def _kbuild_from_params(monkeypatch, **params):
monkeypatch.setenv("KCI_API_TOKEN", "test-token")
params = {
"arch": "arm64",
"compiler": "gcc-14",
"defconfig": "defconfig",
"fragments": [],
**params,
}
return KBuild(
node={"artifacts": {"tarball": "https://storage.test/linux.tar.gz"}},
jobname="kbuild-gcc-14-arm64",
params=params,
apiconfig="url: https://api.test\n",
)


def _kbuild_from_json(tmp_path, monkeypatch, **params):
kbuild = _kbuild_from_params(monkeypatch, **params)
kbuild._storage_config = None
kbuild._fragments_dir = None
path = tmp_path / "kbuild.json"
kbuild.serialize(str(path))
return KBuild.from_json(str(path))


class TestKselftestFlag:
def test_enabled_by_default(self, monkeypatch):
assert _kbuild_from_params(monkeypatch)._kselftest is True

def test_disabled_by_param(self, monkeypatch):
kbuild = _kbuild_from_params(monkeypatch, kselftest="disable")
assert kbuild._kselftest is False

def test_disabled_for_dtbs_check(self, monkeypatch):
kbuild = _kbuild_from_params(monkeypatch, dtbs_check=True)
assert kbuild._kselftest is False

def test_reload_keeps_enabled(self, tmp_path, monkeypatch):
assert _kbuild_from_json(tmp_path, monkeypatch)._kselftest is True

def test_reload_keeps_disabled_for_dtbs_check(self, tmp_path, monkeypatch):
kbuild = _kbuild_from_json(tmp_path, monkeypatch, dtbs_check=True)
assert kbuild._kselftest is False


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