CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
95 lines
2.9 KiB
Python
95 lines
2.9 KiB
Python
# Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from geko import utils
|
|
|
|
|
|
def test_get_utc_timestamp_and_sha256(tmp_path: Path) -> None:
|
|
p = tmp_path / "f.txt"
|
|
p.write_text("abc")
|
|
ts = utils.get_utc_timestamp()
|
|
assert "T" in ts
|
|
assert utils.compute_file_sha256(p) == "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
|
|
|
|
|
|
def test_run_silent_command_raises_on_nonzero(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
class _Proc:
|
|
returncode = 1
|
|
|
|
def communicate(self):
|
|
return "", "bad"
|
|
|
|
monkeypatch.setattr(utils.subprocess, "Popen", lambda *_a, **_k: _Proc())
|
|
with pytest.raises(ValueError, match="bad"):
|
|
utils.run_silent_command(["x"])
|
|
|
|
|
|
def test_parse_devices_variants_and_errors() -> None:
|
|
out = utils.parse_devices("0,1,1")
|
|
assert set(out) == {0, 1}
|
|
|
|
out2 = utils.parse_devices([2, 3])
|
|
assert out2 == [2, 3]
|
|
|
|
with pytest.raises(ValueError, match="Error parsing devices"):
|
|
utils.parse_devices("x,y")
|
|
|
|
with pytest.raises(ValueError, match="not supported"):
|
|
utils.parse_devices(1.5) # type: ignore[arg-type]
|
|
|
|
with pytest.raises(ValueError, match="Need at least 1 device"):
|
|
utils.parse_devices([])
|
|
|
|
|
|
def test_build_tensilelite_client_missing_hip_path_raises(tmp_path: Path) -> None:
|
|
with pytest.raises(FileNotFoundError):
|
|
utils.build_tensilelite_client(tmp_path / "missing")
|
|
|
|
|
|
def test_build_tensilelite_client_raises_without_invoke(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
hip = tmp_path / "hip"
|
|
(hip / "tensilelite").mkdir(parents=True)
|
|
|
|
monkeypatch.setattr(utils, "find_spec", lambda _n: None)
|
|
monkeypatch.setattr(utils, "run_silent_command", lambda *_a, **_k: None)
|
|
|
|
with pytest.raises(RuntimeError, match="invoke"):
|
|
utils.build_tensilelite_client(hip, build_dir=tmp_path / "b")
|
|
|
|
|
|
def test_build_tensilelite_client_build_and_cached_paths(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
hip = tmp_path / "hip"
|
|
tensile = hip / "tensilelite"
|
|
tensile.mkdir(parents=True)
|
|
|
|
build_dir = tmp_path / "build"
|
|
client = build_dir / "tensilelite/client/tensilelite-client"
|
|
hash_file = build_dir / "hash.txt"
|
|
client.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
monkeypatch.setattr(utils, "find_spec", lambda _n: object())
|
|
|
|
built = {"n": 0}
|
|
|
|
def _fake_run(_cmd, cwd=None):
|
|
built["n"] += 1
|
|
client.parent.mkdir(parents=True, exist_ok=True)
|
|
client.write_text("bin\n")
|
|
|
|
monkeypatch.setattr(utils, "run_silent_command", _fake_run)
|
|
|
|
out1 = utils.build_tensilelite_client(hip, build_dir=build_dir)
|
|
assert out1 == client
|
|
assert built["n"] == 1
|
|
assert hash_file.is_file()
|
|
|
|
out2 = utils.build_tensilelite_client(hip, build_dir=build_dir)
|
|
assert out2 == client
|
|
assert built["n"] == 1
|