Unverified Commit c17bc0e1 authored by Jacek Galowicz's avatar Jacek Galowicz Committed by GitHub
Browse files

nixos/test-driver: add option to force kvm use (#509553)

parents 111fe9d7 5f5734db
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2246,6 +2246,9 @@
  "test-opt-passthru": [
    "index.html#test-opt-passthru"
  ],
  "test-opt-qemu.forceAccel": [
    "index.html#test-opt-qemu.forceAccel"
  ],
  "test-opt-qemu.package": [
    "index.html#test-opt-qemu.package"
  ],
+15 −8
Original line number Diff line number Diff line
@@ -24,30 +24,37 @@ rec {
    else
      throw "Unknown QEMU serial device for system '${stdenv.hostPlatform.system}'";

  qemuBinary =
    qemuPkg:
  qemuBinary = qemuPkg: qemuBinaryWith { inherit qemuPkg; };

  qemuBinaryWith =
    {
      qemuPkg,
      forceAccel ? false,
    }:
    let
      hostStdenv = qemuPkg.stdenv;
      hostSystem = hostStdenv.system;
      guestSystem = stdenv.hostPlatform.system;

      accel = accelName: if forceAccel then accelName else "${accelName}:tcg";

      linuxHostGuestMatrix = {
        x86_64-linux = "${qemuPkg}/bin/qemu-system-x86_64 -machine accel=kvm:tcg -cpu max";
        armv7l-linux = "${qemuPkg}/bin/qemu-system-arm -machine virt,accel=kvm:tcg -cpu max";
        aarch64-linux = "${qemuPkg}/bin/qemu-system-aarch64 -machine virt,gic-version=max,accel=kvm:tcg -cpu max";
        x86_64-linux = "${qemuPkg}/bin/qemu-system-x86_64 -machine accel=${accel "kvm"} -cpu max";
        armv7l-linux = "${qemuPkg}/bin/qemu-system-arm -machine virt,accel=${accel "kvm"} -cpu max";
        aarch64-linux = "${qemuPkg}/bin/qemu-system-aarch64 -machine virt,gic-version=max,accel=${accel "kvm"} -cpu max";
        powerpc64le-linux = "${qemuPkg}/bin/qemu-system-ppc64 -machine powernv";
        powerpc64-linux = "${qemuPkg}/bin/qemu-system-ppc64 -machine powernv";
        riscv32-linux = "${qemuPkg}/bin/qemu-system-riscv32 -machine virt";
        riscv64-linux = "${qemuPkg}/bin/qemu-system-riscv64 -machine virt";
        x86_64-darwin = "${qemuPkg}/bin/qemu-system-x86_64 -machine accel=kvm:tcg -cpu max";
        x86_64-darwin = "${qemuPkg}/bin/qemu-system-x86_64 -machine accel=${accel "kvm"} -cpu max";
      };
      otherHostGuestMatrix = {
        aarch64-darwin = {
          aarch64-linux = "${qemuPkg}/bin/qemu-system-aarch64 -machine virt,gic-version=2,accel=hvf:tcg -cpu max";
          aarch64-linux = "${qemuPkg}/bin/qemu-system-aarch64 -machine virt,gic-version=2,accel=${accel "hvf"} -cpu max";
          inherit (otherHostGuestMatrix.x86_64-darwin) x86_64-linux;
        };
        x86_64-darwin = {
          x86_64-linux = "${qemuPkg}/bin/qemu-system-x86_64 -machine type=q35,accel=hvf:tcg -cpu max";
          x86_64-linux = "${qemuPkg}/bin/qemu-system-x86_64 -machine type=q35,accel=${accel "hvf"} -cpu max";
        };
      };

+5 −5
Original line number Diff line number Diff line
@@ -7,11 +7,11 @@
  imagemagick_light,
  ipython,
  junit-xml,
  mypy,
  ptpython,
  python,
  ruff,
  remote-pdb,
  ruff,
  ty,

  netpbm,
  nixosTests,
@@ -72,13 +72,13 @@ buildPythonApplication {
  doCheck = true;

  nativeCheckInputs = [
    mypy
    ruff
    ty
  ];

  checkPhase = ''
    echo -e "\x1b[32m## run mypy\x1b[0m"
    mypy test_driver extract-docstrings.py
    echo -e "\x1b[32m## run ty\x1b[0m"
    ty check --error-on-warning test_driver extract-docstrings.py
    echo -e "\x1b[32m## run ruff check\x1b[0m"
    ruff check .
    echo -e "\x1b[32m## run ruff format\x1b[0m"
+1 −20
Original line number Diff line number Diff line
@@ -17,27 +17,8 @@ find = {}
test_driver = ["py.typed"]

[tool.ruff]
target-version = "py312"
target-version = "py313"
line-length = 88

lint.select = ["E", "F", "I", "U", "N"]
lint.ignore = ["E501", "N818"]

# xxx: we can import https://pypi.org/project/types-colorama/ here
[[tool.mypy.overrides]]
module = "colorama.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "ptpython.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "junit_xml.*"
ignore_missing_imports = true

[tool.mypy]
warn_redundant_casts = true
disallow_untyped_calls = true
disallow_untyped_defs = true
no_implicit_optional = true
+3 −3
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ class EnvDefault(argparse.Action):
    environment variable as the flags default value.
    """

    def __init__(self, envvar, required=False, default=None, nargs=None, **kwargs):  # type: ignore
    def __init__(self, envvar, required=False, default=None, nargs=None, **kwargs):
        if not default and envvar:
            if envvar in os.environ:
                if nargs is not None and (nargs.isdigit() or nargs in ["*", "+"]):
@@ -37,7 +37,7 @@ class EnvDefault(argparse.Action):
            required = False
        super().__init__(default=default, required=required, nargs=nargs, **kwargs)

    def __call__(self, parser, namespace, values, option_string=None):  # type: ignore
    def __call__(self, parser, namespace, values, option_string=None):
        setattr(namespace, self.dest, values)


@@ -219,7 +219,7 @@ def main() -> None:
            ptpython.ipython.embed(
                user_ns=driver.test_symbols(),
                history_filename=history_path,
            )  # type:ignore
            )
        else:
            tic = time.time()
            driver.run_tests()
Loading